loot tracker: store and match events by type

This commit is contained in:
Adam
2020-02-09 17:11:37 -05:00
committed by Adam
parent 4d5857214e
commit 63e537e0e0
4 changed files with 22 additions and 7 deletions

View File

@@ -57,6 +57,7 @@ import net.runelite.client.util.AsyncBufferedImage;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.client.util.Text;
import net.runelite.http.api.loottracker.LootRecordType;
class LootTrackerBox extends JPanel
{
@@ -70,6 +71,7 @@ class LootTrackerBox extends JPanel
private final ItemManager itemManager;
@Getter(AccessLevel.PACKAGE)
private final String id;
private final LootRecordType lootRecordType;
private final LootTrackerPriceType priceType;
private final boolean showPriceType;
@@ -84,6 +86,7 @@ class LootTrackerBox extends JPanel
LootTrackerBox(
final ItemManager itemManager,
final String id,
final LootRecordType lootRecordType,
@Nullable final String subtitle,
final boolean hideIgnoredItems,
final LootTrackerPriceType priceType,
@@ -91,6 +94,7 @@ class LootTrackerBox extends JPanel
final BiConsumer<String, Boolean> onItemToggle)
{
this.id = id;
this.lootRecordType = lootRecordType;
this.itemManager = itemManager;
this.onItemToggle = onItemToggle;
this.hideIgnoredItems = hideIgnoredItems;
@@ -151,7 +155,7 @@ class LootTrackerBox extends JPanel
*/
boolean matches(final LootTrackerRecord record)
{
return record.getTitle().equals(id);
return record.getTitle().equals(id) && record.getType() == lootRecordType;
}
/**

View File

@@ -61,6 +61,7 @@ import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.QuantityFormatter;
import net.runelite.client.util.SwingUtil;
import net.runelite.http.api.loottracker.LootRecordType;
import net.runelite.http.api.loottracker.LootTrackerClient;
class LootTrackerPanel extends PluginPanel
@@ -337,10 +338,18 @@ class LootTrackerPanel extends PluginPanel
* Creates a subtitle, adds a new entry and then passes off to the render methods, that will decide
* how to display this new data.
*/
void add(final String eventName, final int actorLevel, LootTrackerItem[] items)
void add(final String eventName, final LootRecordType type, final int actorLevel, LootTrackerItem[] items)
{
final String subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : "";
final LootTrackerRecord record = new LootTrackerRecord(eventName, subTitle, items, 1);
final String subTitle;
if (type == LootRecordType.PICKPOCKET)
{
subTitle = "(pickpocket)";
}
else
{
subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : "";
}
final LootTrackerRecord record = new LootTrackerRecord(eventName, subTitle, type, items, 1);
sessionRecords.add(record);
LootTrackerBox box = buildBox(record);
@@ -487,7 +496,7 @@ class LootTrackerPanel extends PluginPanel
overallPanel.setVisible(true);
// Create box
final LootTrackerBox box = new LootTrackerBox(itemManager, record.getTitle(), record.getSubTitle(),
final LootTrackerBox box = new LootTrackerBox(itemManager, record.getTitle(), record.getType(), record.getSubTitle(),
hideIgnoredItems, config.priceType(), config.showPriceType(), plugin::toggleItem);
box.addKill(record);

View File

@@ -348,7 +348,7 @@ public class LootTrackerPlugin extends Plugin
void addLoot(String name, int combatLevel, LootRecordType type, Collection<ItemStack> items)
{
final LootTrackerItem[] entries = buildEntries(stack(items));
SwingUtilities.invokeLater(() -> panel.add(name, combatLevel, entries));
SwingUtilities.invokeLater(() -> panel.add(name, type, combatLevel, entries));
if (config.saveLoot())
{
@@ -729,7 +729,7 @@ public class LootTrackerPlugin extends Plugin
buildLootTrackerItem(itemStack.getId(), itemStack.getQty())
).toArray(LootTrackerItem[]::new);
return new LootTrackerRecord(record.getEventId(), "", drops, record.getAmount());
return new LootTrackerRecord(record.getEventId(), "", record.getType(), drops, record.getAmount());
})
.collect(Collectors.toCollection(ArrayList::new));
}

View File

@@ -25,12 +25,14 @@
package net.runelite.client.plugins.loottracker;
import lombok.Value;
import net.runelite.http.api.loottracker.LootRecordType;
@Value
class LootTrackerRecord
{
private final String title;
private final String subTitle;
private final LootRecordType type;
private final LootTrackerItem[] items;
private final int kills;