Merge pull request #2235 from xKylee/inventorysetup
inventorysetup: update
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019, Ethan <https://github.com/Wea1thRS/>
|
||||
* Copyright (c) 2018, https://openosrs.com
|
||||
* Copyright (c) 2019, dillydill123 <https://github.com/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<InventorySetupItem> inventory;
|
||||
@Getter(AccessLevel.PUBLIC)
|
||||
private List<InventorySetupItem> equipment;
|
||||
}
|
||||
@Getter
|
||||
private ArrayList<InventorySetupItem> inventory;
|
||||
|
||||
@Getter
|
||||
private ArrayList<InventorySetupItem> equipment;
|
||||
|
||||
@Getter
|
||||
private ArrayList<InventorySetupItem> 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<InventorySetupItem> inv)
|
||||
{
|
||||
inventory = inv;
|
||||
}
|
||||
|
||||
public void updateEquipment(final ArrayList<InventorySetupItem> eqp)
|
||||
{
|
||||
equipment = eqp;
|
||||
}
|
||||
|
||||
public void updateRunePouch(final ArrayList<InventorySetupItem> rp)
|
||||
{
|
||||
rune_pouch = rp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019, Ethan <https://github.com/Wea1thRS/>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019, Ethan <https://github.com/Wea1thRS/>
|
||||
* Copyright (c) 2018, https://openosrs.com
|
||||
* Copyright (c) 2019, dillydill123 <https://github.com/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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019, Ethan <https://github.com/Wea1thRS/>
|
||||
* Copyright (c) 2018, https://openosrs.com
|
||||
* Copyright (c) 2019, dillydill123 <https://github.com/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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019, Ethan <https://github.com/Wea1thRS/>
|
||||
* Copyright (c) 2018, https://openosrs.com
|
||||
* Copyright (c) 2019, dillydill123 <https://github.com/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<InventorySetupItem> 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<InventorySetupItem> 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);
|
||||
}
|
||||
abstract public void setupContainerPanel(final JPanel containerSlotsPanel);
|
||||
|
||||
abstract public void highlightSlotDifferences(final ArrayList<InventorySetupItem> currContainer, final InventorySetup inventorySetup);
|
||||
|
||||
abstract public void setSlots(final InventorySetup setup);
|
||||
|
||||
abstract public void resetSlotColors();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019, Ethan <https://github.com/Wea1thRS/>
|
||||
* Copyright (c) 2018, https://openosrs.com
|
||||
* Copyright (c) 2019, dillydill123 <https://github.com/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<EquipmentInventorySlot, InventorySetupSlot> equipmentSlots;
|
||||
private HashMap<EquipmentInventorySlot, InventorySetupSlot> 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<InventorySetupItem> currEquipment, final InventorySetup inventorySetup)
|
||||
{
|
||||
final List<InventorySetupItem> equipment = setup.getEquipment();
|
||||
final ArrayList<InventorySetupItem> 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<InventorySetupItem> currEquipment, final InventorySetup inventorySetup)
|
||||
@Override
|
||||
public void resetSlotColors()
|
||||
{
|
||||
final List<InventorySetupItem> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019, Ethan <https://github.com/Wea1thRS/>
|
||||
* Copyright (c) 2018, https://openosrs.com
|
||||
* Copyright (c) 2019, dillydill123 <https://github.com/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<InventorySetupSlot> inventorySlots;
|
||||
private ArrayList<InventorySetupSlot> 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<InventorySetupItem> currInventory, final InventorySetup inventorySetup)
|
||||
{
|
||||
List<InventorySetupItem> inventory = setup.getInventory();
|
||||
final ArrayList<InventorySetupItem> 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<InventorySetupItem> currInventory, final InventorySetup inventorySetup)
|
||||
@Override
|
||||
public void resetSlotColors()
|
||||
{
|
||||
|
||||
final List<InventorySetupItem> 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;
|
||||
}
|
||||
}
|
||||
|
||||
private void doUnorderedHighlighting(final ArrayList<InventorySetupItem> currInventory, final InventorySetup inventorySetup)
|
||||
{
|
||||
HashMap<ImmutablePair<Integer, Integer>, 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<Integer, Integer> key = new ImmutablePair<>(itemId, quantity);
|
||||
int count = currInvMap.get(key) == null ? 0 : currInvMap.get(key);
|
||||
currInvMap.put(key, count + 1);
|
||||
}
|
||||
|
||||
final ArrayList<InventorySetupItem> 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<Integer, Integer> 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<InventorySetupItem> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,625 @@
|
||||
/*
|
||||
* Copyright (c) 2019, dillydill123 <https://github.com/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);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019, Ethan <https://github.com/Wea1thRS/>
|
||||
* Copyright (c) 2018, https://openosrs.com
|
||||
* Copyright (c) 2019, dillydill123 <https://github.com/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<String> 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<InventorySetupItem> normInv = plugin.getNormalizedContainer(InventoryID.INVENTORY);
|
||||
final List<InventorySetupItem> 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<InventorySetupItem> 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<InventorySetupItem> 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<InventorySetupItem> eqp = plugin.getNormalizedContainer(InventoryID.EQUIPMENT);
|
||||
eqpPanel.highlightSlotDifferences(eqp, currentSelectedSetup);
|
||||
}
|
||||
|
||||
public final String getSelectedInventorySetup()
|
||||
{
|
||||
return (String) setupComboBox.getSelectedItem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<InventorySetupSlot> 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<InventorySetupItem> 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<InventorySetupItem> setupRunePouch = inventorySetup.getRune_pouch();
|
||||
|
||||
Map<Integer, Long> 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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019, Ethan <https://github.com/Wea1thRS/>
|
||||
* Copyright (c) 2018, https://openosrs.com
|
||||
* Copyright (c) 2019, dillydill123 <https://github.com/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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
After Width: | Height: | Size: 146 B |
|
After Width: | Height: | Size: 208 B |
|
After Width: | Height: | Size: 183 B |
|
After Width: | Height: | Size: 168 B |
|
After Width: | Height: | Size: 223 B |
|
After Width: | Height: | Size: 180 B |
|
After Width: | Height: | Size: 181 B |
|
After Width: | Height: | Size: 174 B |
|
After Width: | Height: | Size: 121 B |
|
After Width: | Height: | Size: 192 B |
|
After Width: | Height: | Size: 172 B |
|
After Width: | Height: | Size: 312 B |