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;
}
@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(
keyName = "position",
name = "",

View File

@@ -2,6 +2,7 @@
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Ron Young <https://github.com/raiyni>
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* Copyright (c) 2018, Lucas <https://github.com/Lucwousin>
* All rights reserved.
*
* 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 boolean shiftPressed = false;
private int nextRowIndex = 0;
@Provides
BankTagsConfig getConfig(ConfigManager configManager)
@@ -157,6 +159,13 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
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
public void onScriptCallbackEvent(ScriptCallbackEvent event)
{
@@ -195,8 +204,19 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
if (tagManager.findTag(itemId, search))
{
// return true
intStack[intStackSize - 2] = 1;
if (!config.hidePlaceholders())
{
// 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)
{
@@ -207,6 +227,61 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
intStack[intStackSize - 1] = tabInterface.isActive() ? 1 : 0;
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

View File

@@ -642,6 +642,15 @@ public class TabInterface
Widget draggedOn = client.getDraggedOnWidget();
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)
{
return;