From ac27e8d17f734770514fbf4dbd1f5689a611783f Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Sat, 19 Oct 2019 03:16:05 +0100 Subject: [PATCH 1/3] loot tracker: rename price to gePrice --- .../client/plugins/loottracker/LootTrackerBox.java | 12 ++++++------ .../client/plugins/loottracker/LootTrackerItem.java | 2 +- .../client/plugins/loottracker/LootTrackerPanel.java | 2 +- .../plugins/loottracker/LootTrackerPlugin.java | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java index 2e89f8af60..55892d8e34 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java @@ -261,7 +261,7 @@ class LootTrackerBox extends JPanel continue; } - totalPrice += entry.getPrice(); + totalPrice += entry.getGePrice(); int quantity = 0; for (final LootTrackerItem i : items) @@ -277,9 +277,9 @@ class LootTrackerBox extends JPanel if (quantity > 0) { int newQuantity = entry.getQuantity() + quantity; - long pricePerItem = entry.getPrice() == 0 ? 0 : (entry.getPrice() / entry.getQuantity()); + long gePricePerItem = entry.getGePrice() == 0 ? 0 : (entry.getGePrice() / entry.getQuantity()); - items.add(new LootTrackerItem(entry.getId(), entry.getName(), newQuantity, pricePerItem * newQuantity, entry.isIgnored())); + items.add(new LootTrackerItem(entry.getId(), entry.getName(), newQuantity, gePricePerItem * newQuantity, entry.isIgnored())); } else { @@ -287,7 +287,7 @@ class LootTrackerBox extends JPanel } } - items.sort((i1, i2) -> Long.compare(i2.getPrice(), i1.getPrice())); + items.sort((i1, i2) -> Long.compare(i2.getGePrice(), i1.getGePrice())); // Calculates how many rows need to be display to fit all items final int rowSize = ((items.size() % ITEMS_PER_ROW == 0) ? 0 : 1) + items.size() / ITEMS_PER_ROW; @@ -352,8 +352,8 @@ class LootTrackerBox extends JPanel { final String name = item.getName(); final int quantity = item.getQuantity(); - final long price = item.getPrice(); + final long gePrice = item.getGePrice(); final String ignoredLabel = item.isIgnored() ? " - Ignored" : ""; - return name + " x " + quantity + " (" + QuantityFormatter.quantityToStackSize(price) + ") " + ignoredLabel; + return name + " x " + quantity + " (" + QuantityFormatter.quantityToStackSize(gePrice) + ") " + ignoredLabel; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java index feb1504681..1ecf28a229 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java @@ -38,7 +38,7 @@ class LootTrackerItem @Getter private final int quantity; @Getter - private final long price; + private final long gePrice; @Getter @Setter private boolean ignored; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java index 9dc783bab8..a4f21447f5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java @@ -613,7 +613,7 @@ class LootTrackerPanel extends PluginPanel continue; } - overallGp += item.getPrice(); + overallGp += item.getGePrice(); } if (present > 0) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index edec90e676..cc021c3650 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -636,14 +636,14 @@ public class LootTrackerPlugin extends Plugin { final ItemComposition itemComposition = itemManager.getItemComposition(itemId); final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId; - final long price = (long) itemManager.getItemPrice(realItemId) * (long) quantity; + final long gePrice = (long) itemManager.getItemPrice(realItemId) * (long) quantity; final boolean ignored = ignoredItems.contains(itemComposition.getName()); return new LootTrackerItem( itemId, itemComposition.getName(), quantity, - price, + gePrice, ignored); } From 2e6138b6f615c5d32060ca33e3c9beaafe94bf87 Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Sat, 19 Oct 2019 03:23:20 +0100 Subject: [PATCH 2/3] loot tracker: add HA prices Co-authored-by: Erik Rahka --- .../plugins/loottracker/LootTrackerBox.java | 22 ++++++++++--- .../loottracker/LootTrackerConfig.java | 10 ++++++ .../plugins/loottracker/LootTrackerItem.java | 2 ++ .../plugins/loottracker/LootTrackerPanel.java | 13 +++++--- .../loottracker/LootTrackerPlugin.java | 3 ++ .../loottracker/LootTrackerPriceType.java | 31 +++++++++++++++++++ 6 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPriceType.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java index 55892d8e34..6438e82c60 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java @@ -69,6 +69,7 @@ class LootTrackerBox extends JPanel private final ItemManager itemManager; @Getter(AccessLevel.PACKAGE) private final String id; + private final LootTrackerPriceType priceType; @Getter private final List records = new ArrayList<>(); @@ -82,12 +83,14 @@ class LootTrackerBox extends JPanel final String id, @Nullable final String subtitle, final boolean hideIgnoredItems, + final LootTrackerPriceType priceType, final BiConsumer onItemToggle) { this.id = id; this.itemManager = itemManager; this.onItemToggle = onItemToggle; this.hideIgnoredItems = hideIgnoredItems; + this.priceType = priceType; setLayout(new BorderLayout(0, 1)); setBorder(new EmptyBorder(5, 0, 0, 0)); @@ -261,7 +264,7 @@ class LootTrackerBox extends JPanel continue; } - totalPrice += entry.getGePrice(); + totalPrice += priceType == LootTrackerPriceType.HIGH_ALCHEMY ? entry.getHaPrice() : entry.getGePrice(); int quantity = 0; for (final LootTrackerItem i : items) @@ -278,8 +281,9 @@ class LootTrackerBox extends JPanel { int newQuantity = entry.getQuantity() + quantity; long gePricePerItem = entry.getGePrice() == 0 ? 0 : (entry.getGePrice() / entry.getQuantity()); + long haPricePerItem = entry.getHaPrice() == 0 ? 0 : (entry.getHaPrice() / entry.getQuantity()); - items.add(new LootTrackerItem(entry.getId(), entry.getName(), newQuantity, gePricePerItem * newQuantity, entry.isIgnored())); + items.add(new LootTrackerItem(entry.getId(), entry.getName(), newQuantity, gePricePerItem * newQuantity, haPricePerItem * newQuantity, entry.isIgnored())); } else { @@ -287,7 +291,14 @@ class LootTrackerBox extends JPanel } } - items.sort((i1, i2) -> Long.compare(i2.getGePrice(), i1.getGePrice())); + if (priceType == LootTrackerPriceType.HIGH_ALCHEMY) + { + items.sort((i1, i2) -> Long.compare(i2.getHaPrice(), i1.getHaPrice())); + } + else + { + items.sort((i1, i2) -> Long.compare(i2.getGePrice(), i1.getGePrice())); + } // Calculates how many rows need to be display to fit all items final int rowSize = ((items.size() % ITEMS_PER_ROW == 0) ? 0 : 1) + items.size() / ITEMS_PER_ROW; @@ -353,7 +364,10 @@ class LootTrackerBox extends JPanel final String name = item.getName(); final int quantity = item.getQuantity(); final long gePrice = item.getGePrice(); + final long haPrice = item.getHaPrice(); final String ignoredLabel = item.isIgnored() ? " - Ignored" : ""; - return name + " x " + quantity + " (" + QuantityFormatter.quantityToStackSize(gePrice) + ") " + ignoredLabel; + return "" + name + " x " + quantity + ignoredLabel + + "
GE: " + QuantityFormatter.quantityToStackSize(gePrice) + + "
HA: " + QuantityFormatter.quantityToStackSize(haPrice) + ""; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java index bba5994d89..1b212ae81b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java @@ -49,6 +49,16 @@ public interface LootTrackerConfig extends Config ) void setIgnoredItems(String key); + @ConfigItem( + keyName = "priceType", + name = "Price Type", + description = "What type of price to use for calculating value." + ) + default LootTrackerPriceType priceType() + { + return LootTrackerPriceType.GRAND_EXCHANGE; + } + @ConfigItem( keyName = "saveLoot", name = "Submit loot tracker data", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java index 1ecf28a229..81aedb3a4a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java @@ -40,6 +40,8 @@ class LootTrackerItem @Getter private final long gePrice; @Getter + private final long haPrice; + @Getter @Setter private boolean ignored; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java index a4f21447f5..59e23dbd96 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java @@ -518,7 +518,8 @@ class LootTrackerPanel extends PluginPanel overallPanel.setVisible(true); // Create box - final LootTrackerBox box = new LootTrackerBox(itemManager, record.getTitle(), record.getSubTitle(), hideIgnoredItems, plugin::toggleItem); + final LootTrackerBox box = new LootTrackerBox(itemManager, record.getTitle(), record.getSubTitle(), + hideIgnoredItems, config.priceType(), plugin::toggleItem); box.combine(record); // Create popup menu @@ -594,7 +595,8 @@ class LootTrackerPanel extends PluginPanel private void updateOverall() { long overallKills = 0; - long overallGp = 0; + long overallGe = 0; + long overallHa = 0; for (LootTrackerRecord record : records) { @@ -613,7 +615,8 @@ class LootTrackerPanel extends PluginPanel continue; } - overallGp += item.getGePrice(); + overallGe += item.getGePrice(); + overallHa += item.getHaPrice(); } if (present > 0) @@ -623,7 +626,9 @@ class LootTrackerPanel extends PluginPanel } overallKillsLabel.setText(htmlLabel("Total count: ", overallKills)); - overallGpLabel.setText(htmlLabel("Total value: ", overallGp)); + overallGpLabel.setText(htmlLabel("Total value: ", config.priceType() == LootTrackerPriceType.HIGH_ALCHEMY ? overallHa : overallGe)); + overallGpLabel.setToolTipText("Total GE price: " + QuantityFormatter.formatNumber(overallGe) + + "
Total HA price: " + QuantityFormatter.formatNumber(overallHa) + ""); updateCollapseText(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index cc021c3650..e1fbfb307c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -54,6 +54,7 @@ import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; +import net.runelite.api.Constants; import net.runelite.api.GameState; import net.runelite.api.InventoryID; import net.runelite.api.ItemComposition; @@ -637,6 +638,7 @@ public class LootTrackerPlugin extends Plugin final ItemComposition itemComposition = itemManager.getItemComposition(itemId); final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId; final long gePrice = (long) itemManager.getItemPrice(realItemId) * (long) quantity; + final long haPrice = (long) Math.round(itemComposition.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER) * (long) quantity; final boolean ignored = ignoredItems.contains(itemComposition.getName()); return new LootTrackerItem( @@ -644,6 +646,7 @@ public class LootTrackerPlugin extends Plugin itemComposition.getName(), quantity, gePrice, + haPrice, ignored); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPriceType.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPriceType.java new file mode 100644 index 0000000000..e23ad8c2f2 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPriceType.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 Hydrox6 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.loottracker; + +public enum LootTrackerPriceType +{ + GRAND_EXCHANGE, + HIGH_ALCHEMY +} From 5b236b920ee3330d72dc1da25e64a973dcf27b3e Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Sat, 19 Oct 2019 03:25:42 +0100 Subject: [PATCH 3/3] loot tracker: add price type display --- .../client/plugins/loottracker/LootTrackerBox.java | 11 ++++++++++- .../client/plugins/loottracker/LootTrackerConfig.java | 10 ++++++++++ .../client/plugins/loottracker/LootTrackerPanel.java | 10 ++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java index 6438e82c60..24e521d3be 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java @@ -70,6 +70,7 @@ class LootTrackerBox extends JPanel @Getter(AccessLevel.PACKAGE) private final String id; private final LootTrackerPriceType priceType; + private final boolean showPriceType; @Getter private final List records = new ArrayList<>(); @@ -84,6 +85,7 @@ class LootTrackerBox extends JPanel @Nullable final String subtitle, final boolean hideIgnoredItems, final LootTrackerPriceType priceType, + final boolean showPriceType, final BiConsumer onItemToggle) { this.id = id; @@ -91,6 +93,7 @@ class LootTrackerBox extends JPanel this.onItemToggle = onItemToggle; this.hideIgnoredItems = hideIgnoredItems; this.priceType = priceType; + this.showPriceType = showPriceType; setLayout(new BorderLayout(0, 1)); setBorder(new EmptyBorder(5, 0, 0, 0)); @@ -184,7 +187,13 @@ class LootTrackerBox extends JPanel { 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"); final long kills = getTotalKills(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java index 1b212ae81b..55fee8a6c4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java @@ -59,6 +59,16 @@ public interface LootTrackerConfig extends Config 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( keyName = "saveLoot", name = "Submit loot tracker data", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java index 59e23dbd96..6001df2923 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java @@ -519,7 +519,7 @@ class LootTrackerPanel extends PluginPanel // Create box 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); // 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)); - 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("Total GE price: " + QuantityFormatter.formatNumber(overallGe) + "
Total HA price: " + QuantityFormatter.formatNumber(overallHa) + ""); updateCollapseText();