loot tracker: filter by type in details view

This commit is contained in:
Adam
2020-02-09 17:18:44 -05:00
committed by Adam
parent 63e537e0e0
commit 8137fd87c2
3 changed files with 15 additions and 11 deletions

View File

@@ -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 id other record id
* @param type other record type
* @return true if match is made * @return true if match is made
*/ */
boolean matches(final String id) boolean matches(final String id, final LootRecordType type)
{ {
if (id == null) if (id == null)
{ {
return true; return true;
} }
return this.id.equals(id); return this.id.equals(id) && lootRecordType == type;
} }
/** /**

View File

@@ -124,6 +124,7 @@ class LootTrackerPanel extends PluginPanel
private boolean groupLoot; private boolean groupLoot;
private boolean hideIgnoredItems; private boolean hideIgnoredItems;
private String currentView; private String currentView;
private LootRecordType currentType;
static static
{ {
@@ -236,6 +237,7 @@ class LootTrackerPanel extends PluginPanel
backBtn.addActionListener(ev -> backBtn.addActionListener(ev ->
{ {
currentView = null; currentView = null;
currentType = null;
backBtn.setVisible(false); backBtn.setVisible(false);
detailsTitle.setText(""); detailsTitle.setText("");
rebuild(); rebuild();
@@ -285,9 +287,9 @@ class LootTrackerPanel extends PluginPanel
} }
// If not in detailed view, remove all, otherwise only remove for the currently detailed title // If not in detailed view, remove all, otherwise only remove for the currently detailed title
sessionRecords.removeIf(r -> r.matches(currentView)); sessionRecords.removeIf(r -> r.matches(currentView, currentType));
aggregateRecords.removeIf(r -> r.matches(currentView)); aggregateRecords.removeIf(r -> r.matches(currentView, currentType));
boxes.removeIf(b -> b.matches(currentView)); boxes.removeIf(b -> b.matches(currentView, currentType));
updateOverall(); updateOverall();
logsContainer.removeAll(); logsContainer.removeAll();
logsContainer.repaint(); logsContainer.repaint();
@@ -472,7 +474,7 @@ class LootTrackerPanel extends PluginPanel
private LootTrackerBox buildBox(LootTrackerRecord record) private LootTrackerBox buildBox(LootTrackerRecord record)
{ {
// If this record is not part of current view, return // If this record is not part of current view, return
if (!record.matches(currentView)) if (!record.matches(currentView, currentType))
{ {
return null; return null;
} }
@@ -532,7 +534,7 @@ class LootTrackerPanel extends PluginPanel
{ {
Predicate<LootTrackerRecord> match = groupLoot Predicate<LootTrackerRecord> match = groupLoot
// With grouped loot, remove any record with this title // 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 // Otherwise remove specifically this entry
: r -> r.equals(record); : r -> r.equals(record);
sessionRecords.removeIf(match); sessionRecords.removeIf(match);
@@ -557,6 +559,7 @@ class LootTrackerPanel extends PluginPanel
details.addActionListener(e -> details.addActionListener(e ->
{ {
currentView = record.getTitle(); currentView = record.getTitle();
currentType = record.getType();
detailsTitle.setText(currentView); detailsTitle.setText(currentView);
backBtn.setVisible(true); backBtn.setVisible(true);
rebuild(); rebuild();
@@ -584,7 +587,7 @@ class LootTrackerPanel extends PluginPanel
for (LootTrackerRecord record : concat(aggregateRecords, sessionRecords)) for (LootTrackerRecord record : concat(aggregateRecords, sessionRecords))
{ {
if (!record.matches(currentView)) if (!record.matches(currentView, currentType))
{ {
continue; continue;
} }

View File

@@ -42,13 +42,13 @@ class LootTrackerRecord
* @param id other record id * @param id other record id
* @return true if match is made * @return true if match is made
*/ */
boolean matches(final String id) boolean matches(final String id, LootRecordType type)
{ {
if (id == null) if (id == null)
{ {
return true; return true;
} }
return title.equals(id); return title.equals(id) && this.type == type;
} }
} }