From 670f61fba24b42e501f1b683514867065fea1e6c Mon Sep 17 00:00:00 2001 From: Max Weber Date: Tue, 23 Oct 2018 16:00:05 -0600 Subject: [PATCH] loottracker: Lazily rebuild panels --- .../plugins/loottracker/LootTrackerBox.java | 4 ++++ .../plugins/loottracker/LootTrackerPanel.java | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) 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 b4ffdcb44e..a0360ff1a1 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 @@ -162,6 +162,10 @@ class LootTrackerBox extends JPanel } records.add(record); + } + + void rebuild() + { buildItems(); priceLabel.setText(StackFormatter.quantityToStackSize(totalPrice) + " gp"); 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 8764ad79c5..a4d7aaf8a3 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 @@ -325,7 +325,12 @@ class LootTrackerPanel extends PluginPanel final String subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : ""; final LootTrackerRecord record = new LootTrackerRecord(eventName, subTitle, items, System.currentTimeMillis()); records.add(record); - buildBox(record); + LootTrackerBox box = buildBox(record); + if (box != null) + { + box.rebuild(); + updateOverall(); + } } /** @@ -381,6 +386,7 @@ class LootTrackerPanel extends PluginPanel logsContainer.removeAll(); boxes.clear(); records.forEach(this::buildBox); + boxes.forEach(LootTrackerBox::rebuild); updateOverall(); logsContainer.revalidate(); logsContainer.repaint(); @@ -391,12 +397,12 @@ class LootTrackerPanel extends PluginPanel * add its items to it, updating the log's overall price and kills. If not, a new log will be created * to hold this entry's information. */ - private void buildBox(LootTrackerRecord record) + private LootTrackerBox buildBox(LootTrackerRecord record) { // If this record is not part of current view, return if (!record.matches(currentView)) { - return; + return null; } // Group all similar loot together @@ -407,8 +413,7 @@ class LootTrackerPanel extends PluginPanel if (box.matches(record)) { box.combine(record); - updateOverall(); - return; + return box; } } } @@ -456,8 +461,7 @@ class LootTrackerPanel extends PluginPanel boxes.add(box); logsContainer.add(box, 0); - // Update overall - updateOverall(); + return box; } private void updateOverall()