banktags: use script event for detecting bank search
The bank plugin is being changed to manually initiate bank searches, by invoking the script, and the bank tabs plugin needs to be able to detect this search too.
This commit is contained in:
@@ -458,7 +458,8 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onScriptPreFired(ScriptPreFired event)
|
public void onScriptPreFired(ScriptPreFired event)
|
||||||
{
|
{
|
||||||
if (event.getScriptId() == ScriptID.BANKMAIN_FINISHBUILDING)
|
int scriptId = event.getScriptId();
|
||||||
|
if (scriptId == ScriptID.BANKMAIN_FINISHBUILDING)
|
||||||
{
|
{
|
||||||
// Since we apply tag tab search filters even when the bank is not in search mode,
|
// Since we apply tag tab search filters even when the bank is not in search mode,
|
||||||
// bankkmain_build will reset the bank title to "The Bank of Gielinor". So apply our
|
// bankkmain_build will reset the bank title to "The Bank of Gielinor". So apply our
|
||||||
@@ -476,6 +477,10 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
|
|||||||
bankTitle.setText("Tag tab <col=ff0000>" + activeTab.getTag() + "</col>");
|
bankTitle.setText("Tag tab <col=ff0000>" + activeTab.getTag() + "</col>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (scriptId == ScriptID.BANKMAIN_SEARCH_TOGGLE)
|
||||||
|
{
|
||||||
|
tabInterface.handleSearch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ public class TabInterface
|
|||||||
|
|
||||||
final Iterator<String> dataIter = Text.fromCSV(dataString).iterator();
|
final Iterator<String> dataIter = Text.fromCSV(dataString).iterator();
|
||||||
String name = dataIter.next();
|
String name = dataIter.next();
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (char c : name.toCharArray())
|
for (char c : name.toCharArray())
|
||||||
{
|
{
|
||||||
if (FILTERED_CHARS.test(c))
|
if (FILTERED_CHARS.test(c))
|
||||||
@@ -369,7 +369,7 @@ public class TabInterface
|
|||||||
|
|
||||||
while (dataIter.hasNext())
|
while (dataIter.hasNext())
|
||||||
{
|
{
|
||||||
final int itemId = Integer.valueOf(dataIter.next());
|
final int itemId = Integer.parseInt(dataIter.next());
|
||||||
tagManager.addTag(itemId, name, itemId < 0);
|
tagManager.addTag(itemId, name, itemId < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,16 +656,6 @@ public class TabInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (activeTab != null
|
if (activeTab != null
|
||||||
&& event.getMenuOption().equals("Search")
|
|
||||||
&& client.getWidget(WidgetInfo.BANK_SEARCH_BUTTON_BACKGROUND).getSpriteId() != SpriteID.EQUIPMENT_SLOT_SELECTED)
|
|
||||||
{
|
|
||||||
activateTab(null);
|
|
||||||
// This ensures that when clicking Search when tab is selected, the search input is opened rather
|
|
||||||
// than client trying to close it first
|
|
||||||
client.setVar(VarClientStr.INPUT_TEXT, "");
|
|
||||||
client.setVar(VarClientInt.INPUT_TYPE, 0);
|
|
||||||
}
|
|
||||||
else if (activeTab != null
|
|
||||||
&& (event.getMenuOption().startsWith("View tab") || event.getMenuOption().equals("View all items")))
|
&& (event.getMenuOption().startsWith("View tab") || event.getMenuOption().equals("View all items")))
|
||||||
{
|
{
|
||||||
activateTab(null);
|
activateTab(null);
|
||||||
@@ -696,6 +686,18 @@ public class TabInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleSearch()
|
||||||
|
{
|
||||||
|
if (activeTab != null)
|
||||||
|
{
|
||||||
|
activateTab(null);
|
||||||
|
// This ensures that when clicking Search when tab is selected, the search input is opened rather
|
||||||
|
// than client trying to close it first
|
||||||
|
client.setVar(VarClientStr.INPUT_TEXT, "");
|
||||||
|
client.setVar(VarClientInt.INPUT_TYPE, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateTabIfActive(final Collection<String> tags)
|
public void updateTabIfActive(final Collection<String> tags)
|
||||||
{
|
{
|
||||||
if (activeTab != null && tags.contains(activeTab.getTag()))
|
if (activeTab != null && tags.contains(activeTab.getTag()))
|
||||||
@@ -1158,11 +1160,10 @@ public class TabInterface
|
|||||||
t.revalidate();
|
t.revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ItemComposition getItem(int idx)
|
private ItemComposition getItem(int idx)
|
||||||
{
|
{
|
||||||
ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
|
ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
|
||||||
Item item = bankContainer.getItems()[idx];
|
Item item = bankContainer.getItem(idx);
|
||||||
return itemManager.getItemComposition(item.getId());
|
return itemManager.getItemComposition(item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user