adds support for date and adds date display to loot tracker panel

Signed-off-by: PKLite <stonewall@pklite.xyz>
This commit is contained in:
PKLite
2019-06-26 03:39:05 -04:00
parent 53cab8d233
commit 2c79d051ff
5 changed files with 19 additions and 5 deletions

View File

@@ -17,7 +17,7 @@ public enum LootRecordSortType implements Comparator<LootTrackerRecord>
@Override
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

View File

@@ -32,6 +32,7 @@ import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.function.BiConsumer;
import javax.annotation.Nullable;
@@ -59,6 +60,7 @@ class LootTrackerBox extends JPanel
private final JPanel itemContainer = new JPanel();
private final JLabel priceLabel = new JLabel();
private final JLabel subTitleLabel = new JLabel();
private final JLabel dateLabel = new JLabel();
private final ItemManager itemManager;
@Getter(AccessLevel.PACKAGE)
private final String id;
@@ -69,14 +71,17 @@ class LootTrackerBox extends JPanel
private long totalPrice;
private boolean hideIgnoredItems;
private BiConsumer<String, Boolean> onItemToggle;
private final long timeStamp;
LootTrackerBox(
final long timeStamp,
final ItemManager itemManager,
final String id,
@Nullable final String subtitle,
final boolean hideIgnoredItems,
final BiConsumer<String, Boolean> onItemToggle)
{
this.timeStamp = timeStamp;
this.id = id;
this.itemManager = itemManager;
this.onItemToggle = onItemToggle;
@@ -99,6 +104,12 @@ class LootTrackerBox extends JPanel
subTitleLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
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))
{
subTitleLabel.setText(subtitle);
@@ -110,6 +121,7 @@ class LootTrackerBox extends JPanel
add(logTitle, BorderLayout.NORTH);
add(itemContainer, BorderLayout.CENTER);
}
/**

View File

@@ -32,6 +32,7 @@ import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
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)
{
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);
LootTrackerBox box = buildBox(record);
if (box != null)
@@ -545,7 +546,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(record.getTimestamp().toEpochMilli(), itemManager, record.getTitle(), record.getSubTitle(),
hideIgnoredItems, plugin::toggleItem);
box.combine(record);

View File

@@ -823,7 +823,7 @@ public class LootTrackerPlugin extends Plugin
).toArray(LootTrackerItem[]::new);
trackerRecords.add(new LootTrackerRecord(record.getEventId(), record.getUsername(),
"", drops, -1));
"", drops, record.getTime()));
}
return trackerRecords;

View File

@@ -25,6 +25,7 @@
package net.runelite.client.plugins.loottracker;
import com.google.gson.annotations.SerializedName;
import java.time.Instant;
import lombok.Value;
@Value
@@ -35,7 +36,7 @@ class LootTrackerRecord
private final String subTitle;
@SerializedName("item_records")
private final LootTrackerItem[] items;
private final long timestamp;
private final Instant timestamp;
/**
* Checks if this record matches specified id