diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java
index f37be3eb43..0f3b11cea7 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java
@@ -28,6 +28,7 @@ package net.runelite.client.plugins.loottracker;
import com.google.common.base.Strings;
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Component;
import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
@@ -59,6 +60,8 @@ class LootTrackerBox extends JPanel
private final JPanel itemContainer = new JPanel();
private final JLabel priceLabel = new JLabel();
private final JLabel subTitleLabel = new JLabel();
+ private final JPanel logTitle = new JPanel(new BorderLayout(5, 0));
+ private final JLabel titleLabel = new JLabel();
private final ItemManager itemManager;
@Getter(AccessLevel.PACKAGE)
private final String id;
@@ -85,11 +88,10 @@ class LootTrackerBox extends JPanel
setLayout(new BorderLayout(0, 1));
setBorder(new EmptyBorder(5, 0, 0, 0));
- final JPanel logTitle = new JPanel(new BorderLayout(5, 0));
logTitle.setBorder(new EmptyBorder(7, 7, 7, 7));
logTitle.setBackground(ColorScheme.DARKER_GRAY_COLOR.darker());
- final JLabel titleLabel = new JLabel(Text.removeTags(id));
+ titleLabel.setText(Text.removeTags(id));
titleLabel.setFont(FontManager.getRunescapeSmallFont());
titleLabel.setForeground(Color.WHITE);
@@ -182,6 +184,39 @@ class LootTrackerBox extends JPanel
repaint();
}
+ void collapse()
+ {
+ if (!isCollapsed())
+ {
+ itemContainer.setVisible(false);
+ applyDimmer(false, logTitle);
+ }
+ }
+
+ void expand()
+ {
+ if (isCollapsed())
+ {
+ itemContainer.setVisible(true);
+ applyDimmer(true, logTitle);
+ }
+ }
+
+ boolean isCollapsed()
+ {
+ return !itemContainer.isVisible();
+ }
+
+ private void applyDimmer(boolean brighten, JPanel panel)
+ {
+ for (Component component : panel.getComponents())
+ {
+ Color color = component.getForeground();
+
+ component.setForeground(brighten ? color.brighter() : color.darker());
+ }
+ }
+
/**
* This method creates stacked items from the item list, calculates total price and then
* displays all the items in the UI.
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java
index 4f583e11c8..ef237a78ec 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java
@@ -69,6 +69,8 @@ class LootTrackerPanel extends PluginPanel
private static final ImageIcon VISIBLE_ICON_HOVER;
private static final ImageIcon INVISIBLE_ICON;
private static final ImageIcon INVISIBLE_ICON_HOVER;
+ private static final ImageIcon COLLAPSE_ICON;
+ private static final ImageIcon EXPAND_ICON;
private static final String HTML_LABEL_TEMPLATE =
"
%s%s";
@@ -92,6 +94,7 @@ class LootTrackerPanel extends PluginPanel
private final JLabel viewHiddenBtn = new JLabel();
private final JLabel singleLootBtn = new JLabel();
private final JLabel groupedLootBtn = new JLabel();
+ private final JLabel collapseBtn = new JLabel();
// Log collection
private final List records = new ArrayList<>();
@@ -112,6 +115,8 @@ class LootTrackerPanel extends PluginPanel
final BufferedImage backArrowImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "back_icon.png");
final BufferedImage visibleImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "visible_icon.png");
final BufferedImage invisibleImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "invisible_icon.png");
+ final BufferedImage collapseImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "collapsed.png");
+ final BufferedImage expandedImg = ImageUtil.getResourceStreamFromClass(LootTrackerPlugin.class, "expanded.png");
SINGLE_LOOT_VIEW = new ImageIcon(singleLootImg);
SINGLE_LOOT_VIEW_FADED = new ImageIcon(ImageUtil.alphaOffset(singleLootImg, -180));
@@ -129,6 +134,9 @@ class LootTrackerPanel extends PluginPanel
INVISIBLE_ICON = new ImageIcon(invisibleImg);
INVISIBLE_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(invisibleImg, -220));
+
+ COLLAPSE_ICON = new ImageIcon(collapseImg);
+ EXPAND_ICON = new ImageIcon(expandedImg);
}
LootTrackerPanel(final LootTrackerPlugin plugin, final ItemManager itemManager, final LootTrackerConfig config)
@@ -156,6 +164,16 @@ class LootTrackerPanel extends PluginPanel
final JPanel viewControls = new JPanel(new GridLayout(1, 3, 10, 0));
viewControls.setBackground(ColorScheme.DARKER_GRAY_COLOR);
+ collapseBtn.setIcon(EXPAND_ICON);
+ collapseBtn.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ changeCollapse();
+ }
+ });
+
singleLootBtn.setIcon(SINGLE_LOOT_VIEW);
singleLootBtn.setToolTipText("Show each kill separately");
singleLootBtn.addMouseListener(new MouseAdapter()
@@ -225,6 +243,7 @@ class LootTrackerPanel extends PluginPanel
}
});
+ viewControls.add(collapseBtn);
viewControls.add(groupedLootBtn);
viewControls.add(singleLootBtn);
viewControls.add(viewHiddenBtn);
@@ -265,8 +284,8 @@ class LootTrackerPanel extends PluginPanel
leftTitleContainer.add(backBtn, BorderLayout.WEST);
leftTitleContainer.add(detailsTitle, BorderLayout.CENTER);
- actionsContainer.add(leftTitleContainer, BorderLayout.WEST);
actionsContainer.add(viewControls, BorderLayout.EAST);
+ actionsContainer.add(leftTitleContainer, BorderLayout.WEST);
// Create panel that will contain overall data
overallPanel.setBorder(BorderFactory.createCompoundBorder(
@@ -325,6 +344,27 @@ class LootTrackerPanel extends PluginPanel
add(errorPanel);
}
+ void updateCollapseText()
+ {
+ if (isAllCollapsed())
+ {
+ collapseBtn.setToolTipText("Un-Collapse All");
+ collapseBtn.setIcon(COLLAPSE_ICON);
+ }
+ else
+ {
+ collapseBtn.setToolTipText("Collapse All");
+ collapseBtn.setIcon(EXPAND_ICON);
+ }
+ }
+
+ private boolean isAllCollapsed()
+ {
+ return boxes.stream()
+ .filter(i -> i.isCollapsed())
+ .count() == boxes.size();
+ }
+
void loadHeaderIcon(BufferedImage img)
{
overallIcon.setIcon(new ImageIcon(img));
@@ -382,6 +422,28 @@ class LootTrackerPanel extends PluginPanel
viewHiddenBtn.setIcon(hideIgnoredItems ? VISIBLE_ICON : INVISIBLE_ICON);
}
+ /**
+ * Changes the collapse status of loot entries
+ */
+ private void changeCollapse()
+ {
+ boolean isAllCollapsed = isAllCollapsed();
+
+ for (LootTrackerBox box : boxes)
+ {
+ if (isAllCollapsed)
+ {
+ box.expand();
+ }
+ else if (!box.isCollapsed())
+ {
+ box.collapse();
+ }
+ }
+
+ updateCollapseText();
+ }
+
/**
* After an item changed it's ignored state, iterate all the records and make
* sure all items of the same name also get updated
@@ -464,6 +526,27 @@ class LootTrackerPanel extends PluginPanel
popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
box.setComponentPopupMenu(popupMenu);
+ // Create collapse event
+ box.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mouseClicked(MouseEvent e)
+ {
+ if (e.getButton() == MouseEvent.BUTTON1)
+ {
+ if (box.isCollapsed())
+ {
+ box.expand();
+ }
+ else
+ {
+ box.collapse();
+ }
+ updateCollapseText();
+ }
+ }
+ });
+
// Create reset menu
final JMenuItem reset = new JMenuItem("Reset");
reset.addActionListener(e ->
@@ -541,6 +624,7 @@ class LootTrackerPanel extends PluginPanel
overallKillsLabel.setText(htmlLabel("Total count: ", overallKills));
overallGpLabel.setText(htmlLabel("Total value: ", overallGp));
+ updateCollapseText();
}
private static String htmlLabel(String key, long value)
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/loottracker/collapsed.png b/runelite-client/src/main/resources/net/runelite/client/plugins/loottracker/collapsed.png
new file mode 100644
index 0000000000..449f68ae6c
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/loottracker/collapsed.png differ
diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/loottracker/expanded.png b/runelite-client/src/main/resources/net/runelite/client/plugins/loottracker/expanded.png
new file mode 100644
index 0000000000..df41d71bc9
Binary files /dev/null and b/runelite-client/src/main/resources/net/runelite/client/plugins/loottracker/expanded.png differ