From 8137fd87c2ba682c6e31709548b8eae721d77b63 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Feb 2020 17:18:44 -0500 Subject: [PATCH] loot tracker: filter by type in details view --- .../plugins/loottracker/LootTrackerBox.java | 7 ++++--- .../plugins/loottracker/LootTrackerPanel.java | 15 +++++++++------ .../plugins/loottracker/LootTrackerRecord.java | 4 ++-- 3 files changed, 15 insertions(+), 11 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 8d7413f047..eda30ffb3a 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 @@ -159,19 +159,20 @@ class LootTrackerBox extends JPanel } /** - * Checks if this box matches specified id + * Checks if this box matches specified id and type * * @param id other record id + * @param type other record type * @return true if match is made */ - boolean matches(final String id) + boolean matches(final String id, final LootRecordType type) { if (id == null) { return true; } - return this.id.equals(id); + return this.id.equals(id) && lootRecordType == type; } /** 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 da064f524b..141f306b57 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 @@ -124,6 +124,7 @@ class LootTrackerPanel extends PluginPanel private boolean groupLoot; private boolean hideIgnoredItems; private String currentView; + private LootRecordType currentType; static { @@ -236,6 +237,7 @@ class LootTrackerPanel extends PluginPanel backBtn.addActionListener(ev -> { currentView = null; + currentType = null; backBtn.setVisible(false); detailsTitle.setText(""); rebuild(); @@ -285,9 +287,9 @@ class LootTrackerPanel extends PluginPanel } // If not in detailed view, remove all, otherwise only remove for the currently detailed title - sessionRecords.removeIf(r -> r.matches(currentView)); - aggregateRecords.removeIf(r -> r.matches(currentView)); - boxes.removeIf(b -> b.matches(currentView)); + sessionRecords.removeIf(r -> r.matches(currentView, currentType)); + aggregateRecords.removeIf(r -> r.matches(currentView, currentType)); + boxes.removeIf(b -> b.matches(currentView, currentType)); updateOverall(); logsContainer.removeAll(); logsContainer.repaint(); @@ -472,7 +474,7 @@ class LootTrackerPanel extends PluginPanel private LootTrackerBox buildBox(LootTrackerRecord record) { // If this record is not part of current view, return - if (!record.matches(currentView)) + if (!record.matches(currentView, currentType)) { return null; } @@ -532,7 +534,7 @@ class LootTrackerPanel extends PluginPanel { Predicate match = groupLoot // With grouped loot, remove any record with this title - ? r -> r.matches(record.getTitle()) + ? r -> r.matches(record.getTitle(), record.getType()) // Otherwise remove specifically this entry : r -> r.equals(record); sessionRecords.removeIf(match); @@ -557,6 +559,7 @@ class LootTrackerPanel extends PluginPanel details.addActionListener(e -> { currentView = record.getTitle(); + currentType = record.getType(); detailsTitle.setText(currentView); backBtn.setVisible(true); rebuild(); @@ -584,7 +587,7 @@ class LootTrackerPanel extends PluginPanel for (LootTrackerRecord record : concat(aggregateRecords, sessionRecords)) { - if (!record.matches(currentView)) + if (!record.matches(currentView, currentType)) { continue; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerRecord.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerRecord.java index 0763337109..a7f455c1f7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerRecord.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerRecord.java @@ -42,13 +42,13 @@ class LootTrackerRecord * @param id other record id * @return true if match is made */ - boolean matches(final String id) + boolean matches(final String id, LootRecordType type) { if (id == null) { return true; } - return title.equals(id); + return title.equals(id) && this.type == type; } } \ No newline at end of file