loot tracker: add HA prices
Co-authored-by: Erik Rahka <erikrahka@gmail.com>
This commit is contained in:
@@ -69,6 +69,7 @@ class LootTrackerBox extends JPanel
|
|||||||
private final ItemManager itemManager;
|
private final ItemManager itemManager;
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private final String id;
|
private final String id;
|
||||||
|
private final LootTrackerPriceType priceType;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final List<LootTrackerRecord> records = new ArrayList<>();
|
private final List<LootTrackerRecord> records = new ArrayList<>();
|
||||||
@@ -82,12 +83,14 @@ class LootTrackerBox extends JPanel
|
|||||||
final String id,
|
final String id,
|
||||||
@Nullable final String subtitle,
|
@Nullable final String subtitle,
|
||||||
final boolean hideIgnoredItems,
|
final boolean hideIgnoredItems,
|
||||||
|
final LootTrackerPriceType priceType,
|
||||||
final BiConsumer<String, Boolean> onItemToggle)
|
final BiConsumer<String, Boolean> onItemToggle)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.itemManager = itemManager;
|
this.itemManager = itemManager;
|
||||||
this.onItemToggle = onItemToggle;
|
this.onItemToggle = onItemToggle;
|
||||||
this.hideIgnoredItems = hideIgnoredItems;
|
this.hideIgnoredItems = hideIgnoredItems;
|
||||||
|
this.priceType = priceType;
|
||||||
|
|
||||||
setLayout(new BorderLayout(0, 1));
|
setLayout(new BorderLayout(0, 1));
|
||||||
setBorder(new EmptyBorder(5, 0, 0, 0));
|
setBorder(new EmptyBorder(5, 0, 0, 0));
|
||||||
@@ -261,7 +264,7 @@ class LootTrackerBox extends JPanel
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
totalPrice += entry.getGePrice();
|
totalPrice += priceType == LootTrackerPriceType.HIGH_ALCHEMY ? entry.getHaPrice() : entry.getGePrice();
|
||||||
|
|
||||||
int quantity = 0;
|
int quantity = 0;
|
||||||
for (final LootTrackerItem i : items)
|
for (final LootTrackerItem i : items)
|
||||||
@@ -278,8 +281,9 @@ class LootTrackerBox extends JPanel
|
|||||||
{
|
{
|
||||||
int newQuantity = entry.getQuantity() + quantity;
|
int newQuantity = entry.getQuantity() + quantity;
|
||||||
long gePricePerItem = entry.getGePrice() == 0 ? 0 : (entry.getGePrice() / entry.getQuantity());
|
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
|
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
|
// 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;
|
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 String name = item.getName();
|
||||||
final int quantity = item.getQuantity();
|
final int quantity = item.getQuantity();
|
||||||
final long gePrice = item.getGePrice();
|
final long gePrice = item.getGePrice();
|
||||||
|
final long haPrice = item.getHaPrice();
|
||||||
final String ignoredLabel = item.isIgnored() ? " - Ignored" : "";
|
final String ignoredLabel = item.isIgnored() ? " - Ignored" : "";
|
||||||
return name + " x " + quantity + " (" + QuantityFormatter.quantityToStackSize(gePrice) + ") " + ignoredLabel;
|
return "<html>" + name + " x " + quantity + ignoredLabel
|
||||||
|
+ "<br>GE: " + QuantityFormatter.quantityToStackSize(gePrice)
|
||||||
|
+ "<br>HA: " + QuantityFormatter.quantityToStackSize(haPrice) + "</html>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,16 @@ public interface LootTrackerConfig extends Config
|
|||||||
)
|
)
|
||||||
void setIgnoredItems(String key);
|
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(
|
@ConfigItem(
|
||||||
keyName = "saveLoot",
|
keyName = "saveLoot",
|
||||||
name = "Submit loot tracker data",
|
name = "Submit loot tracker data",
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ class LootTrackerItem
|
|||||||
@Getter
|
@Getter
|
||||||
private final long gePrice;
|
private final long gePrice;
|
||||||
@Getter
|
@Getter
|
||||||
|
private final long haPrice;
|
||||||
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private boolean ignored;
|
private boolean ignored;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -518,7 +518,8 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
overallPanel.setVisible(true);
|
overallPanel.setVisible(true);
|
||||||
|
|
||||||
// Create box
|
// 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);
|
box.combine(record);
|
||||||
|
|
||||||
// Create popup menu
|
// Create popup menu
|
||||||
@@ -594,7 +595,8 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
private void updateOverall()
|
private void updateOverall()
|
||||||
{
|
{
|
||||||
long overallKills = 0;
|
long overallKills = 0;
|
||||||
long overallGp = 0;
|
long overallGe = 0;
|
||||||
|
long overallHa = 0;
|
||||||
|
|
||||||
for (LootTrackerRecord record : records)
|
for (LootTrackerRecord record : records)
|
||||||
{
|
{
|
||||||
@@ -613,7 +615,8 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
overallGp += item.getGePrice();
|
overallGe += item.getGePrice();
|
||||||
|
overallHa += item.getHaPrice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (present > 0)
|
if (present > 0)
|
||||||
@@ -623,7 +626,9 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
overallKillsLabel.setText(htmlLabel("Total count: ", overallKills));
|
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("<html>Total GE price: " + QuantityFormatter.formatNumber(overallGe)
|
||||||
|
+ "<br>Total HA price: " + QuantityFormatter.formatNumber(overallHa) + "</html>");
|
||||||
updateCollapseText();
|
updateCollapseText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import lombok.Getter;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.Constants;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.InventoryID;
|
import net.runelite.api.InventoryID;
|
||||||
import net.runelite.api.ItemComposition;
|
import net.runelite.api.ItemComposition;
|
||||||
@@ -637,6 +638,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
|
||||||
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId;
|
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId;
|
||||||
final long gePrice = (long) itemManager.getItemPrice(realItemId) * (long) quantity;
|
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());
|
final boolean ignored = ignoredItems.contains(itemComposition.getName());
|
||||||
|
|
||||||
return new LootTrackerItem(
|
return new LootTrackerItem(
|
||||||
@@ -644,6 +646,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
itemComposition.getName(),
|
itemComposition.getName(),
|
||||||
quantity,
|
quantity,
|
||||||
gePrice,
|
gePrice,
|
||||||
|
haPrice,
|
||||||
ignored);
|
ignored);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Hydrox6 <ikada@protonmail.ch>
|
||||||
|
* 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user