Adds the date filter, need to make changing it update the total
Signed-off-by: PKLite <stonewall@pklite.xyz>
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* ******************************************************************************
|
||||||
|
* * Copyright (c) 2019 RuneLitePlus
|
||||||
|
* * Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file.
|
||||||
|
* * If there are any questions comments, or feedback about this software, please direct all inquiries directly to the file authors:
|
||||||
|
* * ST0NEWALL#9112
|
||||||
|
* * RuneLitePlus Discord: https://discord.gg/Q7wFtCe
|
||||||
|
* * RuneLitePlus website: https://runelitepl.us
|
||||||
|
* *****************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.runelite.client.plugins.loottracker;
|
||||||
|
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public enum LootRecordDateFilter
|
||||||
|
{
|
||||||
|
HOUR("Hour", Duration.ofHours(1)),
|
||||||
|
DAY("Day", Duration.ofDays(1)),
|
||||||
|
WEEK("Week", Duration.ofDays(7)),
|
||||||
|
MONTH("Month", Duration.ofDays(30)),
|
||||||
|
YEAR("Year", Duration.ofDays(365)),
|
||||||
|
ALL("All", Duration.ZERO);
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
@Getter
|
||||||
|
private final Duration duration;
|
||||||
|
|
||||||
|
private LootRecordDateFilter(String name, Duration duration)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,12 +34,15 @@ import java.awt.event.MouseEvent;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Vector;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@@ -104,6 +107,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
private final JLabel singleLootBtn = new JLabel();
|
private final JLabel singleLootBtn = new JLabel();
|
||||||
private final JLabel groupedLootBtn = new JLabel();
|
private final JLabel groupedLootBtn = new JLabel();
|
||||||
private final JLabel resetIcon = new JLabel();
|
private final JLabel resetIcon = new JLabel();
|
||||||
|
private JComboBox dateFilterComboBox = new JComboBox<>(new Vector<LootRecordDateFilter>(Arrays.asList(LootRecordDateFilter.values())));
|
||||||
|
|
||||||
// Log collection
|
// Log collection
|
||||||
private final List<LootTrackerRecord> records = new ArrayList<>();
|
private final List<LootTrackerRecord> records = new ArrayList<>();
|
||||||
@@ -114,6 +118,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
private final LootTrackerConfig config;
|
private final LootTrackerConfig config;
|
||||||
|
|
||||||
private boolean groupLoot;
|
private boolean groupLoot;
|
||||||
|
private LootRecordDateFilter dateFilter = LootRecordDateFilter.ALL;
|
||||||
private boolean hideIgnoredItems;
|
private boolean hideIgnoredItems;
|
||||||
private String currentView;
|
private String currentView;
|
||||||
|
|
||||||
@@ -176,7 +181,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
actionsContainer.setBorder(new EmptyBorder(5, 5, 5, 10));
|
actionsContainer.setBorder(new EmptyBorder(5, 5, 5, 10));
|
||||||
actionsContainer.setVisible(false);
|
actionsContainer.setVisible(false);
|
||||||
|
|
||||||
final JPanel viewControls = new JPanel(new GridLayout(1, 4, 10, 0));
|
final JPanel viewControls = new JPanel(new GridLayout(1, 5, 5, 0));
|
||||||
viewControls.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
viewControls.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
|
|
||||||
singleLootBtn.setIcon(SINGLE_LOOT_VIEW);
|
singleLootBtn.setIcon(SINGLE_LOOT_VIEW);
|
||||||
@@ -271,6 +276,19 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dateFilterComboBox.setSelectedItem(LootRecordDateFilter.ALL);
|
||||||
|
dateFilterComboBox.setToolTipText("Filter the displayed loot records by date");
|
||||||
|
dateFilterComboBox.setMaximumSize(new Dimension(15, 0));
|
||||||
|
dateFilterComboBox.setMaximumRowCount(3);
|
||||||
|
dateFilterComboBox.addItemListener(e ->
|
||||||
|
{
|
||||||
|
final LootRecordDateFilter dateFilterSelected = (LootRecordDateFilter) e.getItem();
|
||||||
|
dateFilter = dateFilterSelected;
|
||||||
|
rebuild();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
//viewControls.add(dateFilterComboBox);
|
||||||
viewControls.add(resetIcon);
|
viewControls.add(resetIcon);
|
||||||
viewControls.add(groupedLootBtn);
|
viewControls.add(groupedLootBtn);
|
||||||
viewControls.add(singleLootBtn);
|
viewControls.add(singleLootBtn);
|
||||||
@@ -312,6 +330,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
leftTitleContainer.add(backBtn, BorderLayout.WEST);
|
leftTitleContainer.add(backBtn, BorderLayout.WEST);
|
||||||
leftTitleContainer.add(detailsTitle, BorderLayout.CENTER);
|
leftTitleContainer.add(detailsTitle, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
actionsContainer.add(dateFilterComboBox);
|
||||||
actionsContainer.add(leftTitleContainer, BorderLayout.WEST);
|
actionsContainer.add(leftTitleContainer, BorderLayout.WEST);
|
||||||
actionsContainer.add(viewControls, BorderLayout.EAST);
|
actionsContainer.add(viewControls, BorderLayout.EAST);
|
||||||
|
|
||||||
@@ -494,7 +513,15 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buildBox(records.get(i));
|
if (this.dateFilter.equals(LootRecordDateFilter.ALL))
|
||||||
|
{
|
||||||
|
buildBox(records.get(i));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Instant.now().toEpochMilli() - records.get(i).getTimestamp().toEpochMilli() <= this.dateFilter.getDuration().toMillis())
|
||||||
|
{
|
||||||
|
buildBox(records.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
boxes.forEach(LootTrackerBox::rebuild);
|
boxes.forEach(LootTrackerBox::rebuild);
|
||||||
@@ -527,6 +554,10 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.dateFilter.equals(LootRecordDateFilter.ALL))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
// Group all similar loot together
|
// Group all similar loot together
|
||||||
if (groupLoot)
|
if (groupLoot)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user