Skip to content

Commit

Permalink
open tabinterface when using a custom banktag
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Oct 19, 2024
1 parent 6441a7c commit 391cf53
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,22 @@
* A bank tag. Plugins may implement this interface to define custom bank tags.
* You may register a BankTag with {@link TagManager#registerTag(String, BankTag)} to
* make it searchable in the bank UI and tab interface. You may also set the active bank tag
* via {@link BankTagsService#openBankTag(BankTag)}, regardless of if the banktag is registered.
* via {@link BankTagsService#openBankTag(String, BankTag)}, regardless of if the banktag is registered.
*
* @see TagManager#registerTag(String, BankTag)
* @see TagManager#unregisterTag(String)
* @see BankTagsService#openBankTag(BankTag)
* @see BankTagsService#openBankTag(String, BankTag)
*/
public interface BankTag
{
/**
* Bank tag is allowed to be modified
*/
int OPTION_ALLOW_MODIFICATIONS = 1;
/**
* Option to hide the tag name from the "Remove-tag" menu option.
*/
int OPTION_HIDE_REMOVE_TAG_NAME = 1;
int OPTION_HIDE_REMOVE_TAG_NAME = 2;

/**
* Test if an item is in the tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,12 @@ public Layout layout()
{
return layout;
}

@Override
public int options()
{
return BankTag.OPTION_ALLOW_MODIFICATIONS;
}
};

tabInterface.openTag(tag, activeTag, true);
Expand All @@ -493,11 +499,10 @@ private BankTag buildSearchFilterBankTag(String tag)
}

@Override
public void openBankTag(BankTag bankTag)
public void openBankTag(String name, BankTag bankTag)
{
tabInterface.closeTag(false);
activeTag = bankTag;
bankSearch.layoutBank();
tabInterface.openTag(name, activeTag, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ public interface BankTagsService
void openBankTag(String tag);

/**
* Open the given {@link BankTag}. The bank tag is ephemeral and is implemented by the caller. The tags may not
* be modified by the end user, and changes to the tag are not persisted. No part of the bank tag is saved by the
* Bank tag plugin. If the {@link BankTag} has an associated {@link net.runelite.client.plugins.banktags.tabs.Layout},
* Open the given {@link BankTag}. The bank tag is implemented by the caller.
* The tag may have an associated {@link net.runelite.client.plugins.banktags.tabs.TagTab},
* but this isn't required. If the tag has an associated {@link net.runelite.client.plugins.banktags.tabs.Layout},
* the layout will be applied.
* @param bankTag
*
* @param name the tag name
* @param bankTag the bank tag
*/
void openBankTag(BankTag bankTag);
void openBankTag(String name, BankTag bankTag);

/**
* Close the currently open {@link BankTag}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void setTags(int itemId, Collection<String> tags, boolean variation)
setTagString(itemId, Text.toCSV(tags), variation);
}

boolean findTag(int itemId, String search)
public boolean findTag(int itemId, String search)
{
Collection<String> tags = getTags(itemId, false);
tags.addAll(getTags(itemId, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,12 @@ else if (qty == 0)
c.setItemQuantity(Integer.MAX_VALUE);
c.setItemQuantityMode(ItemQuantityMode.NEVER);

// TabInterface rewrites these to RUNELITE types and adds handlers
c.setAction(7 - 1, DUPLICATE_ITEM);
c.setAction(8 - 1, REMOVE_LAYOUT);
if ((plugin.getActiveTag().options() & BankTag.OPTION_ALLOW_MODIFICATIONS) != 0)
{
// TabInterface rewrites these to RUNELITE types and adds handlers
c.setAction(7 - 1, DUPLICATE_ITEM);
c.setAction(8 - 1, REMOVE_LAYOUT);
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@ private void opTagTab(ScriptEvent event)
@Subscribe
private void onMenuEntryAdded(MenuEntryAdded event)
{
if (activeBankTag != null && (activeBankTag.options() & BankTag.OPTION_ALLOW_MODIFICATIONS) == 0)
{
return;
}

if (activeBankTag != null
&& event.getActionParam1() == ComponentID.BANK_ITEM_CONTAINER
&& event.getOption().equals("Examine"))
Expand Down Expand Up @@ -919,8 +924,9 @@ public void onDraggingWidgetChanged(DraggingWidgetChanged event)

// Returning early or nulling the drag release listener has no effect. Hence, we need to
// null the draggedOnWidget instead.
if (draggedWidget.getId() == ComponentID.BANK_ITEM_CONTAINER && activeBankTag != null && activeBankTag.layout() == null
&& config.preventTagTabDrags())
if (draggedWidget.getId() == ComponentID.BANK_ITEM_CONTAINER && activeBankTag != null
&& (activeBankTag.layout() == null && config.preventTagTabDrags()
|| (activeBankTag.options() & BankTag.OPTION_ALLOW_MODIFICATIONS) == 0))
{
client.setDraggedOnWidget(null);
}
Expand Down

0 comments on commit 391cf53

Please sign in to comment.