loot tracker: add price type display

This commit is contained in:
Hydrox6
2019-10-19 03:25:42 +01:00
parent 2e6138b6f6
commit 5b236b920e
3 changed files with 28 additions and 3 deletions

View File

@@ -70,6 +70,7 @@ class LootTrackerBox extends JPanel
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final String id; private final String id;
private final LootTrackerPriceType priceType; private final LootTrackerPriceType priceType;
private final boolean showPriceType;
@Getter @Getter
private final List<LootTrackerRecord> records = new ArrayList<>(); private final List<LootTrackerRecord> records = new ArrayList<>();
@@ -84,6 +85,7 @@ class LootTrackerBox extends JPanel
@Nullable final String subtitle, @Nullable final String subtitle,
final boolean hideIgnoredItems, final boolean hideIgnoredItems,
final LootTrackerPriceType priceType, final LootTrackerPriceType priceType,
final boolean showPriceType,
final BiConsumer<String, Boolean> onItemToggle) final BiConsumer<String, Boolean> onItemToggle)
{ {
this.id = id; this.id = id;
@@ -91,6 +93,7 @@ class LootTrackerBox extends JPanel
this.onItemToggle = onItemToggle; this.onItemToggle = onItemToggle;
this.hideIgnoredItems = hideIgnoredItems; this.hideIgnoredItems = hideIgnoredItems;
this.priceType = priceType; this.priceType = priceType;
this.showPriceType = showPriceType;
setLayout(new BorderLayout(0, 1)); setLayout(new BorderLayout(0, 1));
setBorder(new EmptyBorder(5, 0, 0, 0)); setBorder(new EmptyBorder(5, 0, 0, 0));
@@ -184,7 +187,13 @@ class LootTrackerBox extends JPanel
{ {
buildItems(); buildItems();
priceLabel.setText(QuantityFormatter.quantityToStackSize(totalPrice) + " gp"); String priceTypeString = " ";
if (showPriceType)
{
priceTypeString = priceType == LootTrackerPriceType.HIGH_ALCHEMY ? "HA: " : "GE: ";
}
priceLabel.setText(priceTypeString + QuantityFormatter.quantityToStackSize(totalPrice) + " gp");
priceLabel.setToolTipText(QuantityFormatter.formatNumber(totalPrice) + " gp"); priceLabel.setToolTipText(QuantityFormatter.formatNumber(totalPrice) + " gp");
final long kills = getTotalKills(); final long kills = getTotalKills();

View File

@@ -59,6 +59,16 @@ public interface LootTrackerConfig extends Config
return LootTrackerPriceType.GRAND_EXCHANGE; return LootTrackerPriceType.GRAND_EXCHANGE;
} }
@ConfigItem(
keyName = "showPriceType",
name = "Show Price Type",
description = "Whether to show a GE: or HA: next to the total values in the tracker"
)
default boolean showPriceType()
{
return false;
}
@ConfigItem( @ConfigItem(
keyName = "saveLoot", keyName = "saveLoot",
name = "Submit loot tracker data", name = "Submit loot tracker data",

View File

@@ -519,7 +519,7 @@ class LootTrackerPanel extends PluginPanel
// Create box // Create box
final LootTrackerBox box = new LootTrackerBox(itemManager, record.getTitle(), record.getSubTitle(), final LootTrackerBox box = new LootTrackerBox(itemManager, record.getTitle(), record.getSubTitle(),
hideIgnoredItems, config.priceType(), plugin::toggleItem); hideIgnoredItems, config.priceType(), config.showPriceType(), plugin::toggleItem);
box.combine(record); box.combine(record);
// Create popup menu // Create popup menu
@@ -625,8 +625,14 @@ class LootTrackerPanel extends PluginPanel
} }
} }
String priceType = "";
if (config.showPriceType())
{
priceType = config.priceType() == LootTrackerPriceType.HIGH_ALCHEMY ? "HA " : "GE ";
}
overallKillsLabel.setText(htmlLabel("Total count: ", overallKills)); overallKillsLabel.setText(htmlLabel("Total count: ", overallKills));
overallGpLabel.setText(htmlLabel("Total value: ", config.priceType() == LootTrackerPriceType.HIGH_ALCHEMY ? overallHa : overallGe)); overallGpLabel.setText(htmlLabel("Total " + priceType + "value: ", config.priceType() == LootTrackerPriceType.HIGH_ALCHEMY ? overallHa : overallGe));
overallGpLabel.setToolTipText("<html>Total GE price: " + QuantityFormatter.formatNumber(overallGe) overallGpLabel.setToolTipText("<html>Total GE price: " + QuantityFormatter.formatNumber(overallGe)
+ "<br>Total HA price: " + QuantityFormatter.formatNumber(overallHa) + "</html>"); + "<br>Total HA price: " + QuantityFormatter.formatNumber(overallHa) + "</html>");
updateCollapseText(); updateCollapseText();