From 53cf50074f5919ecedb447bfdf99f8f294bcad72 Mon Sep 17 00:00:00 2001 From: Kyle <48519776+xKylee@users.noreply.github.com> Date: Sun, 25 Aug 2019 17:34:25 +0100 Subject: [PATCH] inventory tags: add 4 additional tags (#1417) * Update InventoryTagsConfig.java * Update InventoryTagsPlugin.java * config: Add support for multiple values on hide and unhide values * inventorytags: Amount of groups --- .../client/plugins/config/ConfigPanel.java | 16 ++- .../inventorytags/InventoryTagsConfig.java | 120 +++++++++++++++++- .../inventorytags/InventoryTagsPlugin.java | 33 ++++- 3 files changed, 156 insertions(+), 13 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java index dcc55c1d91..bbe48e17b1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java @@ -662,11 +662,23 @@ public class ConfigPanel extends PluginPanel @SuppressWarnings("unchecked") Enum selectedItem = Enum.valueOf(type, configManager.getConfiguration(cd.getGroup().value(), cid2.getItem().keyName())); if (!cid.getItem().unhideValue().equals("")) { - show = selectedItem.toString().equals(cid.getItem().unhideValue()); + List unhideValue = Splitter + .onPattern("\\|\\|") + .trimResults() + .omitEmptyStrings() + .splitToList(cid.getItem().unhideValue()); + + show = unhideValue.contains(selectedItem.toString()); } else if (!cid.getItem().hideValue().equals("")) { - show = !selectedItem.toString().equals(cid.getItem().hideValue()); + List hideValue = Splitter + .onPattern("\\|\\|") + .trimResults() + .omitEmptyStrings() + .splitToList(cid.getItem().hideValue()); + + show = !hideValue.contains(selectedItem.toString()); } } catch (IllegalArgumentException ex) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsConfig.java index 12cff9fcec..edfe77df84 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsConfig.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.inventorytags; import java.awt.Color; +import lombok.RequiredArgsConstructor; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @@ -34,11 +35,51 @@ public interface InventoryTagsConfig extends Config { String GROUP = "inventorytags"; + @RequiredArgsConstructor + enum amount + { + ONE("1"), + TWO("2"), + THREE("3"), + FOUR("4"), + FIVE("5"), + SIX("6"), + SEVEN("7"), + EIGHT("8"); + + private final String name; + + @Override + public String toString() + { + return name; + } + + public int toInt() + { + return Integer.parseInt(name); + } + } + @ConfigItem( position = 0, + keyName = "amount", + name = "Amount of groups", + description = "The amount of inventory groups" + ) + default amount getAmount() + { + return amount.FOUR; + } + + @ConfigItem( + position = 1, keyName = "groupColor1", name = "Group 1 Color", - description = "Color of the Tag" + description = "Color of the Tag", + hidden = true, + unhide = "amount", + unhideValue = "1 || 2 || 3 || 4 || 5 || 6 || 7 || 8" ) default Color getGroup1Color() { @@ -46,10 +87,13 @@ public interface InventoryTagsConfig extends Config } @ConfigItem( - position = 1, + position = 2, keyName = "groupColor2", name = "Group 2 Color", - description = "Color of the Tag" + description = "Color of the Tag", + hidden = true, + unhide = "amount", + unhideValue = "2 || 3 || 4 || 5 || 6 || 7 || 8" ) default Color getGroup2Color() { @@ -57,10 +101,13 @@ public interface InventoryTagsConfig extends Config } @ConfigItem( - position = 2, + position = 3, keyName = "groupColor3", name = "Group 3 Color", - description = "Color of the Tag" + description = "Color of the Tag", + hidden = true, + unhide = "amount", + unhideValue = "3 || 4 || 5 || 6 || 7 || 8" ) default Color getGroup3Color() { @@ -68,13 +115,72 @@ public interface InventoryTagsConfig extends Config } @ConfigItem( - position = 3, + position = 4, keyName = "groupColor4", name = "Group 4 Color", - description = "Color of the Tag" + description = "Color of the Tag", + hidden = true, + unhide = "amount", + unhideValue = "4 || 5 || 6 || 7 || 8" ) default Color getGroup4Color() { return new Color(255, 0, 255); } + + @ConfigItem( + position = 5, + keyName = "groupColor5", + name = "Group 5 Color", + description = "Color of the Tag", + hidden = true, + unhide = "amount", + unhideValue = "5 || 6 || 7 || 8" + ) + default Color getGroup5Color() + { + return new Color(0, 255, 246); + } + + @ConfigItem( + position = 6, + keyName = "groupColor6", + name = "Group 6 Color", + description = "Color of the Tag", + hidden = true, + unhide = "amount", + unhideValue = "6 || 7 || 8" + ) + default Color getGroup6Color() + { + return new Color(248, 255, 244); + } + + @ConfigItem( + position = 7, + keyName = "groupColor7", + name = "Group 7 Color", + description = "Color of the Tag", + hidden = true, + unhide = "amount", + unhideValue = "7 || 8" + ) + default Color getGroup7Color() + { + return new Color(0, 0, 0); + } + + @ConfigItem( + position = 8, + keyName = "groupColor8", + name = "Group 8 Color", + description = "Color of the Tag", + hidden = true, + unhide = "amount", + unhideValue = "8" + ) + default Color getGroup8Color() + { + return new Color(104, 105, 255); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java index f33d73734e..ddeb00e0b3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java @@ -64,6 +64,11 @@ public class InventoryTagsPlugin extends Plugin private static final String SETNAME_GROUP_2 = "Group 2"; private static final String SETNAME_GROUP_3 = "Group 3"; private static final String SETNAME_GROUP_4 = "Group 4"; + private static final String SETNAME_GROUP_5 = "Group 5"; + private static final String SETNAME_GROUP_6 = "Group 6"; + private static final String SETNAME_GROUP_7 = "Group 7"; + private static final String SETNAME_GROUP_8 = "Group 8"; + private static final String CONFIGURE = "Configure"; private static final String SAVE = "Save"; @@ -84,7 +89,8 @@ public class InventoryTagsPlugin extends Plugin private static final WidgetMenuOption RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_SAVE = new WidgetMenuOption(SAVE, MENU_TARGET, WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_TAB); - private static final List GROUPS = ImmutableList.of(SETNAME_GROUP_4, SETNAME_GROUP_3, SETNAME_GROUP_2, SETNAME_GROUP_1); + private static final List GROUPS = ImmutableList.of(SETNAME_GROUP_8, SETNAME_GROUP_7, SETNAME_GROUP_6, + SETNAME_GROUP_5, SETNAME_GROUP_4, SETNAME_GROUP_3, SETNAME_GROUP_2, SETNAME_GROUP_1); @Inject private Client client; @@ -109,10 +115,15 @@ public class InventoryTagsPlugin extends Plugin private boolean editorMode; + private InventoryTagsConfig.amount amount; private Color group1Color; private Color group2Color; private Color group3Color; private Color group4Color; + private Color group5Color; + private Color group6Color; + private Color group7Color; + private Color group8Color; @Provides InventoryTagsConfig provideConfig(ConfigManager configManager) @@ -220,13 +231,15 @@ public class InventoryTagsPlugin extends Plugin return; } - MenuEntry[] menuList = new MenuEntry[GROUPS.size() + 1]; + MenuEntry[] menuList = new MenuEntry[amount.toInt() + 1]; int num = 0; // preserve the 'Cancel' option as the client will reuse the first entry for Cancel and only resets option/action menuList[num++] = event.getMenuEntries()[0]; - for (final String groupName : GROUPS) + List groups = GROUPS.subList(Math.max(GROUPS.size() - amount.toInt(), 0), GROUPS.size()); + + for (final String groupName : groups) { final String group = getTag(itemId); final MenuEntry newMenu = new MenuEntry(); @@ -257,8 +270,15 @@ public class InventoryTagsPlugin extends Plugin return this.group3Color; case SETNAME_GROUP_4: return this.group4Color; + case SETNAME_GROUP_5: + return this.group5Color; + case SETNAME_GROUP_6: + return this.group6Color; + case SETNAME_GROUP_7: + return this.group7Color; + case SETNAME_GROUP_8: + return this.group8Color; } - return null; } @@ -299,9 +319,14 @@ public class InventoryTagsPlugin extends Plugin private void updateConfig() { + this.amount = config.getAmount(); this.group1Color = config.getGroup1Color(); this.group2Color = config.getGroup2Color(); this.group3Color = config.getGroup3Color(); this.group4Color = config.getGroup4Color(); + this.group5Color = config.getGroup5Color(); + this.group6Color = config.getGroup6Color(); + this.group7Color = config.getGroup7Color(); + this.group8Color = config.getGroup8Color(); } }