Add options for hiding placeholders and seperators in tag tabs

This commit is contained in:
Lucas
2019-04-25 14:53:55 +02:00
parent 5b77d64b9c
commit 936173b9f8
8 changed files with 498 additions and 112 deletions

View File

@@ -53,6 +53,28 @@ public interface BankTagsConfig extends Config
return true; return true;
} }
@ConfigItem(
keyName = "removeSeparators",
name = "Remove tab separators in Tag Tabs",
description = "Removes tab separators and corrects item layouts in Tag Tabs to mimic a regular tab",
position = 3
)
default boolean removeSeparators()
{
return true;
}
@ConfigItem(
keyName = "hidePlaceholders",
name = "Hide placeholders",
description = "Hide placeholders in tag tabs or tag search.",
position = 4
)
default boolean hidePlaceholders()
{
return false;
}
@ConfigItem( @ConfigItem(
keyName = "position", keyName = "position",
name = "", name = "",

View File

@@ -2,6 +2,7 @@
* Copyright (c) 2018, Adam <Adam@sigterm.info> * Copyright (c) 2018, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Ron Young <https://github.com/raiyni> * Copyright (c) 2018, Ron Young <https://github.com/raiyni>
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com> * Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* Copyright (c) 2018, Lucas <https://github.com/Lucwousin>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -130,6 +131,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
private SpriteManager spriteManager; private SpriteManager spriteManager;
private boolean shiftPressed = false; private boolean shiftPressed = false;
private int nextRowIndex = 0;
@Provides @Provides
BankTagsConfig getConfig(ConfigManager configManager) BankTagsConfig getConfig(ConfigManager configManager)
@@ -157,6 +159,13 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
shiftPressed = false; shiftPressed = false;
} }
private boolean isSearching()
{
return client.getVar(VarClientInt.INPUT_TYPE) == InputType.SEARCH.getType()
|| (client.getVar(VarClientInt.INPUT_TYPE) <= 0
&& client.getVar(VarClientStr.INPUT_TEXT) != null && client.getVar(VarClientStr.INPUT_TEXT).length() > 0);
}
@Subscribe @Subscribe
public void onScriptCallbackEvent(ScriptCallbackEvent event) public void onScriptCallbackEvent(ScriptCallbackEvent event)
{ {
@@ -195,8 +204,19 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
if (tagManager.findTag(itemId, search)) if (tagManager.findTag(itemId, search))
{ {
// return true if (!config.hidePlaceholders())
intStack[intStackSize - 2] = 1; {
// return true
intStack[intStackSize - 2] = 1;
}
// not a placeholder
else if (itemManager.getItemComposition(itemId).getPlaceholderTemplateId() == -1)
{
// return true
intStack[intStackSize - 2] = 1;
}
break;
} }
else if (!tagSearch) else if (!tagSearch)
{ {
@@ -207,6 +227,61 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
intStack[intStackSize - 1] = tabInterface.isActive() ? 1 : 0; intStack[intStackSize - 1] = tabInterface.isActive() ? 1 : 0;
break; break;
} }
if (!config.removeSeparators() || !isSearching() || !tabInterface.isActive())
{
return;
}
switch (eventName)
{
case "lineSpace":
// prevent Y value being incremented to account for line separators
intStack[intStackSize - 1] = 0;
break;
case "tabTextSpace":
// prevent Y value being incremented to account for "Tab x" text
intStack[intStackSize - 1] = 0;
break;
case "hideLine":
// hide the widget for the line separator
intStack[intStackSize - 1] = 1;
break;
case "hideTabText":
// hide the widget for the "Tab x" text
intStack[intStackSize - 1] = 1;
break;
case "rowIndex":
// remember the next index in the row so we can start the next tab's items there
nextRowIndex = intStack[intStackSize - 1];
break;
case "rowIndexInit":
// set the index to our remembered value instead of 0
intStack[intStackSize - 1] = nextRowIndex;
break;
case "bankLayoutInit":
// reset the row index if the bank is rebuilt
nextRowIndex = 0;
break;
case "newBankRow":
// if we haven't filled a row when the current tab is finished building,
// adjust the y offset to continue the next tab on the same row
if (nextRowIndex != 0)
{
intStack[intStackSize - 2] = intStack[intStackSize - 2] - 32;
}
// if we have filled the row, adjust the y offset to maintain appropriate row spacing
else
{
intStack[intStackSize - 2] = intStack[intStackSize - 2] + 4;
}
break;
case "addLastRow":
// after all tabs are finished building, add an extra row of space
// this ensures the scrollbar is set to the correct height
intStack[intStackSize - 1] = intStack[intStackSize - 1] + 32;
break;
}
} }
@Subscribe @Subscribe

View File

@@ -642,6 +642,15 @@ public class TabInterface
Widget draggedOn = client.getDraggedOnWidget(); Widget draggedOn = client.getDraggedOnWidget();
Widget draggedWidget = client.getDraggedWidget(); Widget draggedWidget = client.getDraggedWidget();
// round-about way to prevent drag reordering when in a tag tab, now that it looks like a normal tab
// returning early from drag release and nulling out the drag release listener have no effect,
// probably a better way to do this though
if (draggedWidget.getId() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && isActive()
&& config.removeSeparators())
{
client.setDraggedOnWidget(null);
}
if (!isDragging || draggedOn == null) if (!isDragging || draggedOn == null)
{ {
return; return;

View File

@@ -0,0 +1 @@
57892EA7C7677AF80D1DA094F34C8A8738F2F4E5DDA2E861680F7D598664B216

View File

@@ -0,0 +1,238 @@
.id 509
.int_stack_count 12
.string_stack_count 0
.int_var_count 18
.string_var_count 0
iconst 0
istore 12
iload 11
iconst 0
if_icmpeq LABEL6
jump LABEL19
LABEL6:
iload 2
iconst 0
if_icmpgt LABEL10
jump LABEL19
LABEL10:
invoke 514
iconst 1
if_icmpeq LABEL14
jump LABEL19
LABEL14:
iload 8
iconst 15
sconst "tabTextSpace" ;
runelite_callback ;
add
istore 12
jump LABEL21
LABEL19:
iload 8
istore 12
LABEL21:
iconst -1
istore 13
iconst 0
istore 14
iconst 0
istore 15
iconst 0
sconst "rowIndexInit" ;
runelite_callback ;
istore 16
iconst 0
istore 17
LABEL31:
iload 0
iload 1
if_icmplt LABEL35
jump LABEL107
LABEL35:
iload 3
iload 0
cc_find
iconst 1
if_icmpeq LABEL41
jump LABEL102
LABEL41:
iconst 95
iload 0
inv_getobj
istore 13
iload 13
invoke 279
iconst 1
if_icmpeq LABEL50
jump LABEL102
LABEL50:
iconst 0
cc_sethide
iload 13
iconst 95
iload 0
inv_getnum
iload 3
iload 4
iload 5
iload 6
iload 7
invoke 278
iload 15
iconst 1
add
istore 15
iload 12
iload 17
iconst 36
multiply
add
istore 14
iconst 51
iload 16
iconst 36
iload 9
add
multiply
add
iload 14
iconst 0
iconst 0
cc_setposition
iload 14
iconst 32
add
istore 14
iload 16
iload 10
if_icmplt LABEL91
jump LABEL96
LABEL91:
iload 16
iconst 1
add
sconst "rowIndex" ;
runelite_callback ;
istore 16
jump LABEL102
LABEL96:
iconst 0
iload 17
iconst 1
add
istore 17
sconst "rowIndex" ;
runelite_callback ;
istore 16
LABEL102:
iload 0
iconst 1
add
istore 0
jump LABEL31
LABEL107:
iload 14
iconst 0
if_icmple LABEL111
jump LABEL114
LABEL111:
iload 8
iload 15
return
LABEL114:
iload 11
iconst 0
if_icmpeq LABEL118
jump LABEL189
LABEL118:
iload 16
iconst 0
if_icmpgt LABEL122
jump LABEL166
LABEL122:
iload 3
iconst 816
iconst 9
iconst 2
multiply
add
iload 2
add
cc_find
iconst 1
if_icmpeq LABEL134
jump LABEL166
LABEL134:
iconst 0
sconst "hideTabText" ;
runelite_callback ;
cc_sethide
iconst 51
iload 16
iconst 36
iload 9
add
multiply
add
iload 14
iconst 32
sub
iconst 0
iconst 0
cc_setposition
iconst 8
iload 16
sub
istore 16
iload 16
iconst 36
multiply
iload 16
iconst 1
sub
iload 9
multiply
add
iconst 32
iconst 0
iconst 0
cc_setsize
LABEL166:
iload 12
iload 8
if_icmpgt LABEL170
jump LABEL189
LABEL170:
iload 3
iconst 816
iconst 9
add
iload 2
add
iconst 1
sub
cc_find
iconst 1
if_icmpeq LABEL182
jump LABEL189
LABEL182:
iconst 51
iload 8
iconst 0
iconst 0
cc_setposition
iconst 0
sconst "hideTabText" ;
runelite_callback ;
cc_sethide
LABEL189:
iload 14
iload 2 ;
sconst "newBankRow" ;
runelite_callback ;
pop_int ;
iload 15
return
iconst 0
iconst 0
return

View File

@@ -0,0 +1 @@
F7482938547BB43B14BCE44F35FC7555EBA9EF3A9D2E4AAEA916DF2855387F07

View File

@@ -0,0 +1,36 @@
.id 510
.int_stack_count 3
.string_stack_count 0
.int_var_count 3
.string_var_count 0
iload 1
iconst 816
iload 0
add
iconst 1
sub
cc_find
iconst 1
if_icmpeq LABEL10
jump LABEL19
LABEL10:
iconst 51
iload 2
iconst 5
add
iconst 0
iconst 0
cc_setposition
iconst 0
sconst "hideLine" ;
runelite_callback ;
cc_sethide
LABEL19:
iload 2
iconst 12
sconst "lineSpace" ;
runelite_callback ;
add
return
iconst 0
return

View File

@@ -3,6 +3,8 @@
.string_stack_count 0 .string_stack_count 0
.int_var_count 36 .int_var_count 36
.string_var_count 1 .string_var_count 1
sconst "bankLayoutInit" ;
runelite_callback ;
get_varbit 5102 get_varbit 5102
iconst 1 iconst 1
if_icmpeq LABEL4 if_icmpeq LABEL4
@@ -824,6 +826,8 @@ LABEL732:
iload 11 iload 11
iload 12 iload 12
iload 28 iload 28
sconst "addLastRow" ;
runelite_callback ;
iload 29 iload 29
iload 13 iload 13
iload 14 iload 14