diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetup.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetup.java
index a71c109185..71f3b2567a 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetup.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetup.java
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
+ * Copyright (c) 2019, dillydill123
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,16 +24,65 @@
*/
package net.runelite.client.plugins.inventorysetups;
-import java.util.List;
-import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
+import lombok.Setter;
+import java.awt.Color;
+import java.util.ArrayList;
@AllArgsConstructor
public class InventorySetup
{
- @Getter(AccessLevel.PUBLIC)
- private List inventory;
- @Getter(AccessLevel.PUBLIC)
- private List equipment;
-}
\ No newline at end of file
+ @Getter
+ private ArrayList inventory;
+
+ @Getter
+ private ArrayList equipment;
+
+ @Getter
+ private ArrayList rune_pouch;
+
+ @Getter
+ @Setter
+ private String name;
+
+ @Getter
+ @Setter
+ private Color highlightColor;
+
+ @Getter
+ @Setter
+ private boolean stackDifference;
+
+ @Getter
+ @Setter
+ private boolean variationDifference;
+
+ @Getter
+ @Setter
+ private boolean highlightDifference;
+
+ @Getter
+ @Setter
+ private boolean filterBank;
+
+ @Getter
+ @Setter
+ private boolean unorderedHighlight;
+
+ public void updateInventory(final ArrayList inv)
+ {
+ inventory = inv;
+ }
+
+ public void updateEquipment(final ArrayList eqp)
+ {
+ equipment = eqp;
+ }
+
+ public void updateRunePouch(final ArrayList rp)
+ {
+ rune_pouch = rp;
+ }
+
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupBankOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupBankOverlay.java
deleted file mode 100644
index 594931fdb0..0000000000
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupBankOverlay.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package net.runelite.client.plugins.inventorysetups;
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.Rectangle;
-import java.awt.image.BufferedImage;
-import java.util.stream.IntStream;
-import javax.inject.Inject;
-import lombok.extern.slf4j.Slf4j;
-import net.runelite.api.widgets.WidgetItem;
-import net.runelite.client.game.ItemManager;
-import net.runelite.client.ui.FontManager;
-import net.runelite.client.ui.overlay.WidgetItemOverlay;
-
-@Slf4j
-public class InventorySetupBankOverlay extends WidgetItemOverlay
-{
- private final ItemManager itemManager;
- private final InventorySetupPlugin plugin;
-
- @Inject
- public InventorySetupBankOverlay(ItemManager itemManager, InventorySetupPlugin plugin)
- {
- this.itemManager = itemManager;
- this.plugin = plugin;
- showOnBank();
- }
-
- @Override
- public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
- {
- if (plugin.isGetBankHighlight())
- {
- int[] ids = plugin.getCurrentInventorySetupIds();
- if (ids == null)
- {
- return;
- }
-
- if (IntStream.of(ids).noneMatch(x -> x == itemId))
- {
- return;
- }
-
-
- final Color color = plugin.getGetBankHighlightColor();
-
- if (color != null)
- {
- Rectangle bounds = itemWidget.getCanvasBounds();
- final BufferedImage outline = itemManager.getItemOutline(itemId, itemWidget.getQuantity(), color);
- graphics.drawImage(outline, (int) bounds.getX() + 1, (int) bounds.getY() + 1, null);
-
- if (itemWidget.getQuantity() > 1)
- {
- drawQuantity(graphics, itemWidget, Color.YELLOW);
- }
- else if (itemWidget.getQuantity() == 0)
- {
- drawQuantity(graphics, itemWidget, Color.YELLOW.darker());
- }
- }
- }
- }
-
- private void drawQuantity(Graphics2D graphics, WidgetItem item, Color darker)
- {
- graphics.setColor(Color.BLACK);
- graphics.drawString(String.valueOf(item.getQuantity()), item.getCanvasLocation().getX() + 2, item.getCanvasLocation().getY() + 11);
- graphics.setColor(darker);
- graphics.setFont(FontManager.getRunescapeSmallFont());
- graphics.drawString(String.valueOf(item.getQuantity()), item.getCanvasLocation().getX() + 1, item.getCanvasLocation().getY() + 10);
- }
-}
\ No newline at end of file
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupConfig.java
index 1a0f42f961..4e64a10019 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupConfig.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupConfig.java
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
+ * Copyright (c) 2019, dillydill123
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,82 +25,78 @@
package net.runelite.client.plugins.inventorysetups;
import java.awt.Color;
+import net.runelite.client.config.Alpha;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
-@ConfigGroup("inventorysetups")
+@ConfigGroup(InventorySetupPlugin.CONFIG_GROUP)
public interface InventorySetupConfig extends Config
{
@ConfigItem(
- keyName = "highlightDifferences",
- name = "Highlight Differences",
- description = "Highlight slots that don't match the selected setup",
+ keyName = "bankFilter",
+ name = "Default Filter Bank",
+ description = "Configures the default setting for bank filtering in new setups",
position = 0
)
-
- default boolean getHighlightDifferences()
+ default boolean bankFilter()
{
return false;
}
@ConfigItem(
- keyName = "highlightDifferenceColor",
- name = "Highlight Color",
- description = "The color used to highlight differences between setups",
+ keyName = "highlightStackDifference",
+ name = "Default Highlight Stack Difference",
+ description = "Configures the default setting for highlighting stack differences in new setups",
position = 1
)
-
- default Color getHighlightColor()
- {
- return Color.RED;
- }
-
- @ConfigItem(
- keyName = "stackDifference",
- name = "Stack Difference",
- description = "Differences between setups will be highlighted if the stack size is different",
- position = 2
- )
-
- default boolean getStackDifference()
+ default boolean highlightStackDifference()
{
return false;
}
@ConfigItem(
- keyName = "variationDifference",
- name = "Variation Difference",
- description = "Variations of items (E.g., charged jewellery) will be counted as different",
+ keyName = "highlightVarianceDifference",
+ name = "Default Highlight Variation Difference",
+ description = "Configures the default setting for highlighting variations in new setups",
position = 2
)
-
- default boolean getVariationDifference()
+ default boolean highlightVariationDifference()
{
return false;
}
@ConfigItem(
- keyName = "bankHighlight",
- name = "Bank Highlight",
- description = "Highlight setup items in bank",
+ keyName = "highlightUnorderedDifference",
+ name = "Default Highlight Unordered Difference",
+ description = "Configures the default setting for unordered highlighting in new setups",
+ position = 3
+ )
+ default boolean highlightUnorderedDifference()
+ {
+ return false;
+ }
+
+ @ConfigItem(
+ keyName = "highlightDifference",
+ name = "Default Highlight",
+ description = "Configures the default setting for highlighting differences in new setups",
position = 4
)
-
- default boolean getBankHighlight()
+ default boolean highlightDifference()
{
return false;
}
+ @Alpha
@ConfigItem(
- keyName = "bankHighlightColor",
- name = "Bank Highlight Color",
- description = "The color used to highlight setup items in bank",
+ keyName = "highlightColor",
+ name = "Default Highlight Color",
+ description = "Configures the default highlighting color in new setups",
position = 5
)
-
- default Color getBankHighlightColor()
+ default Color highlightColor()
{
return Color.RED;
}
-}
\ No newline at end of file
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupItem.java
index cda1fc2c89..d20a723a1a 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupItem.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupItem.java
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
+ * Copyright (c) 2019, dillydill123
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,17 +24,16 @@
*/
package net.runelite.client.plugins.inventorysetups;
-import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
public class InventorySetupItem
{
- @Getter(AccessLevel.PUBLIC)
+ @Getter
private final int id;
- @Getter(AccessLevel.PUBLIC)
+ @Getter
private final String name;
- @Getter(AccessLevel.PUBLIC)
+ @Getter
private final int quantity;
-}
\ No newline at end of file
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupPlugin.java
index cf81a37cfa..9a7452e0a0 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupPlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupPlugin.java
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
+ * Copyright (c) 2019, dillydill123
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,115 +28,129 @@ import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.inject.Provides;
import java.awt.Color;
-import java.awt.image.BufferedImage;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-import lombok.AccessLevel;
+import net.runelite.client.events.ConfigChanged;
+import net.runelite.client.plugins.PluginType;
+import net.runelite.client.plugins.inventorysetups.ui.InventorySetupPluginPanel;
+import net.runelite.client.plugins.inventorysetups.ui.InventorySetupSlot;
+import joptsimple.internal.Strings;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
-import net.runelite.api.ItemContainer;
import net.runelite.api.ItemDefinition;
+import net.runelite.api.ItemContainer;
+import net.runelite.api.ItemID;
+import net.runelite.api.Varbits;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.ItemContainerChanged;
+import net.runelite.api.events.ScriptCallbackEvent;
+import net.runelite.api.events.WidgetLoaded;
+import net.runelite.api.vars.InputType;
+import net.runelite.api.widgets.WidgetID;
+import net.runelite.client.account.AccountSession;
+import net.runelite.client.account.SessionManager;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
-import net.runelite.client.events.ConfigChanged;
+import net.runelite.client.events.SessionClose;
+import net.runelite.client.events.SessionOpen;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemVariationMapping;
+import net.runelite.client.game.chatbox.ChatboxItemSearch;
+import net.runelite.client.game.chatbox.ChatboxPanelManager;
+import net.runelite.client.game.chatbox.ChatboxTextInput;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
-import net.runelite.client.plugins.PluginType;
-import net.runelite.client.plugins.inventorysetups.ui.InventorySetupPluginPanel;
+import net.runelite.client.plugins.banktags.tabs.BankSearch;
+import net.runelite.client.plugins.runepouch.Runes;
import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton;
-import net.runelite.client.ui.overlay.OverlayManager;
+import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
import net.runelite.client.util.ImageUtil;
+import javax.inject.Inject;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+import java.awt.Toolkit;
+import java.awt.datatransfer.StringSelection;
+import java.awt.image.BufferedImage;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
@PluginDescriptor(
name = "Inventory Setups",
- description = "Save inventory setups",
+ description = "Save gear setups for specific activities",
tags = {"items", "inventory", "setups"},
type = PluginType.UTILITY,
enabledByDefault = false
)
@Slf4j
-@Singleton
public class InventorySetupPlugin extends Plugin
{
- private static final String CONFIG_GROUP = "inventorysetups";
- private static final String CONFIG_KEY = "setups";
+
+ public static final String CONFIG_GROUP = "inventorysetups";
+ public static final String CONFIG_KEY = "setups";
+ public static final String INV_SEARCH = "inv:";
private static final int NUM_INVENTORY_ITEMS = 28;
private static final int NUM_EQUIPMENT_ITEMS = 14;
-
+ private static final Varbits[] RUNE_POUCH_AMOUNT_VARBITS =
+ {
+ Varbits.RUNE_POUCH_AMOUNT1, Varbits.RUNE_POUCH_AMOUNT2, Varbits.RUNE_POUCH_AMOUNT3
+ };
+ private static final Varbits[] RUNE_POUCH_RUNE_VARBITS =
+ {
+ Varbits.RUNE_POUCH_RUNE1, Varbits.RUNE_POUCH_RUNE2, Varbits.RUNE_POUCH_RUNE3
+ };
@Inject
private Client client;
-
+ @Inject
+ private SessionManager sessionManager;
@Inject
private ItemManager itemManager;
-
- @Inject
- private InventorySetupBankOverlay overlay;
-
@Inject
private ClientToolbar clientToolbar;
-
- @Inject
- private InventorySetupConfig config;
-
- @Inject
- private OverlayManager overlayManager;
-
@Inject
private ClientThread clientThread;
-
@Inject
private ConfigManager configManager;
-
+ @Inject
+ private InventorySetupConfig config;
+ @Inject
+ @Getter
+ private ColorPickerManager colorPickerManager;
private InventorySetupPluginPanel panel;
-
- private final Map inventorySetups = new HashMap<>();
-
+ @Getter
+ private ArrayList inventorySetups;
private NavigationButton navButton;
+ @Inject
+ private BankSearch bankSearch;
+ @Inject
+ private ChatboxItemSearch itemSearch;
+ @Inject
+ private ChatboxPanelManager chatboxPanelManager;
+ private ChatboxTextInput searchInput;
+ private boolean bankFilter;
+ private boolean highlightStackDifference;
+ private boolean highlightVariationDifference;
+ private boolean highlightUnorderedDifference;
private boolean highlightDifference;
+ private Color highlightColor;
- private boolean getHighlightDifferences;
- @Getter(AccessLevel.PUBLIC)
- private Color getHighlightColor;
- @Getter(AccessLevel.PUBLIC)
- private boolean getStackDifference;
- @Getter(AccessLevel.PUBLIC)
- private boolean getVariationDifference;
- @Getter(AccessLevel.PACKAGE)
- private boolean getBankHighlight;
- @Getter(AccessLevel.PACKAGE)
- private Color getBankHighlightColor;
+ @Provides
+ InventorySetupConfig getConfig(ConfigManager configManager)
+ {
+ return configManager.getConfig(InventorySetupConfig.class);
+ }
@Override
public void startUp()
{
- updateConfigOptions();
-
- overlayManager.add(overlay);
+ updateConfig();
panel = new InventorySetupPluginPanel(this, itemManager);
-
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "inventorysetups_icon.png");
navButton = NavigationButton.builder()
@@ -158,10 +171,21 @@ public class InventorySetupPlugin extends Plugin
}
loadConfig();
- panel.showNoSetupsPanel();
+
+ SwingUtilities.invokeLater(() ->
+ {
+ panel.rebuild();
+ });
+
return true;
});
+ }
+ @Override
+ public void shutDown()
+ {
+ clientToolbar.removeNavigation(navButton);
+ bankSearch.reset(true);
}
public void addInventorySetup()
@@ -177,215 +201,384 @@ public class InventorySetupPlugin extends Plugin
return;
}
- if (name.isEmpty())
+ clientThread.invokeLater(() ->
+ {
+ ArrayList inv = getNormalizedContainer(InventoryID.INVENTORY);
+ ArrayList eqp = getNormalizedContainer(InventoryID.EQUIPMENT);
+
+ ArrayList runePouchData = null;
+ if (checkIfContainerContainsItem(ItemID.RUNE_POUCH, inv, false))
+ {
+ runePouchData = getRunePouchData();
+ }
+
+ final InventorySetup invSetup = new InventorySetup(inv, eqp, runePouchData, name,
+ this.highlightColor,
+ this.highlightStackDifference,
+ this.highlightVariationDifference,
+ this.highlightDifference,
+ this.bankFilter,
+ this.highlightUnorderedDifference);
+ addInventorySetupClientThread(invSetup);
+ });
+ }
+
+ @Subscribe
+ public void onConfigChanged(ConfigChanged event)
+ {
+ if (!event.getGroup().equals(CONFIG_GROUP))
{
- JOptionPane.showMessageDialog(panel,
- "Invalid Setup Name",
- "Names must not be empty.",
- JOptionPane.PLAIN_MESSAGE);
return;
}
- if (inventorySetups.containsKey(name))
- {
- String builder = "The setup " + name + " already exists. " +
- "Would you like to replace it with the current setup?";
- int confirm = JOptionPane.showConfirmDialog(panel,
- builder,
- "Warning",
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.PLAIN_MESSAGE);
+ updateConfig();
+ }
- if (confirm == JOptionPane.CANCEL_OPTION)
+ @Subscribe
+ public void onWidgetLoaded(WidgetLoaded event)
+ {
+ if (event.getGroupId() != WidgetID.BANK_GROUP_ID)
+ {
+ return;
+ }
+
+ doBankSearch();
+ }
+
+ public void doBankSearch()
+ {
+ final InventorySetup currentSelectedSetup = panel.getCurrentSelectedSetup();
+
+ if (currentSelectedSetup != null && currentSelectedSetup.isFilterBank())
+ {
+ client.setVarbit(Varbits.CURRENT_BANK_TAB, 0);
+ bankSearch.search(InputType.SEARCH, INV_SEARCH + currentSelectedSetup.getName(), true);
+ }
+ }
+
+ public void resetBankSearch()
+ {
+ bankSearch.reset(true);
+ }
+
+ public ArrayList getRunePouchData()
+ {
+ ArrayList runePouchData = new ArrayList<>();
+ for (int i = 0; i < RUNE_POUCH_RUNE_VARBITS.length; i++)
+ {
+ int runeId = client.getVar(RUNE_POUCH_RUNE_VARBITS[i]);
+ Runes rune = Runes.getRune(runeId);
+ int runeAmount = rune == null ? 0 : client.getVar(RUNE_POUCH_AMOUNT_VARBITS[i]);
+ String runeName = rune == null ? "" : rune.getName();
+ int runeItemId = rune == null ? -1 : rune.getItemId();
+
+ runePouchData.add(new InventorySetupItem(runeItemId, runeName, runeAmount));
+ }
+
+ return runePouchData;
+ }
+
+ @Subscribe
+ public void onScriptCallbackEvent(ScriptCallbackEvent event)
+ {
+ String eventName = event.getEventName();
+
+ int[] intStack = client.getIntStack();
+ String[] stringStack = client.getStringStack();
+ int intStackSize = client.getIntStackSize();
+ int stringStackSize = client.getStringStackSize();
+
+ if (eventName.equals("bankSearchFilter"))
+ {
+ String search = stringStack[stringStackSize - 1];
+
+ if (search.startsWith(INV_SEARCH))
+ {
+ final InventorySetup currentSetup = panel.getCurrentSelectedSetup();
+
+ if (currentSetup != null)
+ {
+ int itemId = intStack[intStackSize - 1];
+
+ if (setupContainsItem(currentSetup, itemId))
+ {
+ // return true
+ intStack[intStackSize - 2] = 1;
+ }
+ else
+ {
+ intStack[intStackSize - 2] = 0;
+ }
+ }
+ }
+ }
+ }
+
+ public void updateCurrentSetup(InventorySetup setup)
+ {
+ int confirm = JOptionPane.showConfirmDialog(panel,
+ "Are you sure you want update this inventory setup?",
+ "Warning", JOptionPane.OK_CANCEL_OPTION);
+
+ // cancel button was clicked
+ if (confirm != JOptionPane.YES_OPTION)
+ {
+ return;
+ }
+
+ // must be on client thread to get names
+ clientThread.invokeLater(() ->
+ {
+ ArrayList inv = getNormalizedContainer(InventoryID.INVENTORY);
+ ArrayList eqp = getNormalizedContainer(InventoryID.EQUIPMENT);
+
+ ArrayList runePouchData = null;
+ if (checkIfContainerContainsItem(ItemID.RUNE_POUCH, inv, false))
+ {
+ runePouchData = getRunePouchData();
+ }
+
+ setup.updateRunePouch(runePouchData);
+ setup.updateInventory(inv);
+ setup.updateEquipment(eqp);
+ updateJsonConfig();
+ panel.refreshCurrentSetup();
+ });
+ }
+
+ public void updateSlotFromContainer(final InventorySetupSlot slot)
+ {
+ if (client.getGameState() != GameState.LOGGED_IN)
+ {
+ JOptionPane.showMessageDialog(panel,
+ "You must be logged in to update from " + (slot.getSlotID().toString().toLowerCase() + "."),
+ "Cannot Update Item",
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ final ArrayList container = getContainerFromSlot(slot);
+
+ // must be invoked on client thread to get the name
+ clientThread.invokeLater(() ->
+ {
+ final ArrayList playerContainer = getNormalizedContainer(slot.getSlotID());
+ final InventorySetupItem newItem = playerContainer.get(slot.getIndexInSlot());
+
+ // update the rune pouch data
+ if (!updateIfRunePouch(slot, container.get(slot.getIndexInSlot()), newItem))
{
return;
}
- // delete the old setup, no need to ask for confirmation
- // because the user confirmed above
- removeInventorySetup(name, false);
- }
-
- clientThread.invoke(() ->
- {
- List inv = getNormalizedContainer(InventoryID.INVENTORY);
- List eqp = getNormalizedContainer(InventoryID.EQUIPMENT);
-
- final InventorySetup invSetup = new InventorySetup(inv, eqp);
- SwingUtilities.invokeLater(() ->
- {
- inventorySetups.put(name, invSetup);
- panel.addInventorySetupUnsorted(name);
- panel.setCurrentInventorySetup(name);
-
- updateConfig();
- });
+ container.set(slot.getIndexInSlot(), newItem);
+ updateJsonConfig();
+ panel.refreshCurrentSetup();
});
+
}
- public void removeInventorySetup(final String name, boolean askForConfirmation)
+ public void updateSlotFromSearch(final InventorySetupSlot slot)
{
- if (inventorySetups.containsKey(name))
+
+ if (client.getGameState() != GameState.LOGGED_IN)
{
- int confirm = JOptionPane.YES_OPTION;
-
- if (askForConfirmation)
- {
- confirm = JOptionPane.showConfirmDialog(panel,
- "Are you sure you want to remove this setup?",
- "Warning",
- JOptionPane.YES_NO_OPTION,
- JOptionPane.PLAIN_MESSAGE);
- }
-
- if (confirm == JOptionPane.YES_OPTION)
- {
- inventorySetups.remove(name);
- panel.removeInventorySetup(name);
- }
-
- updateConfig();
- }
- }
-
- public final InventorySetup getInventorySetup(final String name)
- {
- return inventorySetups.get(name);
- }
-
- @Provides
- InventorySetupConfig provideConfig(ConfigManager configManager)
- {
- return configManager.getConfig(InventorySetupConfig.class);
- }
-
- @Subscribe
- private void onConfigChanged(ConfigChanged event)
- {
- if (event.getGroup().equals(CONFIG_GROUP))
- {
- updateConfigOptions();
- // only allow highlighting if the config is enabled and the player is logged in
- highlightDifference = this.getHighlightDifferences && client.getGameState() == GameState.LOGGED_IN;
- final String setupName = panel.getSelectedInventorySetup();
- if (highlightDifference && !setupName.isEmpty())
- {
- panel.setCurrentInventorySetup(setupName);
- }
- }
- }
-
- private void updateConfig()
- {
- if (inventorySetups.isEmpty())
- {
- configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_KEY);
+ JOptionPane.showMessageDialog(panel,
+ "You must be logged in to search.",
+ "Cannot Search for Item",
+ JOptionPane.ERROR_MESSAGE);
return;
}
+ final ArrayList container = getContainerFromSlot(slot);
+
+ itemSearch
+ .tooltipText("Set slot to")
+ .onItemSelected((itemId) ->
+ {
+ clientThread.invokeLater(() ->
+ {
+ int finalId = itemManager.canonicalize(itemId);
+
+ /*
+ NOTE: the itemSearch shows items from skill guides which can be selected
+ And it does not show equipment variants for worn items that reduce weight.
+ Variation mapping would fix this issue for the inventory,
+ but then it would cause rings, potions, etc to be the same when it may not be desired
+ If a worn item is selected for the equipment, it will not be the correct itemID since
+ only the inventory variant and the skill guide variants show up in the search
+ If there is a way to figure out if and item is a skill guide item, then the inventory
+ issue can be solved. For equipment, you would also need a way to get the equipment variant
+ of a worn item that has weight reduction from the inventory counterpart
+
+ For now, it's possible that the user will pick a skill guide item, and it will cause highlighting
+ This only occurs if variation differences are turned on. Weight reducing equipment
+ will also be highlighted if selected for equipment if variation differences are turned on.
+ */
+
+ // if the item is stackable, ask for a quantity
+ if (itemManager.getItemDefinition(finalId).isStackable())
+ {
+ final int finalIdCopy = finalId;
+ searchInput = chatboxPanelManager.openTextInput("Enter amount")
+ .addCharValidator(arg -> arg >= 48 && arg <= 57) // only allow numbers (ASCII)
+ .onDone((input) ->
+ {
+ clientThread.invokeLater(() ->
+ {
+ String inputParsed = input;
+ if (inputParsed.length() > 10)
+ {
+ inputParsed = inputParsed.substring(0, 10);
+ }
+
+ // limit to max int value
+ long quantityLong = Long.parseLong(inputParsed);
+ int quantity = (int) Math.min(quantityLong, Integer.MAX_VALUE);
+ quantity = Math.max(quantity, 1);
+
+ final String itemName = itemManager.getItemDefinition(finalIdCopy).getName();
+ final InventorySetupItem newItem = new InventorySetupItem(finalIdCopy, itemName, quantity);
+
+ // update the rune pouch data
+ if (!updateIfRunePouch(slot, container.get(slot.getIndexInSlot()), newItem))
+ {
+ return;
+ }
+
+ container.set(slot.getIndexInSlot(), newItem);
+ updateJsonConfig();
+ panel.refreshCurrentSetup();
+
+ });
+ }).build();
+ }
+ else
+ {
+ final String itemName = itemManager.getItemDefinition(finalId).getName();
+ final InventorySetupItem newItem = new InventorySetupItem(finalId, itemName, 1);
+
+ // update the rune pouch data
+ if (!updateIfRunePouch(slot, container.get(slot.getIndexInSlot()), newItem))
+ {
+ return;
+ }
+
+ container.set(slot.getIndexInSlot(), newItem);
+ updateJsonConfig();
+ panel.refreshCurrentSetup();
+ }
+
+ });
+ })
+ .build();
+ }
+
+ public void removeInventorySetup(final InventorySetup setup)
+ {
+ int confirm = JOptionPane.showConfirmDialog(panel,
+ "Are you sure you want to permanently delete this inventory setup?",
+ "Warning", JOptionPane.OK_CANCEL_OPTION);
+
+ if (confirm != JOptionPane.YES_OPTION)
+ {
+ return;
+ }
+
+ inventorySetups.remove(setup);
+ panel.rebuild();
+ updateJsonConfig();
+ }
+
+ public void updateJsonConfig()
+ {
final Gson gson = new Gson();
final String json = gson.toJson(inventorySetups);
configManager.setConfiguration(CONFIG_GROUP, CONFIG_KEY, json);
}
- private void loadConfig()
+ @Subscribe
+ public void onSessionOpen(SessionOpen event)
{
- // serialize the internal data structure from the json in the configuration
- final String json = configManager.getConfiguration(CONFIG_GROUP, CONFIG_KEY);
- if (json == null || json.isEmpty())
+ final AccountSession session = sessionManager.getAccountSession();
+ if (session != null && session.getUsername() != null)
{
- inventorySetups.clear();
- }
- else
- {
- // TODO add last resort?, serialize exception just make empty map
- final Gson gson = new Gson();
- Type type = new TypeToken>()
+ // config will have changed to new account, load it up
+ clientThread.invokeLater(() ->
{
- }.getType();
- inventorySetups.clear();
- inventorySetups.putAll(gson.fromJson(json, type));
- }
+ loadConfig();
+ SwingUtilities.invokeLater(() ->
+ {
+ panel.rebuild();
+ });
- for (final String key : inventorySetups.keySet().stream().sorted(Comparator.comparing(String::toLowerCase)).collect(Collectors.toList()))
- {
- panel.addInventorySetup(key);
+ return true;
+ });
}
-
}
@Subscribe
- private void onItemContainerChanged(ItemContainerChanged event)
+ public void onSessionClose(SessionClose event)
{
-
- if (!highlightDifference || client.getGameState() != GameState.LOGGED_IN)
+ // config will have changed to local file
+ clientThread.invokeLater(() ->
{
- return;
- }
+ loadConfig();
+ SwingUtilities.invokeLater(() ->
+ {
+ panel.rebuild();
+ });
- // empty entry, no need to compare anything
- final String selectedInventorySetup = panel.getSelectedInventorySetup();
- if (selectedInventorySetup.isEmpty())
- {
- return;
- }
+ return true;
+ });
+ }
+
+ @Subscribe
+ public void onItemContainerChanged(ItemContainerChanged event)
+ {
// check to see that the container is the equipment or inventory
ItemContainer container = event.getItemContainer();
if (container == client.getItemContainer(InventoryID.INVENTORY))
{
- List normContainer = getNormalizedContainer(InventoryID.INVENTORY);
- final InventorySetup setup = inventorySetups.get(selectedInventorySetup);
- panel.highlightDifferences(normContainer, setup, InventoryID.INVENTORY);
+ panel.highlightInventory();
}
else if (container == client.getItemContainer(InventoryID.EQUIPMENT))
{
- List normContainer = getNormalizedContainer(InventoryID.EQUIPMENT);
- final InventorySetup setup = inventorySetups.get(selectedInventorySetup);
- panel.highlightDifferences(normContainer, setup, InventoryID.EQUIPMENT);
+ panel.highlightEquipment();
}
}
@Subscribe
- private void onGameStateChanged(GameStateChanged event)
+ public void onGameStateChanged(GameStateChanged event)
{
- switch (event.getGameState())
+ panel.highlightInventory();
+ panel.highlightEquipment();
+ }
+
+ public ArrayList getNormalizedContainer(final InventorySetupSlotID id)
+ {
+ switch (id)
{
- // set the highlighting off if login screen shows up
- case LOGIN_SCREEN:
- highlightDifference = false;
- break;
-
- // set highlighting
- case LOGGED_IN:
- highlightDifference = this.getHighlightDifferences;
- break;
-
+ case INVENTORY:
+ return getNormalizedContainer(InventoryID.INVENTORY);
+ case EQUIPMENT:
+ return getNormalizedContainer(InventoryID.EQUIPMENT);
default:
- return;
- }
-
- if (panel == null)
- {
- return;
- }
-
- final String setupName = panel.getSelectedInventorySetup();
- if (!setupName.isEmpty())
- {
- panel.setCurrentInventorySetup(setupName);
+ assert false : "Wrong slot ID!";
+ return null;
}
}
- public List getNormalizedContainer(final InventoryID id)
+ public ArrayList getNormalizedContainer(final InventoryID id)
{
assert id == InventoryID.INVENTORY || id == InventoryID.EQUIPMENT : "invalid inventory ID";
final ItemContainer container = client.getItemContainer(id);
- List newContainer = new ArrayList<>();
+ ArrayList newContainer = new ArrayList<>();
Item[] items = null;
if (container != null)
@@ -399,12 +592,16 @@ public class InventorySetupPlugin extends Plugin
{
if (items == null || i >= items.length)
{
+ // add a "dummy" item to fill the normalized container to the right size
+ // this will be useful to compare when no item is in a slot
newContainer.add(new InventorySetupItem(-1, "", 0));
}
else
{
final Item item = items[i];
String itemName = "";
+
+ // only the client thread can retrieve the name. Therefore, do not use names to compare!
if (client.isClientThread())
{
itemName = itemManager.getItemDefinition(item.getId()).getName();
@@ -416,54 +613,232 @@ public class InventorySetupPlugin extends Plugin
return newContainer;
}
- public boolean getHighlightDifference()
+ public void exportSetup(final InventorySetup setup)
{
- return highlightDifference;
+ final Gson gson = new Gson();
+ final String json = gson.toJson(setup);
+ final StringSelection contents = new StringSelection(json);
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, null);
+
+ JOptionPane.showMessageDialog(panel,
+ "Setup data was copied to clipboard.",
+ "Export Setup Succeeded",
+ JOptionPane.PLAIN_MESSAGE);
}
- @Override
- public void shutDown()
+ public void importSetup()
{
- overlayManager.remove(overlay);
- clientToolbar.removeNavigation(navButton);
- }
+ try
+ {
+ final String setup = JOptionPane.showInputDialog(panel,
+ "Enter setup data",
+ "Import New Setup",
+ JOptionPane.PLAIN_MESSAGE);
- final int[] getCurrentInventorySetupIds()
- {
- InventorySetup setup = inventorySetups.get(panel.getSelectedInventorySetup());
- if (setup == null)
- {
- return null;
- }
- ArrayList items = new ArrayList<>();
- items.addAll(setup.getEquipment());
- items.addAll(setup.getInventory());
- ArrayList itemIds = new ArrayList<>();
- for (InventorySetupItem item : items)
- {
- int id = item.getId();
- ItemDefinition itemComposition = itemManager.getItemDefinition(id);
- if (id > 0)
+ // cancel button was clicked
+ if (setup == null)
{
- itemIds.add(ItemVariationMapping.map(id));
- itemIds.add(itemComposition.getPlaceholderId());
+ return;
}
+ final Gson gson = new Gson();
+ Type type = new TypeToken()
+ {
+
+ }.getType();
+
+ final InventorySetup newSetup = gson.fromJson(setup, type);
+ if (newSetup.getRune_pouch() == null && checkIfContainerContainsItem(ItemID.RUNE_POUCH, newSetup.getInventory(), false))
+ {
+ newSetup.updateRunePouch(getRunePouchData());
+ }
+ addInventorySetupClientThread(newSetup);
+ }
+ catch (Exception e)
+ {
+ JOptionPane.showMessageDialog(panel,
+ "Invalid setup data.",
+ "Import Setup Failed",
+ JOptionPane.ERROR_MESSAGE);
}
- return itemIds.stream()
- .mapToInt(i -> i)
- .filter(Objects::nonNull)
- .filter(id -> id != -1)
- .toArray();
}
- private void updateConfigOptions()
+ public boolean isHighlightingAllowed()
{
- this.getHighlightDifferences = config.getHighlightDifferences();
- this.getHighlightColor = config.getHighlightColor();
- this.getStackDifference = config.getHighlightDifferences();
- this.getVariationDifference = config.getVariationDifference();
- this.getBankHighlight = config.getBankHighlight();
- this.getBankHighlightColor = config.getBankHighlightColor();
+ return client.getGameState() == GameState.LOGGED_IN;
}
-}
\ No newline at end of file
+
+ private ArrayList getContainerFromSlot(final InventorySetupSlot slot)
+ {
+ ArrayList container = slot.getParentSetup().getInventory();
+
+ if (slot.getSlotID() == InventorySetupSlotID.EQUIPMENT)
+ {
+ container = slot.getParentSetup().getEquipment();
+ }
+
+ assert slot.getParentSetup() == panel.getCurrentSelectedSetup() : "Setup Mismatch";
+ assert slot.getIndexInSlot() < container.size() : "Index is greater than container size";
+
+ return container;
+ }
+
+ private void loadConfig()
+ {
+ // serialize the internal data structure from the json in the configuration
+ final String json = configManager.getConfiguration(CONFIG_GROUP, CONFIG_KEY);
+ if (Strings.isNullOrEmpty(json))
+ {
+ inventorySetups = new ArrayList<>();
+ }
+ else
+ {
+ try
+ {
+ final Gson gson = new Gson();
+ Type type = new TypeToken>()
+ {
+
+ }.getType();
+ inventorySetups = gson.fromJson(json, type);
+ for (final InventorySetup setup : inventorySetups)
+ {
+ if (setup.getRune_pouch() == null && checkIfContainerContainsItem(ItemID.RUNE_POUCH, setup.getInventory(), false))
+ {
+ setup.updateRunePouch(getRunePouchData());
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ inventorySetups = new ArrayList<>();
+ }
+ }
+ }
+
+ private void addInventorySetupClientThread(final InventorySetup newSetup)
+ {
+ SwingUtilities.invokeLater(() ->
+ {
+ inventorySetups.add(newSetup);
+ panel.rebuild();
+
+ updateJsonConfig();
+ });
+ }
+
+ private boolean setupContainsItem(final InventorySetup setup, int itemID)
+ {
+
+ // So place holders will show up in the bank.
+ itemID = itemManager.canonicalize(itemID);
+
+ // don't variation map unless it's been selected
+ if (!setup.isVariationDifference())
+ {
+ itemID = ItemVariationMapping.map(itemID);
+ }
+
+ // check the rune pouch to see if it has the item (runes in this case)
+ if (setup.getRune_pouch() != null)
+ {
+ if (checkIfContainerContainsItem(itemID, setup.getRune_pouch(), false))
+ {
+ return true;
+ }
+ }
+
+ return checkIfContainerContainsItem(itemID, setup.getInventory(), setup.isVariationDifference()) ||
+ checkIfContainerContainsItem(itemID, setup.getEquipment(), setup.isVariationDifference());
+ }
+
+ private boolean checkIfContainerContainsItem(int itemID, final ArrayList container, boolean isVariationDifference)
+ {
+ for (final InventorySetupItem item : container)
+ {
+ if (itemID == getCorrectID(isVariationDifference, item.getId()))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private int getCorrectID(boolean variationDifference, int itemId)
+ {
+
+ // if variation difference isn't selected, get the canonical ID
+ if (!variationDifference)
+ {
+ return ItemVariationMapping.map(itemManager.canonicalize(itemId));
+ }
+
+ int idToCompare = itemId;
+
+ // if it is selected, make sure we aren't showing note form
+ ItemDefinition comp = itemManager.getItemDefinition(itemId);
+ if (comp.getNote() != -1)
+ {
+ idToCompare = comp.getLinkedNoteId();
+ }
+
+ return idToCompare;
+
+ }
+
+ private boolean updateIfRunePouch(final InventorySetupSlot slot, final InventorySetupItem oldItem, final InventorySetupItem newItem)
+ {
+
+ if (ItemVariationMapping.map(newItem.getId()) == ItemID.RUNE_POUCH)
+ {
+
+ if (slot.getSlotID() != InventorySetupSlotID.INVENTORY)
+ {
+
+ SwingUtilities.invokeLater(() ->
+ {
+ JOptionPane.showMessageDialog(panel,
+ "You can't have a Rune Pouch there.",
+ "Invalid Item",
+ JOptionPane.ERROR_MESSAGE);
+ });
+
+ return false;
+ }
+
+ // only display this message if we aren't replacing a rune pouch with a new rune pouch
+ if (slot.getParentSetup().getRune_pouch() != null && ItemVariationMapping.map(oldItem.getId()) != ItemID.RUNE_POUCH)
+ {
+ SwingUtilities.invokeLater(() ->
+ {
+ JOptionPane.showMessageDialog(panel,
+ "You can't have two Rune Pouches.",
+ "Invalid Item",
+ JOptionPane.ERROR_MESSAGE);
+ });
+ return false;
+ }
+
+ slot.getParentSetup().updateRunePouch(getRunePouchData());
+ }
+ else if (ItemVariationMapping.map(oldItem.getId()) == ItemID.RUNE_POUCH)
+ {
+ // if the old item is a rune pouch, need to update it to null
+ slot.getParentSetup().updateRunePouch(null);
+ }
+
+ return true;
+ }
+
+ private void updateConfig()
+ {
+ this.bankFilter = config.bankFilter();
+ this.highlightStackDifference = config.highlightStackDifference();
+ this.highlightVariationDifference = config.highlightVariationDifference();
+ this.highlightUnorderedDifference = config.highlightUnorderedDifference();
+ this.highlightDifference = config.highlightDifference();
+ this.highlightColor = config.highlightColor();
+ }
+
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupSlotID.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupSlotID.java
new file mode 100644
index 0000000000..5076c15700
--- /dev/null
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/InventorySetupSlotID.java
@@ -0,0 +1,21 @@
+package net.runelite.client.plugins.inventorysetups;
+
+public enum InventorySetupSlotID
+{
+ INVENTORY(0),
+ EQUIPMENT(1),
+ RUNE_POUCH(2),
+ SPELL_BOOK(3);
+
+ private final int id;
+
+ InventorySetupSlotID(int id)
+ {
+ this.id = id;
+ }
+
+ public int getId()
+ {
+ return id;
+ }
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupContainerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupContainerPanel.java
index e2bcdc3001..7e378a3c9d 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupContainerPanel.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupContainerPanel.java
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
+ * Copyright (c) 2019, dillydill123
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,34 +24,37 @@
*/
package net.runelite.client.plugins.inventorysetups.ui;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.util.List;
-import javax.inject.Singleton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
+import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
+import net.runelite.client.util.AsyncBufferedImage;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.ItemVariationMapping;
+import net.runelite.client.plugins.inventorysetups.InventorySetup;
import net.runelite.client.plugins.inventorysetups.InventorySetupItem;
-import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
import net.runelite.client.ui.ColorScheme;
-import net.runelite.client.util.AsyncBufferedImage;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import java.awt.BorderLayout;
+import java.util.ArrayList;
-@Singleton
-abstract class InventorySetupContainerPanel extends JPanel
+public abstract class InventorySetupContainerPanel extends JPanel
{
- private final ItemManager itemManager;
- private final InventorySetupPlugin plugin;
+ protected final InventorySetupPlugin plugin;
+ protected ItemManager itemManager;
+ protected boolean isHighlighted;
InventorySetupContainerPanel(final ItemManager itemManager, final InventorySetupPlugin plugin, String captionText)
{
this.itemManager = itemManager;
this.plugin = plugin;
+ this.isHighlighted = false;
JPanel containerPanel = new JPanel();
final JPanel containerSlotsPanel = new JPanel();
+ // sets up the custom container panel
setupContainerPanel(containerSlotsPanel);
// caption
@@ -71,11 +73,76 @@ abstract class InventorySetupContainerPanel extends JPanel
add(containerPanel);
}
- void setContainerSlot(int index,
- final InventorySetupSlot containerSlot,
- final List items)
+ protected void addMouseListenerToSlot(final InventorySetupSlot slot)
{
- if (index >= items.size() || items.get(index).getId() == -1)
+
+ JPopupMenu popupMenu = new JPopupMenu();
+
+ String updateContainerFrom = "";
+ switch (slot.getSlotID())
+ {
+ case INVENTORY:
+ updateContainerFrom = "Inventory";
+ break;
+ case EQUIPMENT:
+ updateContainerFrom = "Equipment";
+ break;
+ case RUNE_POUCH:
+ updateContainerFrom = "Rune Pouch";
+ break;
+ case SPELL_BOOK:
+ updateContainerFrom = "Spell Book";
+ break;
+ default:
+ assert false : "Wrong slot ID!";
+ break;
+ }
+ JMenuItem updateFromContainer = new JMenuItem("Update Slot from " + updateContainerFrom);
+ JMenuItem updateFromSearch = new JMenuItem("Update Slot from Search");
+ popupMenu.add(updateFromContainer);
+ popupMenu.add(updateFromSearch);
+
+ updateFromContainer.addActionListener(e ->
+ {
+ plugin.updateSlotFromContainer(slot);
+ });
+
+ updateFromSearch.addActionListener(e ->
+ {
+ plugin.updateSlotFromSearch(slot);
+ });
+
+ // both the panel and image label need adapters
+ // because the image will cover the entire panel
+ slot.setComponentPopupMenu(popupMenu);
+ slot.getImageLabel().setComponentPopupMenu(popupMenu);
+
+ }
+
+ protected void setContainerSlot(int index, final InventorySetupSlot containerSlot, final InventorySetup setup)
+ {
+ ArrayList items = null;
+ switch (containerSlot.getSlotID())
+ {
+ case INVENTORY:
+ items = setup.getInventory();
+ break;
+ case EQUIPMENT:
+ items = setup.getEquipment();
+ break;
+ case RUNE_POUCH:
+ items = setup.getRune_pouch();
+ break;
+ default:
+ assert false : "Wrong slot ID!";
+ break;
+ }
+
+ assert index < items.size() && index > 0 : "Index Off Array";
+
+ containerSlot.setParentSetup(setup);
+
+ if (items.get(index).getId() == -1)
{
containerSlot.setImageLabel(null, null);
return;
@@ -93,33 +160,32 @@ abstract class InventorySetupContainerPanel extends JPanel
containerSlot.setImageLabel(toolTip, itemImg);
}
- void highlightDifferentSlotColor(InventorySetupItem savedItem,
- InventorySetupItem currItem,
- final InventorySetupSlot containerSlot)
+ protected void highlightDifferentSlotColor(final InventorySetup setup, InventorySetupItem savedItem, InventorySetupItem currItem, final InventorySetupSlot containerSlot)
{
// important note: do not use item names for comparisons
// they are all empty to avoid clientThread usage when highlighting
- final Color highlightColor = plugin.getGetHighlightColor();
-
- if (plugin.isGetStackDifference() && currItem.getQuantity() != savedItem.getQuantity())
+ // first check if stack differences are enabled and compare quantities
+ if (setup.isStackDifference() && currItem.getQuantity() != savedItem.getQuantity())
{
- containerSlot.setBackground(highlightColor);
+ containerSlot.setBackground(setup.getHighlightColor());
return;
}
+ // obtain the correct item ids using the variation difference if applicable
int currId = currItem.getId();
int checkId = savedItem.getId();
- if (!plugin.isGetVariationDifference())
+ if (!setup.isVariationDifference())
{
currId = ItemVariationMapping.map(currId);
checkId = ItemVariationMapping.map(checkId);
}
+ // if the ids don't match, highlight the container slot
if (currId != checkId)
{
- containerSlot.setBackground(highlightColor);
+ containerSlot.setBackground(setup.getHighlightColor());
return;
}
@@ -127,5 +193,11 @@ abstract class InventorySetupContainerPanel extends JPanel
containerSlot.setBackground(ColorScheme.DARKER_GRAY_COLOR);
}
- protected abstract void setupContainerPanel(final JPanel containerSlotsPanel);
-}
\ No newline at end of file
+ abstract public void setupContainerPanel(final JPanel containerSlotsPanel);
+
+ abstract public void highlightSlotDifferences(final ArrayList currContainer, final InventorySetup inventorySetup);
+
+ abstract public void setSlots(final InventorySetup setup);
+
+ abstract public void resetSlotColors();
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupEquipmentPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupEquipmentPanel.java
index a2244932cd..62a046a409 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupEquipmentPanel.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupEquipmentPanel.java
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
+ * Copyright (c) 2019, dillydill123
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,23 +24,21 @@
*/
package net.runelite.client.plugins.inventorysetups.ui;
-import java.awt.GridLayout;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.inject.Singleton;
-import javax.swing.JPanel;
+import net.runelite.client.plugins.inventorysetups.InventorySetupSlotID;
+import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
import net.runelite.api.EquipmentInventorySlot;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.inventorysetups.InventorySetup;
import net.runelite.client.plugins.inventorysetups.InventorySetupItem;
-import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
import net.runelite.client.ui.ColorScheme;
+import javax.swing.JPanel;
+import java.awt.GridLayout;
+import java.util.ArrayList;
+import java.util.HashMap;
-@Singleton
public class InventorySetupEquipmentPanel extends InventorySetupContainerPanel
{
- private Map equipmentSlots;
+ private HashMap equipmentSlots;
InventorySetupEquipmentPanel(final ItemManager itemManager, final InventorySetupPlugin plugin)
{
@@ -54,65 +51,76 @@ public class InventorySetupEquipmentPanel extends InventorySetupContainerPanel
this.equipmentSlots = new HashMap<>();
for (EquipmentInventorySlot slot : EquipmentInventorySlot.values())
{
- equipmentSlots.put(slot, new InventorySetupSlot(ColorScheme.DARKER_GRAY_COLOR));
+ final InventorySetupSlot setupSlot = new InventorySetupSlot(ColorScheme.DARKER_GRAY_COLOR, InventorySetupSlotID.EQUIPMENT, slot.getSlotIdx());
+ super.addMouseListenerToSlot(setupSlot);
+ equipmentSlots.put(slot, setupSlot);
}
final GridLayout gridLayout = new GridLayout(5, 3, 1, 1);
containerSlotsPanel.setLayout(gridLayout);
// add the grid layouts, including invisible ones
- containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR));
+ containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR, InventorySetupSlotID.EQUIPMENT, -1));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.HEAD));
- containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR));
+ containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR, InventorySetupSlotID.EQUIPMENT, -1));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.CAPE));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.AMULET));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.AMMO));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.WEAPON));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.BODY));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.SHIELD));
- containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR));
+ containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR, InventorySetupSlotID.EQUIPMENT, -1));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.LEGS));
- containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR));
+ containerSlotsPanel.add(new InventorySetupSlot(ColorScheme.DARK_GRAY_COLOR, InventorySetupSlotID.EQUIPMENT, -1));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.GLOVES));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.BOOTS));
containerSlotsPanel.add(equipmentSlots.get(EquipmentInventorySlot.RING));
}
- void setEquipmentSetupSlots(final InventorySetup setup)
+ @Override
+ public void highlightSlotDifferences(final ArrayList currEquipment, final InventorySetup inventorySetup)
{
- final List equipment = setup.getEquipment();
+ final ArrayList equipToCheck = inventorySetup.getEquipment();
+
+ assert currEquipment.size() == equipToCheck.size() : "size mismatch";
+
+ isHighlighted = true;
+ for (final EquipmentInventorySlot slot : EquipmentInventorySlot.values())
+ {
+ int slotIdx = slot.getSlotIdx();
+ super.highlightDifferentSlotColor(inventorySetup, equipToCheck.get(slotIdx), currEquipment.get(slotIdx), equipmentSlots.get(slot));
+ }
+ }
+
+ @Override
+ public void setSlots(final InventorySetup setup)
+ {
for (final EquipmentInventorySlot slot : EquipmentInventorySlot.values())
{
int i = slot.getSlotIdx();
- super.setContainerSlot(i, equipmentSlots.get(slot), equipment);
+ super.setContainerSlot(i, equipmentSlots.get(slot), setup);
}
validate();
repaint();
-
}
- void highlightDifferences(final List currEquipment, final InventorySetup inventorySetup)
+ @Override
+ public void resetSlotColors()
{
- final List equipToCheck = inventorySetup.getEquipment();
-
- assert currEquipment.size() == equipToCheck.size() : "size mismatch";
-
- for (final EquipmentInventorySlot slot : EquipmentInventorySlot.values())
+ // Don't waste time resetting if we were never highlighted to begin with
+ if (!isHighlighted)
{
-
- int slotIdx = slot.getSlotIdx();
- super.highlightDifferentSlotColor(equipToCheck.get(slotIdx), currEquipment.get(slotIdx), equipmentSlots.get(slot));
+ return;
}
- }
- void resetEquipmentSlotsColor()
- {
for (final EquipmentInventorySlot slot : EquipmentInventorySlot.values())
{
equipmentSlots.get(slot).setBackground(ColorScheme.DARKER_GRAY_COLOR);
}
+
+ isHighlighted = false;
}
-}
\ No newline at end of file
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupInventoryPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupInventoryPanel.java
index 85121c3920..bec4f59878 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupInventoryPanel.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupInventoryPanel.java
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
+ * Copyright (c) 2019, dillydill123
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,38 +24,42 @@
*/
package net.runelite.client.plugins.inventorysetups.ui;
-import java.awt.GridLayout;
-import java.util.ArrayList;
-import java.util.List;
-import javax.inject.Singleton;
-import javax.swing.JPanel;
+import net.runelite.client.plugins.inventorysetups.InventorySetupSlotID;
+import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
+import net.runelite.api.ItemID;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.inventorysetups.InventorySetup;
import net.runelite.client.plugins.inventorysetups.InventorySetupItem;
-import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
+import net.runelite.client.game.ItemVariationMapping;
import net.runelite.client.ui.ColorScheme;
+import javax.swing.JPanel;
+import java.awt.GridLayout;
+import java.util.ArrayList;
+import java.util.HashMap;
-@Singleton
public class InventorySetupInventoryPanel extends InventorySetupContainerPanel
{
+
private static final int ITEMS_PER_ROW = 4;
private static final int NUM_INVENTORY_ITEMS = 28;
- private List inventorySlots;
+ private ArrayList inventorySlots;
+ private InventorySetupRunePouchPanel rpPanel;
- InventorySetupInventoryPanel(final ItemManager itemManager, final InventorySetupPlugin plugin)
+ InventorySetupInventoryPanel(final ItemManager itemManager, final InventorySetupPlugin plugin, final InventorySetupRunePouchPanel rpPanel)
{
super(itemManager, plugin, "Inventory");
+ this.rpPanel = rpPanel;
}
-
@Override
public void setupContainerPanel(final JPanel containerSlotsPanel)
{
this.inventorySlots = new ArrayList<>();
for (int i = 0; i < NUM_INVENTORY_ITEMS; i++)
{
- inventorySlots.add(new InventorySetupSlot(ColorScheme.DARKER_GRAY_COLOR));
+ inventorySlots.add(new InventorySetupSlot(ColorScheme.DARKER_GRAY_COLOR, InventorySetupSlotID.INVENTORY, i));
}
int numRows = (NUM_INVENTORY_ITEMS + ITEMS_PER_ROW - 1) / ITEMS_PER_ROW;
@@ -64,41 +67,157 @@ public class InventorySetupInventoryPanel extends InventorySetupContainerPanel
for (int i = 0; i < NUM_INVENTORY_ITEMS; i++)
{
containerSlotsPanel.add(inventorySlots.get(i));
+ super.addMouseListenerToSlot(inventorySlots.get(i));
}
}
- void setInventorySetupSlots(final InventorySetup setup)
+ @Override
+ public void highlightSlotDifferences(final ArrayList currInventory, final InventorySetup inventorySetup)
{
- List inventory = setup.getInventory();
+ final ArrayList inventoryToCheck = inventorySetup.getInventory();
+ assert currInventory.size() == inventoryToCheck.size() : "size mismatch";
+
+ isHighlighted = true;
+
+ if (inventorySetup.isUnorderedHighlight())
+ {
+ doUnorderedHighlighting(currInventory, inventorySetup);
+ return;
+ }
+
+ boolean currInvHasRunePouch = false;
for (int i = 0; i < NUM_INVENTORY_ITEMS; i++)
{
- super.setContainerSlot(i, inventorySlots.get(i), inventory);
+ InventorySetupItem currInvItem = currInventory.get(i);
+ if (!currInvHasRunePouch && ItemVariationMapping.map(currInvItem.getId()) == ItemID.RUNE_POUCH)
+ {
+ currInvHasRunePouch = true;
+ }
+ super.highlightDifferentSlotColor(inventorySetup, inventoryToCheck.get(i), currInventory.get(i), inventorySlots.get(i));
+ }
+
+ handleRunePouchHighlighting(inventorySetup, currInvHasRunePouch);
+
+ }
+
+ @Override
+ public void setSlots(final InventorySetup setup)
+ {
+ for (int i = 0; i < NUM_INVENTORY_ITEMS; i++)
+ {
+ super.setContainerSlot(i, inventorySlots.get(i), setup);
}
validate();
repaint();
-
}
- void highlightDifferentSlots(final List currInventory, final InventorySetup inventorySetup)
+ @Override
+ public void resetSlotColors()
{
-
- final List inventoryToCheck = inventorySetup.getInventory();
-
- assert currInventory.size() == inventoryToCheck.size() : "size mismatch";
-
- for (int i = 0; i < NUM_INVENTORY_ITEMS; i++)
+ // Don't waste time resetting if we were never highlighted to begin with
+ if (!isHighlighted)
{
- super.highlightDifferentSlotColor(inventoryToCheck.get(i), currInventory.get(i), inventorySlots.get(i));
+ return;
}
- }
- void resetInventorySlotsColor()
- {
for (InventorySetupSlot inventorySlot : inventorySlots)
{
inventorySlot.setBackground(ColorScheme.DARKER_GRAY_COLOR);
}
+
+ rpPanel.resetSlotColors();
+
+ isHighlighted = false;
}
-}
\ No newline at end of file
+
+ private void doUnorderedHighlighting(final ArrayList currInventory, final InventorySetup inventorySetup)
+ {
+ HashMap, Integer> currInvMap = new HashMap<>();
+
+ boolean currInvHasRunePouch = false;
+ for (final InventorySetupItem item : currInventory)
+ {
+ // Use variation mapping if necessary and set the quantity to 1 if ignoring stacks
+ int itemId = inventorySetup.isVariationDifference() ? item.getId() : ItemVariationMapping.map(item.getId());
+ int quantity = inventorySetup.isStackDifference() ? item.getQuantity() : 1;
+
+ if (ItemVariationMapping.map(item.getId()) == ItemID.RUNE_POUCH)
+ {
+ currInvHasRunePouch = true;
+ }
+
+ ImmutablePair key = new ImmutablePair<>(itemId, quantity);
+ int count = currInvMap.get(key) == null ? 0 : currInvMap.get(key);
+ currInvMap.put(key, count + 1);
+ }
+
+ final ArrayList setupInv = inventorySetup.getInventory();
+ for (int i = 0; i < setupInv.size(); i++)
+ {
+ final InventorySetupItem item = setupInv.get(i);
+
+ /*
+ don't count empty spaces. We only want to show items that are missing, not "extra items"
+ that would be indicated by highlighting empty slots.
+ */
+ if (item.getId() == -1)
+ {
+ inventorySlots.get(i).setBackground(ColorScheme.DARKER_GRAY_COLOR);
+ continue;
+ }
+
+ // Use variation mapping if necessary and set the quantity to 1 if ignoring stacks
+ int itemId = inventorySetup.isVariationDifference() ? item.getId() : ItemVariationMapping.map(item.getId());
+ int quantity = inventorySetup.isStackDifference() ? item.getQuantity() : 1;
+
+ ImmutablePair key = new ImmutablePair<>(itemId, quantity);
+ Integer currentCount = currInvMap.get(key);
+
+ // current inventory doesn't have this item, highlight
+ if (currentCount == null)
+ {
+ inventorySlots.get(i).setBackground(inventorySetup.getHighlightColor());
+ continue;
+ }
+
+ if (currentCount == 1)
+ {
+ currInvMap.remove(key);
+ }
+ else
+ {
+ currInvMap.put(key, currentCount - 1);
+ }
+
+ inventorySlots.get(i).setBackground(ColorScheme.DARKER_GRAY_COLOR);
+
+ }
+
+ handleRunePouchHighlighting(inventorySetup, currInvHasRunePouch);
+
+ }
+
+ private void handleRunePouchHighlighting(final InventorySetup inventorySetup, boolean currInvHasRunePouch)
+ {
+ if (inventorySetup.getRune_pouch() != null)
+ {
+
+ // attempt to highlight if rune pouch is available
+ if (currInvHasRunePouch)
+ {
+ ArrayList runePouchToCheck = plugin.getRunePouchData();
+ rpPanel.highlightSlotDifferences(runePouchToCheck, inventorySetup);
+ }
+ else // if the current inventory doesn't have a rune pouch but the setup does, highlight the RP pouch
+ {
+ rpPanel.highlightAllSlots(inventorySetup);
+ }
+ }
+ else
+ {
+ rpPanel.resetSlotColors();
+ }
+ }
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPanel.java
new file mode 100644
index 0000000000..f629404154
--- /dev/null
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPanel.java
@@ -0,0 +1,625 @@
+/*
+ * Copyright (c) 2019, dillydill123
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.runelite.client.plugins.inventorysetups.ui;
+
+import net.runelite.client.plugins.inventorysetups.InventorySetup;
+import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
+import net.runelite.client.ui.ColorScheme;
+import net.runelite.client.ui.FontManager;
+import net.runelite.client.ui.components.FlatTextField;
+import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker;
+import net.runelite.client.util.ImageUtil;
+import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.MatteBorder;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.image.BufferedImage;
+
+public class InventorySetupPanel extends JPanel
+{
+
+ private static final Border NAME_BOTTOM_BORDER = new CompoundBorder(
+ BorderFactory.createMatteBorder(0, 0, 1, 0, ColorScheme.DARK_GRAY_COLOR),
+ BorderFactory.createLineBorder(ColorScheme.DARKER_GRAY_COLOR));
+
+ private static final int H_GAP_BTN = 4;
+
+ private static final ImageIcon BANK_FILTER_ICON;
+ private static final ImageIcon BANK_FILTER_HOVER_ICON;
+ private static final ImageIcon NO_BANK_FILTER_ICON;
+ private static final ImageIcon NO_BANK_FILTER_HOVER_ICON;
+
+ private static final ImageIcon HIGHLIGHT_COLOR_ICON;
+ private static final ImageIcon HIGHLIGHT_COLOR_HOVER_ICON;
+ private static final ImageIcon NO_HIGHLIGHT_COLOR_ICON;
+ private static final ImageIcon NO_HIGHLIGHT_COLOR_HOVER_ICON;
+
+ private static final ImageIcon TOGGLE_HIGHLIGHT_ICON;
+ private static final ImageIcon TOGGLE_HIGHLIGHT_HOVER_ICON;
+ private static final ImageIcon NO_TOGGLE_HIGHLIGHT_ICON;
+ private static final ImageIcon NO_TOGGLE_HIGHLIGHT_HOVER_ICON;
+
+ private static final ImageIcon UNORDERED_HIGHLIGHT_ICON;
+ private static final ImageIcon UNORDERED_HIGHLIGHT_HOVER_ICON;
+ private static final ImageIcon NO_UNORDERED_HIGHLIGHT_ICON;
+ private static final ImageIcon NO_UNORDERED_HIGHLIGHT_HOVER_ICON;
+
+ private static final ImageIcon STACK_DIFFERENCE_ICON;
+ private static final ImageIcon STACK_DIFFERENCE_HOVER_ICON;
+ private static final ImageIcon NO_STACK_DIFFERENCE_ICON;
+ private static final ImageIcon NO_STACK_DIFFERENCE_HOVER_ICON;
+
+ private static final ImageIcon VARIATION_DIFFERENCE_ICON;
+ private static final ImageIcon VARIATION_DIFFERENCE_HOVER_ICON;
+ private static final ImageIcon NO_VARIATION_DIFFERENCE_ICON;
+ private static final ImageIcon NO_VARIATION_DIFFERENCE_HOVER_ICON;
+
+ private static final ImageIcon VIEW_SETUP_ICON;
+ private static final ImageIcon VIEW_SETUP_HOVER_ICON;
+
+ private static final ImageIcon DELETE_ICON;
+ private static final ImageIcon DELETE_HOVER_ICON;
+
+ private static final ImageIcon EXPORT_ICON;
+ private static final ImageIcon EXPORT_HOVER_ICON;
+
+ static
+ {
+ final BufferedImage bankFilterImg = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "filter_icon.png");
+ final BufferedImage bankFilterHover = ImageUtil.luminanceOffset(bankFilterImg, -150);
+ BANK_FILTER_ICON = new ImageIcon(bankFilterImg);
+ BANK_FILTER_HOVER_ICON = new ImageIcon(bankFilterHover);
+
+ NO_BANK_FILTER_ICON = new ImageIcon(bankFilterHover);
+ NO_BANK_FILTER_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(bankFilterHover, -100));
+
+ final BufferedImage stackImg = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "stack_icon.png");
+ final BufferedImage stackHover = ImageUtil.luminanceOffset(stackImg, -150);
+ STACK_DIFFERENCE_ICON = new ImageIcon(stackImg);
+ STACK_DIFFERENCE_HOVER_ICON = new ImageIcon(stackHover);
+
+ NO_STACK_DIFFERENCE_ICON = new ImageIcon(stackHover);
+ NO_STACK_DIFFERENCE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(stackHover, -100));
+
+ final BufferedImage variationImg = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "variation_icon.png");
+ final BufferedImage variationHover = ImageUtil.luminanceOffset(variationImg, -150);
+ VARIATION_DIFFERENCE_ICON = new ImageIcon(variationImg);
+ VARIATION_DIFFERENCE_HOVER_ICON = new ImageIcon(variationHover);
+
+ NO_VARIATION_DIFFERENCE_ICON = new ImageIcon(variationHover);
+ NO_VARIATION_DIFFERENCE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(variationHover, -100));
+
+ final BufferedImage unorderedHighlightImg = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "unordered_highlight_icon.png");
+ final BufferedImage unorderedHighlightHover = ImageUtil.luminanceOffset(unorderedHighlightImg, -150);
+ UNORDERED_HIGHLIGHT_ICON = new ImageIcon(unorderedHighlightImg);
+ UNORDERED_HIGHLIGHT_HOVER_ICON = new ImageIcon(unorderedHighlightHover);
+
+ NO_UNORDERED_HIGHLIGHT_ICON = new ImageIcon(unorderedHighlightHover);
+ NO_UNORDERED_HIGHLIGHT_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(unorderedHighlightHover, -100));
+
+ final BufferedImage highlightToggleImg = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "highlight_icon.png");
+ final BufferedImage highlightToggleHover = ImageUtil.luminanceOffset(highlightToggleImg, -150);
+ TOGGLE_HIGHLIGHT_ICON = new ImageIcon(highlightToggleImg);
+ TOGGLE_HIGHLIGHT_HOVER_ICON = new ImageIcon(highlightToggleHover);
+
+ NO_TOGGLE_HIGHLIGHT_ICON = new ImageIcon(highlightToggleHover);
+ NO_TOGGLE_HIGHLIGHT_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(highlightToggleHover, -100));
+
+ final BufferedImage highlightImg = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "highlight_color_icon.png");
+ final BufferedImage highlightHover = ImageUtil.luminanceOffset(highlightImg, -150);
+ HIGHLIGHT_COLOR_ICON = new ImageIcon(highlightImg);
+ HIGHLIGHT_COLOR_HOVER_ICON = new ImageIcon(highlightHover);
+
+ NO_HIGHLIGHT_COLOR_ICON = new ImageIcon(highlightHover);
+ NO_HIGHLIGHT_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(highlightHover, -100));
+
+ final BufferedImage viewImg = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "visible_icon.png");
+ final BufferedImage viewImgHover = ImageUtil.luminanceOffset(viewImg, -150);
+ VIEW_SETUP_ICON = new ImageIcon(viewImg);
+ VIEW_SETUP_HOVER_ICON = new ImageIcon(viewImgHover);
+
+ final BufferedImage exportImg = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "export_icon.png");
+ final BufferedImage exportImgHover = ImageUtil.luminanceOffset(exportImg, -150);
+ EXPORT_ICON = new ImageIcon(exportImg);
+ EXPORT_HOVER_ICON = new ImageIcon(exportImgHover);
+
+ final BufferedImage deleteImg = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "delete_icon.png");
+ DELETE_ICON = new ImageIcon(deleteImg);
+ DELETE_HOVER_ICON = new ImageIcon(ImageUtil.luminanceOffset(deleteImg, -100));
+ }
+
+ private final InventorySetupPlugin plugin;
+ private final InventorySetupPluginPanel panel;
+ private final InventorySetup inventorySetup;
+ private final JLabel bankFilterIndicator = new JLabel();
+ private final JLabel highlightColorIndicator = new JLabel();
+ private final JLabel stackDifferenceIndicator = new JLabel();
+ private final JLabel variationDifferenceIndicator = new JLabel();
+ private final JLabel unorderedHighlightIndicator = new JLabel();
+ private final JLabel highlightIndicator = new JLabel();
+ private final JLabel viewSetupLabel = new JLabel();
+ private final JLabel exportLabel = new JLabel();
+ private final JLabel deleteLabel = new JLabel();
+ private final FlatTextField nameInput = new FlatTextField();
+ private final JLabel save = new JLabel("Save");
+ private final JLabel cancel = new JLabel("Cancel");
+ private final JLabel rename = new JLabel("Rename");
+
+ InventorySetupPanel(InventorySetupPlugin plugin, InventorySetupPluginPanel panel, InventorySetup invSetup)
+ {
+ this.plugin = plugin;
+ this.panel = panel;
+ this.inventorySetup = invSetup;
+
+ setLayout(new BorderLayout());
+ setBackground(ColorScheme.DARKER_GRAY_COLOR);
+
+ JPanel nameWrapper = new JPanel(new BorderLayout());
+ nameWrapper.setBackground(ColorScheme.DARKER_GRAY_COLOR);
+ nameWrapper.setBorder(NAME_BOTTOM_BORDER);
+
+ JPanel nameActions = new JPanel(new BorderLayout(3, 0));
+ nameActions.setBorder(new EmptyBorder(0, 0, 0, 8));
+ nameActions.setBackground(ColorScheme.DARKER_GRAY_COLOR);
+
+ save.setVisible(false);
+ save.setFont(FontManager.getRunescapeSmallFont());
+ save.setForeground(ColorScheme.PROGRESS_COMPLETE_COLOR);
+ save.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ inventorySetup.setName(nameInput.getText());
+ plugin.updateJsonConfig();
+
+ nameInput.setEditable(false);
+ updateNameActions(false);
+ requestFocusInWindow();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ save.setForeground(ColorScheme.PROGRESS_COMPLETE_COLOR.darker());
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ save.setForeground(ColorScheme.PROGRESS_COMPLETE_COLOR);
+ }
+ });
+
+ cancel.setVisible(false);
+ cancel.setFont(FontManager.getRunescapeSmallFont());
+ cancel.setForeground(ColorScheme.PROGRESS_ERROR_COLOR);
+ cancel.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ nameInput.setEditable(false);
+ nameInput.setText(inventorySetup.getName());
+ updateNameActions(false);
+ requestFocusInWindow();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ cancel.setForeground(ColorScheme.PROGRESS_ERROR_COLOR.darker());
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ cancel.setForeground(ColorScheme.PROGRESS_ERROR_COLOR);
+ }
+ });
+
+ rename.setFont(FontManager.getRunescapeSmallFont());
+ rename.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker());
+ rename.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ nameInput.setEditable(true);
+ updateNameActions(true);
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ rename.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker().darker());
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ rename.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker());
+ }
+ });
+
+ nameActions.add(save, BorderLayout.EAST);
+ nameActions.add(cancel, BorderLayout.WEST);
+ nameActions.add(rename, BorderLayout.CENTER);
+
+ nameInput.setText(inventorySetup.getName());
+ nameInput.setBorder(null);
+ nameInput.setEditable(false);
+ nameInput.setBackground(ColorScheme.DARKER_GRAY_COLOR);
+ nameInput.setPreferredSize(new Dimension(0, 24));
+ nameInput.getTextField().setForeground(Color.WHITE);
+ nameInput.getTextField().setBorder(new EmptyBorder(0, 8, 0, 0));
+
+ nameWrapper.add(nameInput, BorderLayout.CENTER);
+ nameWrapper.add(nameActions, BorderLayout.EAST);
+
+ JPanel bottomContainer = new JPanel(new BorderLayout());
+ bottomContainer.setBorder(new EmptyBorder(8, 0, 8, 0));
+ bottomContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
+
+ bankFilterIndicator.setToolTipText("Enable bank filtering");
+ bankFilterIndicator.setIcon(inventorySetup.isFilterBank() ? BANK_FILTER_ICON : NO_BANK_FILTER_ICON);
+ bankFilterIndicator.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ inventorySetup.setFilterBank(!inventorySetup.isFilterBank());
+ bankFilterIndicator.setToolTipText(inventorySetup.isFilterBank() ? "Disable bank filtering" : "Enable bank filtering");
+ updateBankFilterLabel();
+ plugin.updateJsonConfig();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ bankFilterIndicator.setIcon(inventorySetup.isFilterBank() ? BANK_FILTER_HOVER_ICON : NO_BANK_FILTER_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e)
+ {
+ bankFilterIndicator.setIcon(inventorySetup.isFilterBank() ? BANK_FILTER_ICON : NO_BANK_FILTER_ICON);
+ }
+ });
+
+ stackDifferenceIndicator.setToolTipText("Enable highlighting for stack differences");
+ stackDifferenceIndicator.setIcon(inventorySetup.isStackDifference() ? STACK_DIFFERENCE_ICON : NO_STACK_DIFFERENCE_ICON);
+ stackDifferenceIndicator.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ inventorySetup.setStackDifference(!inventorySetup.isStackDifference());
+ stackDifferenceIndicator.setToolTipText(inventorySetup.isStackDifference() ? "Disable highlighting for stack differences" : "Enable highlighting for stack differences");
+ updateStackDifferenceLabel();
+ plugin.updateJsonConfig();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ stackDifferenceIndicator.setIcon(inventorySetup.isStackDifference() ? STACK_DIFFERENCE_HOVER_ICON : NO_STACK_DIFFERENCE_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ stackDifferenceIndicator.setIcon(inventorySetup.isStackDifference() ? STACK_DIFFERENCE_ICON : NO_STACK_DIFFERENCE_ICON);
+ }
+ });
+
+ variationDifferenceIndicator.setToolTipText("Enable highlighting for variation differences");
+ variationDifferenceIndicator.setIcon(inventorySetup.isVariationDifference() ? VARIATION_DIFFERENCE_ICON : NO_VARIATION_DIFFERENCE_ICON);
+ variationDifferenceIndicator.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ inventorySetup.setVariationDifference(!inventorySetup.isVariationDifference());
+ variationDifferenceIndicator.setToolTipText(inventorySetup.isVariationDifference() ? "Disable highlighting for variation differences" : "Enable highlighting for variation differences");
+ updateVariationDifferenceLabel();
+ plugin.updateJsonConfig();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ variationDifferenceIndicator.setIcon(inventorySetup.isVariationDifference() ? VARIATION_DIFFERENCE_HOVER_ICON : NO_VARIATION_DIFFERENCE_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ variationDifferenceIndicator.setIcon(inventorySetup.isVariationDifference() ? VARIATION_DIFFERENCE_ICON : NO_VARIATION_DIFFERENCE_ICON);
+ }
+ });
+
+ unorderedHighlightIndicator.setToolTipText("Only highlight items that are missing from the inventory and ignore order");
+ unorderedHighlightIndicator.setIcon(inventorySetup.isUnorderedHighlight() ? UNORDERED_HIGHLIGHT_ICON : NO_UNORDERED_HIGHLIGHT_ICON);
+ unorderedHighlightIndicator.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ inventorySetup.setUnorderedHighlight(!inventorySetup.isUnorderedHighlight());
+ unorderedHighlightIndicator.setToolTipText(inventorySetup.isUnorderedHighlight() ? "Enable default ordered highlighting" : "Only highlight items that are missing from the inventory and ignore order");
+ updateUnorderedHighlightIndicator();
+ plugin.updateJsonConfig();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ unorderedHighlightIndicator.setIcon(inventorySetup.isUnorderedHighlight() ? UNORDERED_HIGHLIGHT_HOVER_ICON : NO_UNORDERED_HIGHLIGHT_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e)
+ {
+ unorderedHighlightIndicator.setIcon(inventorySetup.isUnorderedHighlight() ? UNORDERED_HIGHLIGHT_ICON : NO_UNORDERED_HIGHLIGHT_ICON);
+ }
+ });
+
+ highlightIndicator.setToolTipText("Enable highlighting");
+ highlightIndicator.setIcon(inventorySetup.isHighlightDifference() ? TOGGLE_HIGHLIGHT_ICON : NO_TOGGLE_HIGHLIGHT_ICON);
+ highlightIndicator.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ inventorySetup.setHighlightDifference(!inventorySetup.isHighlightDifference());
+ highlightIndicator.setToolTipText(inventorySetup.isHighlightDifference() ? "Disable highlighting" : "Enable highlighting");
+ updateToggleHighlightLabel();
+ updateHighlightColorLabel();
+ plugin.updateJsonConfig();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ highlightIndicator.setIcon(inventorySetup.isHighlightDifference() ? TOGGLE_HIGHLIGHT_HOVER_ICON : NO_TOGGLE_HIGHLIGHT_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ highlightIndicator.setIcon(inventorySetup.isHighlightDifference() ? TOGGLE_HIGHLIGHT_ICON : NO_TOGGLE_HIGHLIGHT_ICON);
+ }
+ });
+
+ highlightColorIndicator.setToolTipText("Edit highlight color");
+ highlightColorIndicator.setIcon(inventorySetup.isHighlightDifference() ? HIGHLIGHT_COLOR_ICON : NO_HIGHLIGHT_COLOR_ICON);
+ highlightColorIndicator.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ openHighlightColorPicker();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ highlightColorIndicator.setIcon(inventorySetup.isHighlightDifference() ? HIGHLIGHT_COLOR_HOVER_ICON : NO_HIGHLIGHT_COLOR_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ highlightColorIndicator.setIcon(inventorySetup.isHighlightDifference() ? HIGHLIGHT_COLOR_ICON : NO_HIGHLIGHT_COLOR_ICON);
+ }
+ });
+
+ JPanel leftActions = new JPanel(new FlowLayout(FlowLayout.LEFT, H_GAP_BTN, 0));
+ leftActions.setBackground(ColorScheme.DARKER_GRAY_COLOR);
+
+ leftActions.add(bankFilterIndicator);
+ leftActions.add(stackDifferenceIndicator);
+ leftActions.add(variationDifferenceIndicator);
+ leftActions.add(unorderedHighlightIndicator);
+ leftActions.add(highlightIndicator);
+ leftActions.add(highlightColorIndicator);
+
+ viewSetupLabel.setToolTipText("View setup");
+ viewSetupLabel.setIcon(VIEW_SETUP_ICON);
+ viewSetupLabel.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ panel.setCurrentInventorySetup(inventorySetup, true);
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ viewSetupLabel.setIcon(VIEW_SETUP_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ viewSetupLabel.setIcon(VIEW_SETUP_ICON);
+ }
+ });
+
+ exportLabel.setToolTipText("Export setup");
+ exportLabel.setIcon(EXPORT_ICON);
+ exportLabel.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ plugin.exportSetup(inventorySetup);
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ exportLabel.setIcon(EXPORT_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ exportLabel.setIcon(EXPORT_ICON);
+ }
+ });
+
+ deleteLabel.setToolTipText("Delete setup");
+ deleteLabel.setIcon(DELETE_ICON);
+ deleteLabel.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent mouseEvent)
+ {
+ plugin.removeInventorySetup(inventorySetup);
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent)
+ {
+ deleteLabel.setIcon(DELETE_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent)
+ {
+ deleteLabel.setIcon(DELETE_ICON);
+ }
+ });
+
+ JPanel rightActions = new JPanel(new FlowLayout(FlowLayout.RIGHT, H_GAP_BTN, 0));
+ rightActions.setBackground(ColorScheme.DARKER_GRAY_COLOR);
+
+ rightActions.add(viewSetupLabel);
+ rightActions.add(exportLabel);
+ rightActions.add(deleteLabel);
+
+ bottomContainer.add(leftActions, BorderLayout.WEST);
+ bottomContainer.add(rightActions, BorderLayout.EAST);
+
+ add(nameWrapper, BorderLayout.NORTH);
+ add(bottomContainer, BorderLayout.CENTER);
+
+ updateHighlightColorLabel();
+ updateStackDifferenceLabel();
+ updateVariationDifferenceLabel();
+ updateToggleHighlightLabel();
+
+ }
+
+ private void updateNameActions(boolean saveAndCancel)
+ {
+ save.setVisible(saveAndCancel);
+ cancel.setVisible(saveAndCancel);
+ rename.setVisible(!saveAndCancel);
+
+ if (saveAndCancel)
+ {
+ nameInput.getTextField().requestFocusInWindow();
+ nameInput.getTextField().selectAll();
+ }
+ }
+
+ private void updateHighlightColorLabel()
+ {
+ Color color = inventorySetup.getHighlightColor();
+ highlightColorIndicator.setBorder(new MatteBorder(0, 0, 3, 0, color));
+ highlightColorIndicator.setIcon(inventorySetup.isHighlightDifference() ? HIGHLIGHT_COLOR_ICON : NO_HIGHLIGHT_COLOR_ICON);
+ }
+
+ private void updateBankFilterLabel()
+ {
+ bankFilterIndicator.setIcon(inventorySetup.isFilterBank() ? BANK_FILTER_ICON : NO_BANK_FILTER_ICON);
+ }
+
+ private void updateStackDifferenceLabel()
+ {
+ stackDifferenceIndicator.setIcon(inventorySetup.isStackDifference() ? STACK_DIFFERENCE_ICON : NO_STACK_DIFFERENCE_ICON);
+ }
+
+ private void updateVariationDifferenceLabel()
+ {
+ variationDifferenceIndicator.setIcon(inventorySetup.isVariationDifference() ? VARIATION_DIFFERENCE_ICON : NO_VARIATION_DIFFERENCE_ICON);
+ }
+
+ private void updateUnorderedHighlightIndicator()
+ {
+ unorderedHighlightIndicator.setIcon(inventorySetup.isUnorderedHighlight() ? UNORDERED_HIGHLIGHT_ICON : NO_UNORDERED_HIGHLIGHT_ICON);
+ }
+
+ private void updateToggleHighlightLabel()
+ {
+ highlightIndicator.setIcon(inventorySetup.isHighlightDifference() ? TOGGLE_HIGHLIGHT_ICON : NO_TOGGLE_HIGHLIGHT_ICON);
+ }
+
+ private void openHighlightColorPicker()
+ {
+
+ RuneliteColorPicker colorPicker = plugin.getColorPickerManager().create(
+ SwingUtilities.windowForComponent(this),
+ inventorySetup.getHighlightColor(),
+ inventorySetup.getName(),
+ false);
+
+ colorPicker.setLocation(getLocationOnScreen());
+ colorPicker.setOnColorChange(c ->
+ {
+ inventorySetup.setHighlightColor(c);
+ updateHighlightColorLabel();
+ });
+
+ colorPicker.addWindowListener(new WindowAdapter()
+ {
+ @Override
+ public void windowClosing(WindowEvent e)
+ {
+ plugin.updateJsonConfig();
+ }
+ });
+
+ colorPicker.setVisible(true);
+ }
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPluginPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPluginPanel.java
index bce82cd7cb..1b89546e86 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPluginPanel.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupPluginPanel.java
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
+ * Copyright (c) 2019, dillydill123
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,52 +24,47 @@
*/
package net.runelite.client.plugins.inventorysetups.ui;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.event.ItemEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.image.BufferedImage;
-import java.util.List;
-import javax.inject.Singleton;
+import net.runelite.client.plugins.inventorysetups.InventorySetup;
+import net.runelite.client.plugins.inventorysetups.InventorySetupItem;
+import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
+import lombok.Getter;
+import net.runelite.api.InventoryID;
+import net.runelite.client.game.ItemManager;
+import net.runelite.client.ui.ColorScheme;
+import net.runelite.client.ui.PluginPanel;
+import net.runelite.client.ui.components.PluginErrorPanel;
+import net.runelite.client.util.ImageUtil;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
-import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;
-import net.runelite.api.InventoryID;
-import net.runelite.client.game.ItemManager;
-import net.runelite.client.plugins.inventorysetups.InventorySetup;
-import net.runelite.client.plugins.inventorysetups.InventorySetupItem;
-import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
-import net.runelite.client.ui.PluginPanel;
-import net.runelite.client.ui.components.PluginErrorPanel;
-import net.runelite.client.util.ImageUtil;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
-@Singleton
public class InventorySetupPluginPanel extends PluginPanel
{
- private static final ImageIcon ADD_ICON;
- private static final ImageIcon ADD_HOVER_ICON;
- private static final ImageIcon REMOVE_ICON;
- private static final ImageIcon REMOVE_HOVER_ICON;
- private final JPanel noSetupsPanel;
- private final JPanel invEqPanel;
+ private static ImageIcon ADD_ICON;
+ private static ImageIcon ADD_HOVER_ICON;
+ private static ImageIcon BACK_ICON;
+ private static ImageIcon BACK_HOVER_ICON;
+ private static ImageIcon IMPORT_ICON;
+ private static ImageIcon IMPORT_HOVER_ICON;
+ private static ImageIcon UPDATE_ICON;
+ private static ImageIcon UPDATE_HOVER_ICON;
- private final InventorySetupInventoryPanel invPanel;
- private final InventorySetupEquipmentPanel eqpPanel;
-
- private final JComboBox setupComboBox;
-
- private final JLabel removeMarker;
-
- private final InventorySetupPlugin plugin;
+ private static String MAIN_TITLE;
static
{
@@ -78,34 +72,86 @@ public class InventorySetupPluginPanel extends PluginPanel
ADD_ICON = new ImageIcon(addIcon);
ADD_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(addIcon, 0.53f));
- final BufferedImage removeIcon = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "remove_icon.png");
- REMOVE_ICON = new ImageIcon(removeIcon);
- REMOVE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(removeIcon, 0.53f));
+ final BufferedImage importIcon = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "import_icon.png");
+ IMPORT_ICON = new ImageIcon(importIcon);
+ IMPORT_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(importIcon, 0.53f));
+
+ final BufferedImage updateIcon = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "update_icon.png");
+ UPDATE_ICON = new ImageIcon(updateIcon);
+ UPDATE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(updateIcon, 0.53f));
+
+ final BufferedImage backIcon = ImageUtil.getResourceStreamFromClass(InventorySetupPlugin.class, "back_arrow_icon.png");
+ BACK_ICON = new ImageIcon(ImageUtil.flipImage(backIcon, true, false));
+ BACK_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageUtil.flipImage(backIcon, true, false), 0.53f));
+
+ MAIN_TITLE = "Inventory Setups";
}
+ private final JPanel noSetupsPanel;
+ private final JPanel invEqPanel;
+ private final JPanel overviewPanel;
+ private final JScrollPane contentWrapperPane;
+ private final JPanel overviewTopRightButtonsPanel;
+ private final JPanel setupTopRightButtonsPanel;
+ private final JLabel title;
+ private final JLabel addMarker;
+ private final JLabel addImportMarker;
+ private final JLabel updateMarker;
+ private final JLabel backMarker;
+ private final InventorySetupInventoryPanel invPanel;
+ private final InventorySetupEquipmentPanel eqpPanel;
+ private final InventorySetupRunePouchPanel rpPanel;
+ private final InventorySetupPlugin plugin;
+ @Getter
+ private InventorySetup currentSelectedSetup;
+
public InventorySetupPluginPanel(final InventorySetupPlugin plugin, final ItemManager itemManager)
{
super(false);
+ this.currentSelectedSetup = null;
this.plugin = plugin;
- this.removeMarker = new JLabel(REMOVE_ICON);
- this.invPanel = new InventorySetupInventoryPanel(itemManager, plugin);
+ this.rpPanel = new InventorySetupRunePouchPanel(itemManager, plugin);
+ this.invPanel = new InventorySetupInventoryPanel(itemManager, plugin, rpPanel);
this.eqpPanel = new InventorySetupEquipmentPanel(itemManager, plugin);
this.noSetupsPanel = new JPanel();
this.invEqPanel = new JPanel();
- this.setupComboBox = new JComboBox<>();
+ this.overviewPanel = new JPanel();
// setup the title
- final JLabel addMarker = new JLabel(ADD_ICON);
- final JLabel title = new JLabel();
- title.setText("Inventory Setups");
+ this.title = new JLabel();
+ title.setText(MAIN_TITLE);
title.setForeground(Color.WHITE);
+ this.addImportMarker = new JLabel(IMPORT_ICON);
+ addImportMarker.setToolTipText ("Import a new inventory setup");
+ addImportMarker.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ plugin.importSetup();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ addImportMarker.setIcon(IMPORT_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e)
+ {
+ addImportMarker.setIcon(IMPORT_ICON);
+ }
+ });
+
// setup the add marker (+ sign in the top right)
+ this.addMarker = new JLabel(ADD_ICON);
addMarker.setToolTipText("Add a new inventory setup");
addMarker.addMouseListener(new MouseAdapter()
{
@Override
- public void mouseClicked(MouseEvent e)
+ public void mousePressed(MouseEvent e)
{
plugin.addInventorySetup();
}
@@ -123,51 +169,74 @@ public class InventorySetupPluginPanel extends PluginPanel
}
});
- // setup the remove marker (X sign in the top right)
- removeMarker.setToolTipText("Remove the current inventory setup");
- removeMarker.addMouseListener(new MouseAdapter()
+ this.updateMarker = new JLabel(UPDATE_ICON);
+ updateMarker.setToolTipText("Update setup with current inventory and equipment");
+ updateMarker.addMouseListener(new MouseAdapter()
{
@Override
- public void mouseClicked(MouseEvent e)
+ public void mousePressed(MouseEvent e)
{
- final String name = (String) setupComboBox.getSelectedItem();
- plugin.removeInventorySetup(name, true);
+ plugin.updateCurrentSetup(currentSelectedSetup);
}
@Override
public void mouseEntered(MouseEvent e)
{
- if (removeMarker.isEnabled())
- {
- removeMarker.setIcon(REMOVE_HOVER_ICON);
- }
+ updateMarker.setIcon(UPDATE_HOVER_ICON);
}
@Override
public void mouseExited(MouseEvent e)
{
- removeMarker.setIcon(REMOVE_ICON);
+ updateMarker.setIcon(UPDATE_ICON);
}
});
- // setup the combo box for selection switching
- // add empty to indicate the empty position
- setupComboBox.addItem("");
- setupComboBox.setSelectedIndex(0);
- setupComboBox.addItemListener(e ->
+ this.backMarker = new JLabel(BACK_ICON);
+ backMarker.setToolTipText("Return to setups");
+ backMarker.addMouseListener(new MouseAdapter()
{
- if (e.getStateChange() == ItemEvent.SELECTED)
+ @Override
+ public void mousePressed(MouseEvent e)
{
- String selection = (String) e.getItem();
- setCurrentInventorySetup(selection);
+ noSetupsPanel.setVisible(false);
+ invEqPanel.setVisible(false);
+ overviewPanel.setVisible(true);
+ overviewTopRightButtonsPanel.setVisible(true);
+ setupTopRightButtonsPanel.setVisible(false);
+ title.setText(MAIN_TITLE);
+ currentSelectedSetup = null;
+ plugin.resetBankSearch();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ backMarker.setIcon(BACK_HOVER_ICON);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e)
+ {
+ backMarker.setIcon(BACK_ICON);
}
});
- // the panel on the top right that holds the add and delete buttons
+ this.overviewTopRightButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 0));
+ overviewTopRightButtonsPanel.add(addImportMarker);
+ overviewTopRightButtonsPanel.add(addMarker);
+
+ this.setupTopRightButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 8, 0));
+ setupTopRightButtonsPanel.add(updateMarker);
+ setupTopRightButtonsPanel.add(backMarker);
+
+ // the panel on the top right that holds the buttons
final JPanel markersPanel = new JPanel();
- markersPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0));
- markersPanel.add(removeMarker);
- markersPanel.add(addMarker);
+ markersPanel.setLayout(new FlowLayout());
+ markersPanel.add(overviewTopRightButtonsPanel);
+ markersPanel.add(setupTopRightButtonsPanel);
+ overviewTopRightButtonsPanel.setVisible(true);
+ setupTopRightButtonsPanel.setVisible(false);
// the top panel that has the title and the buttons
final JPanel titleAndMarkersPanel = new JPanel();
@@ -176,148 +245,170 @@ public class InventorySetupPluginPanel extends PluginPanel
titleAndMarkersPanel.add(markersPanel, BorderLayout.EAST);
// the panel that stays at the top and doesn't scroll
- // contains the title, buttons, and the combo box
+ // contains the title and buttons
final JPanel northAnchoredPanel = new JPanel();
northAnchoredPanel.setLayout(new BoxLayout(northAnchoredPanel, BoxLayout.Y_AXIS));
northAnchoredPanel.setBorder(new EmptyBorder(0, 0, 10, 0));
northAnchoredPanel.add(titleAndMarkersPanel);
northAnchoredPanel.add(Box.createRigidArea(new Dimension(0, 10)));
- northAnchoredPanel.add(setupComboBox);
// the panel that holds the inventory and equipment panels
final BoxLayout invEqLayout = new BoxLayout(invEqPanel, BoxLayout.Y_AXIS);
invEqPanel.setLayout(invEqLayout);
invEqPanel.add(invPanel);
invEqPanel.add(Box.createRigidArea(new Dimension(0, 10)));
+ invEqPanel.add(rpPanel);
+ invEqPanel.add(Box.createRigidArea(new Dimension(0, 10)));
invEqPanel.add(eqpPanel);
// setup the error panel. It's wrapped around a normal panel
// so it doesn't stretch to fill the parent panel
final PluginErrorPanel errorPanel = new PluginErrorPanel();
- errorPanel.setContent("Inventory Setups", "Select or create an inventory setup.");
+ errorPanel.setContent("Inventory Setups", "Create an inventory setup.");
noSetupsPanel.add(errorPanel);
- // the panel that holds the inventory panels, and the error panel
+ // the panel that holds the inventory panels, error panel, and the overview panel
final JPanel contentPanel = new JPanel();
final BoxLayout contentLayout = new BoxLayout(contentPanel, BoxLayout.Y_AXIS);
contentPanel.setLayout(contentLayout);
contentPanel.add(invEqPanel);
contentPanel.add(noSetupsPanel);
+ contentPanel.add(overviewPanel);
// wrapper for the main content panel to keep it from stretching
final JPanel contentWrapper = new JPanel(new BorderLayout());
contentWrapper.add(Box.createGlue(), BorderLayout.CENTER);
contentWrapper.add(contentPanel, BorderLayout.NORTH);
- final JScrollPane contentWrapperPane = new JScrollPane(contentWrapper);
- contentWrapperPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ this.contentWrapperPane = new JScrollPane(contentWrapper);
+ this.contentWrapperPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
setLayout(new BorderLayout());
setBorder(new EmptyBorder(10, 10, 10, 10));
add(northAnchoredPanel, BorderLayout.NORTH);
- add(contentWrapperPane, BorderLayout.CENTER);
+ add(this.contentWrapperPane, BorderLayout.CENTER);
- // show the no setups panel on startup
- showNoSetupsPanel();
-
- }
-
- public void showNoSetupsPanel()
- {
- setupComboBox.setSelectedIndex(0);
- removeMarker.setEnabled(false);
- noSetupsPanel.setVisible(true);
+ // make sure the invEq panel isn't visible upon startup
invEqPanel.setVisible(false);
+
}
- private void showHasSetupPanel(final String name)
+ public void init()
{
- setupComboBox.setSelectedItem(name);
- removeMarker.setEnabled(true);
- noSetupsPanel.setVisible(false);
- invEqPanel.setVisible(true);
- }
+ overviewPanel.setLayout(new GridBagLayout());
+ overviewPanel.setBackground(ColorScheme.DARK_GRAY_COLOR);
- public void setCurrentInventorySetup(final String name)
- {
- if (name.isEmpty())
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.weightx = 1;
+ constraints.gridx = 0;
+ constraints.gridy = 0;
+
+ for (final InventorySetup setup : plugin.getInventorySetups())
+ {
+ InventorySetupPanel newPanel = new InventorySetupPanel(plugin, this, setup);
+ overviewPanel.add(newPanel, constraints);
+ constraints.gridy++;
+
+ overviewPanel.add(Box.createRigidArea(new Dimension(0, 10)), constraints);
+ constraints.gridy++;
+ }
+
+ invEqPanel.setVisible(false);
+
+ noSetupsPanel.setVisible(plugin.getInventorySetups().isEmpty());
+ overviewPanel.setVisible(!plugin.getInventorySetups().isEmpty());
+
+ }
+
+ public void rebuild()
+ {
+ overviewPanel.removeAll();
+ init();
+ revalidate();
+ repaint();
+ }
+
+ public void refreshCurrentSetup()
+ {
+ if (currentSelectedSetup != null)
+ {
+ setCurrentInventorySetup(currentSelectedSetup, false);
+ }
+ }
+
+ public void setCurrentInventorySetup(final InventorySetup inventorySetup, boolean resetScrollBar)
+ {
+ currentSelectedSetup = inventorySetup;
+ invPanel.setSlots(inventorySetup);
+ rpPanel.setSlots(inventorySetup);
+ eqpPanel.setSlots(inventorySetup);
+
+ overviewTopRightButtonsPanel.setVisible(false);
+ setupTopRightButtonsPanel.setVisible(true);
+
+ invEqPanel.setVisible(true);
+ noSetupsPanel.setVisible(false);
+ overviewPanel.setVisible(false);
+
+ title.setText(inventorySetup.getName());
+
+ // only show the rune pouch if the setup has a rune pouch
+ rpPanel.setVisible(currentSelectedSetup.getRune_pouch() != null);
+
+ highlightInventory();
+ highlightEquipment();
+
+ if (resetScrollBar)
+ {
+ // reset scrollbar back to top
+ this.contentWrapperPane.getVerticalScrollBar().setValue(0);
+ }
+
+ plugin.doBankSearch();
+
+ validate();
+ repaint();
+
+ }
+
+ public void highlightInventory()
+ {
+ // if the panel itself isn't visible, don't waste time doing any highlighting logic
+ if (!invEqPanel.isVisible())
{
- showNoSetupsPanel();
return;
}
- showHasSetupPanel(name);
-
- final InventorySetup inventorySetup = plugin.getInventorySetup(name);
-
- invPanel.setInventorySetupSlots(inventorySetup);
- eqpPanel.setEquipmentSetupSlots(inventorySetup);
-
- if (plugin.getHighlightDifference())
+ // if the panel is visible, check if highlighting is enabled on the setup and globally
+ // if any of the two, reset the slots so they aren't highlighted
+ if (!currentSelectedSetup.isHighlightDifference() || !plugin.isHighlightingAllowed())
{
- final List normInv = plugin.getNormalizedContainer(InventoryID.INVENTORY);
- final List normEqp = plugin.getNormalizedContainer(InventoryID.EQUIPMENT);
-
- highlightDifferences(normInv, inventorySetup, InventoryID.INVENTORY);
- highlightDifferences(normEqp, inventorySetup, InventoryID.EQUIPMENT);
- }
- else
- {
- invPanel.resetInventorySlotsColor();
- eqpPanel.resetEquipmentSlotsColor();
+ invPanel.resetSlotColors();
+ return;
}
- validate();
- repaint();
+ final ArrayList inv = plugin.getNormalizedContainer(InventoryID.INVENTORY);
+ invPanel.highlightSlotDifferences(inv, currentSelectedSetup);
}
- public void addInventorySetup(final String name)
+ public void highlightEquipment()
{
- setupComboBox.addItem(name);
- }
-
- public void addInventorySetupUnsorted(final String name)
- {
- for (int i = 1; i < setupComboBox.getItemCount(); ++i)
+ // if the panel itself isn't visible, don't waste time doing any highlighting logic
+ if (!invEqPanel.isVisible())
{
- if (setupComboBox.getItemAt(i).toLowerCase().compareTo(name.toLowerCase()) > 0)
- {
- setupComboBox.insertItemAt(name, i);
- return;
- }
+ return;
}
- setupComboBox.addItem(name);
- }
- public void removeInventorySetup(final String name)
- {
- setupComboBox.removeItem(name);
- showNoSetupsPanel();
-
- invPanel.resetInventorySlotsColor();
- eqpPanel.resetEquipmentSlotsColor();
-
- validate();
- repaint();
- }
-
- public void highlightDifferences(final List container,
- final InventorySetup setupToCheck,
- final InventoryID type)
- {
- switch (type)
+ // if the panel is visible, check if highlighting is enabled on the setup and globally
+ // if any of the two, reset the slots so they aren't highlighted
+ if (!currentSelectedSetup.isHighlightDifference() || !plugin.isHighlightingAllowed())
{
- case INVENTORY:
- invPanel.highlightDifferentSlots(container, setupToCheck);
- break;
-
- case EQUIPMENT:
- eqpPanel.highlightDifferences(container, setupToCheck);
- break;
+ eqpPanel.resetSlotColors();
+ return;
}
+
+ final ArrayList eqp = plugin.getNormalizedContainer(InventoryID.EQUIPMENT);
+ eqpPanel.highlightSlotDifferences(eqp, currentSelectedSetup);
}
- public final String getSelectedInventorySetup()
- {
- return (String) setupComboBox.getSelectedItem();
- }
}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupRunePouchPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupRunePouchPanel.java
new file mode 100644
index 0000000000..9493baf077
--- /dev/null
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupRunePouchPanel.java
@@ -0,0 +1,130 @@
+package net.runelite.client.plugins.inventorysetups.ui;
+
+import net.runelite.client.plugins.inventorysetups.InventorySetup;
+import net.runelite.client.plugins.inventorysetups.InventorySetupItem;
+import net.runelite.client.plugins.inventorysetups.InventorySetupSlotID;
+import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin;
+import net.runelite.client.game.ItemManager;
+import net.runelite.client.ui.ColorScheme;
+import javax.swing.JPanel;
+import java.awt.GridLayout;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+public class InventorySetupRunePouchPanel extends InventorySetupContainerPanel
+{
+ private ArrayList runeSlots;
+
+ InventorySetupRunePouchPanel(ItemManager itemManager, InventorySetupPlugin plugin)
+ {
+ super(itemManager, plugin, "Rune Pouch");
+ }
+
+ @Override
+ public void setupContainerPanel(JPanel containerSlotsPanel)
+ {
+ runeSlots = new ArrayList<>();
+ for (int i = 0; i < 3; i++)
+ {
+ runeSlots.add(new InventorySetupSlot(ColorScheme.DARKER_GRAY_COLOR, InventorySetupSlotID.RUNE_POUCH, i));
+ }
+
+ final GridLayout gridLayout = new GridLayout(1, 4, 1, 1);
+ containerSlotsPanel.setLayout(gridLayout);
+
+ for (final InventorySetupSlot slot : runeSlots)
+ {
+ containerSlotsPanel.add(slot);
+ }
+ }
+
+ @Override
+ public void highlightSlotDifferences(ArrayList currContainer, InventorySetup inventorySetup)
+ {
+ assert inventorySetup.getRune_pouch() != null : "Rune Pouch container is null.";
+
+ assert currContainer.size() == 3 : "Incorrect size";
+
+ isHighlighted = true;
+
+ // Note, we don't care about order or stack size
+
+ final ArrayList setupRunePouch = inventorySetup.getRune_pouch();
+
+ Map currInvMap = currContainer.stream()
+ .map(InventorySetupItem::getId)
+ .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+
+ for (int i = setupRunePouch.size() - 1; i >= 0; i--)
+ {
+ int itemID = setupRunePouch.get(i).getId();
+ Long currentCount = currInvMap.get(itemID);
+
+ if (currentCount == null)
+ {
+ runeSlots.get(i).setBackground(inventorySetup.getHighlightColor());
+ continue;
+ }
+
+ if (currentCount == 1)
+ {
+ currInvMap.remove(itemID);
+ }
+ else
+ {
+ currInvMap.put(itemID, currentCount - 1);
+ }
+
+ runeSlots.get(i).setBackground(ColorScheme.DARKER_GRAY_COLOR);
+ }
+ }
+
+ @Override
+ public void setSlots(InventorySetup setup)
+ {
+
+ if (setup.getRune_pouch() != null)
+ {
+ for (int i = 0; i < runeSlots.size(); i++)
+ {
+ super.setContainerSlot(i, runeSlots.get(i), setup);
+ }
+ }
+ else
+ {
+ for (final InventorySetupSlot slot : runeSlots)
+ {
+ slot.setImageLabel(null, null);
+ }
+ }
+
+ validate();
+ repaint();
+ }
+
+ @Override
+ public void resetSlotColors()
+ {
+ if (!isHighlighted)
+ {
+ return;
+ }
+ for (final InventorySetupSlot slot : runeSlots)
+ {
+ slot.setBackground(ColorScheme.DARKER_GRAY_COLOR);
+ }
+ isHighlighted = false;
+
+ }
+
+ public void highlightAllSlots(final InventorySetup setup)
+ {
+ for (final InventorySetupSlot slot : runeSlots)
+ {
+ slot.setBackground(setup.getHighlightColor());
+ }
+
+ }
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupSlot.java
index 8c47339a4e..90be26cce6 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupSlot.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorysetups/ui/InventorySetupSlot.java
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2018-2019, Ethan
- * Copyright (c) 2018, https://openosrs.com
+ * Copyright (c) 2019, dillydill123
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,30 +24,45 @@
*/
package net.runelite.client.plugins.inventorysetups.ui;
-import java.awt.Color;
-import java.awt.Dimension;
-import javax.inject.Singleton;
+import net.runelite.client.plugins.inventorysetups.InventorySetup;
+import net.runelite.client.plugins.inventorysetups.InventorySetupSlotID;
+import lombok.Getter;
+import lombok.Setter;
+import net.runelite.client.util.AsyncBufferedImage;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
-import net.runelite.client.util.AsyncBufferedImage;
+import java.awt.Color;
+import java.awt.Dimension;
-@Singleton
-class InventorySetupSlot extends JPanel
+public class InventorySetupSlot extends JPanel
{
+ @Getter
private final JLabel imageLabel;
- InventorySetupSlot(Color color)
+ @Getter
+ private final InventorySetupSlotID slotID;
+
+ @Getter
+ @Setter
+ private InventorySetup parentSetup;
+
+ @Getter
+ private int indexInSlot;
+
+ public InventorySetupSlot(Color color, InventorySetupSlotID id, int indexInSlot)
{
- imageLabel = new JLabel();
+ this.slotID = id;
+ this.imageLabel = new JLabel();
+ this.parentSetup = null;
+ this.indexInSlot = indexInSlot;
imageLabel.setVerticalAlignment(SwingConstants.CENTER);
setPreferredSize(new Dimension(46, 42));
setBackground(color);
add(imageLabel);
-
}
- void setImageLabel(String toolTip, AsyncBufferedImage itemImage)
+ public void setImageLabel(String toolTip, AsyncBufferedImage itemImage)
{
if (itemImage == null || toolTip == null)
{
@@ -64,4 +78,5 @@ class InventorySetupSlot extends JPanel
validate();
repaint();
}
-}
\ No newline at end of file
+
+}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runes.java b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runes.java
index e51485e208..d67517663e 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runes.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runes.java
@@ -58,7 +58,7 @@ public enum Runes
@Getter(AccessLevel.PACKAGE)
private final int id;
- @Getter(AccessLevel.PACKAGE)
+ @Getter(AccessLevel.PUBLIC)
private final int itemId;
@Getter(AccessLevel.PACKAGE)
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/back_arrow_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/back_arrow_icon.png
new file mode 100644
index 0000000000..1318a567bf
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/back_arrow_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/delete_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/delete_icon.png
new file mode 100644
index 0000000000..18b67f23f3
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/delete_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/export_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/export_icon.png
new file mode 100644
index 0000000000..fb328bc295
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/export_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/filter_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/filter_icon.png
new file mode 100644
index 0000000000..f71cd1e09e
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/filter_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/highlight_color_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/highlight_color_icon.png
new file mode 100644
index 0000000000..fb9b6816e5
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/highlight_color_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/highlight_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/highlight_icon.png
new file mode 100644
index 0000000000..7122914035
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/highlight_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/import_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/import_icon.png
new file mode 100644
index 0000000000..18235072ad
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/import_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/stack_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/stack_icon.png
new file mode 100644
index 0000000000..f0dfe5ed3d
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/stack_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/unordered_highlight_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/unordered_highlight_icon.png
new file mode 100644
index 0000000000..1c5313eed9
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/unordered_highlight_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/update_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/update_icon.png
new file mode 100644
index 0000000000..f489b449f7
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/update_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/variation_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/variation_icon.png
new file mode 100644
index 0000000000..83b937eb39
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/variation_icon.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/visible_icon.png b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/visible_icon.png
new file mode 100644
index 0000000000..5c4232c808
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/inventorysetups/visible_icon.png differ