adds support for date and adds date display to loot tracker panel
Signed-off-by: PKLite <stonewall@pklite.xyz>
This commit is contained in:
@@ -17,7 +17,7 @@ public enum LootRecordSortType implements Comparator<LootTrackerRecord>
|
|||||||
@Override
|
@Override
|
||||||
public int compare(LootTrackerRecord o1, LootTrackerRecord o2)
|
public int compare(LootTrackerRecord o1, LootTrackerRecord o2)
|
||||||
{
|
{
|
||||||
return Long.compare(o1.getTimestamp(), o2.getTimestamp());
|
return Long.compare(o1.getTimestamp().toEpochMilli(), o2.getTimestamp().toEpochMilli());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TOTAL_VALUE
|
TOTAL_VALUE
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import java.awt.GridLayout;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -59,6 +60,7 @@ class LootTrackerBox extends JPanel
|
|||||||
private final JPanel itemContainer = new JPanel();
|
private final JPanel itemContainer = new JPanel();
|
||||||
private final JLabel priceLabel = new JLabel();
|
private final JLabel priceLabel = new JLabel();
|
||||||
private final JLabel subTitleLabel = new JLabel();
|
private final JLabel subTitleLabel = new JLabel();
|
||||||
|
private final JLabel dateLabel = new JLabel();
|
||||||
private final ItemManager itemManager;
|
private final ItemManager itemManager;
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private final String id;
|
private final String id;
|
||||||
@@ -69,14 +71,17 @@ class LootTrackerBox extends JPanel
|
|||||||
private long totalPrice;
|
private long totalPrice;
|
||||||
private boolean hideIgnoredItems;
|
private boolean hideIgnoredItems;
|
||||||
private BiConsumer<String, Boolean> onItemToggle;
|
private BiConsumer<String, Boolean> onItemToggle;
|
||||||
|
private final long timeStamp;
|
||||||
|
|
||||||
LootTrackerBox(
|
LootTrackerBox(
|
||||||
|
final long timeStamp,
|
||||||
final ItemManager itemManager,
|
final ItemManager itemManager,
|
||||||
final String id,
|
final String id,
|
||||||
@Nullable final String subtitle,
|
@Nullable final String subtitle,
|
||||||
final boolean hideIgnoredItems,
|
final boolean hideIgnoredItems,
|
||||||
final BiConsumer<String, Boolean> onItemToggle)
|
final BiConsumer<String, Boolean> onItemToggle)
|
||||||
{
|
{
|
||||||
|
this.timeStamp = timeStamp;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.itemManager = itemManager;
|
this.itemManager = itemManager;
|
||||||
this.onItemToggle = onItemToggle;
|
this.onItemToggle = onItemToggle;
|
||||||
@@ -99,6 +104,12 @@ class LootTrackerBox extends JPanel
|
|||||||
subTitleLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
subTitleLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
|
||||||
logTitle.add(subTitleLabel, BorderLayout.CENTER);
|
logTitle.add(subTitleLabel, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
dateLabel.setFont(FontManager.getRunescapeSmallFont().deriveFont(FontManager.getRunescapeSmallFont().getSize() - 2));
|
||||||
|
dateLabel.setForeground(Color.LIGHT_GRAY);
|
||||||
|
dateLabel.setText(new Date(timeStamp).toLocaleString());
|
||||||
|
logTitle.add(dateLabel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
|
||||||
if (!Strings.isNullOrEmpty(subtitle))
|
if (!Strings.isNullOrEmpty(subtitle))
|
||||||
{
|
{
|
||||||
subTitleLabel.setText(subtitle);
|
subTitleLabel.setText(subtitle);
|
||||||
@@ -110,6 +121,7 @@ class LootTrackerBox extends JPanel
|
|||||||
|
|
||||||
add(logTitle, BorderLayout.NORTH);
|
add(logTitle, BorderLayout.NORTH);
|
||||||
add(itemContainer, BorderLayout.CENTER);
|
add(itemContainer, BorderLayout.CENTER);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import java.awt.GridLayout;
|
|||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -390,7 +391,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
void add(final String eventName, final String localUsername, final int actorLevel, LootTrackerItem[] items)
|
void add(final String eventName, final String localUsername, final int actorLevel, LootTrackerItem[] items)
|
||||||
{
|
{
|
||||||
final String subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : "";
|
final String subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : "";
|
||||||
final LootTrackerRecord record = new LootTrackerRecord( eventName, localUsername, subTitle, items, System.currentTimeMillis());
|
final LootTrackerRecord record = new LootTrackerRecord( eventName, localUsername, subTitle, items, Instant.now());
|
||||||
records.add(record);
|
records.add(record);
|
||||||
LootTrackerBox box = buildBox(record);
|
LootTrackerBox box = buildBox(record);
|
||||||
if (box != null)
|
if (box != null)
|
||||||
@@ -545,7 +546,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
overallPanel.setVisible(true);
|
overallPanel.setVisible(true);
|
||||||
|
|
||||||
// Create box
|
// Create box
|
||||||
final LootTrackerBox box = new LootTrackerBox(itemManager, record.getTitle(), record.getSubTitle(),
|
final LootTrackerBox box = new LootTrackerBox(record.getTimestamp().toEpochMilli(), itemManager, record.getTitle(), record.getSubTitle(),
|
||||||
hideIgnoredItems, plugin::toggleItem);
|
hideIgnoredItems, plugin::toggleItem);
|
||||||
box.combine(record);
|
box.combine(record);
|
||||||
|
|
||||||
|
|||||||
@@ -823,7 +823,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
).toArray(LootTrackerItem[]::new);
|
).toArray(LootTrackerItem[]::new);
|
||||||
|
|
||||||
trackerRecords.add(new LootTrackerRecord(record.getEventId(), record.getUsername(),
|
trackerRecords.add(new LootTrackerRecord(record.getEventId(), record.getUsername(),
|
||||||
"", drops, -1));
|
"", drops, record.getTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return trackerRecords;
|
return trackerRecords;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
package net.runelite.client.plugins.loottracker;
|
package net.runelite.client.plugins.loottracker;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import java.time.Instant;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
@@ -35,7 +36,7 @@ class LootTrackerRecord
|
|||||||
private final String subTitle;
|
private final String subTitle;
|
||||||
@SerializedName("item_records")
|
@SerializedName("item_records")
|
||||||
private final LootTrackerItem[] items;
|
private final LootTrackerItem[] items;
|
||||||
private final long timestamp;
|
private final Instant timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this record matches specified id
|
* Checks if this record matches specified id
|
||||||
|
|||||||
Reference in New Issue
Block a user