From 3a773746dc4e63d31f01ad464b21f36f73cfff54 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Mon, 30 Apr 2018 12:35:06 +0200 Subject: [PATCH] Show GE and HA only when showing both prices - Change the price displaying to dropdown menu - Show (GE:, (HA: only when showing both prices at once, otherwise do not add label at all Depends on: #2149 Signed-off-by: Tomas Slusny --- .../grounditems/GroundItemsConfig.java | 73 ++++++++----------- .../grounditems/GroundItemsOverlay.java | 36 ++++++--- .../grounditems/config/PriceDisplayMode.java | 46 ++++++++++++ 3 files changed, 104 insertions(+), 51 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/grounditems/config/PriceDisplayMode.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index 4c8ae5710d..fb03ef19ed 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -25,13 +25,13 @@ package net.runelite.client.plugins.grounditems; +import java.awt.Color; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; - -import java.awt.Color; import net.runelite.client.plugins.grounditems.config.ItemHighlightMode; import net.runelite.client.plugins.grounditems.config.MenuHighlightMode; +import net.runelite.client.plugins.grounditems.config.PriceDisplayMode; @ConfigGroup( keyName = "grounditems", @@ -44,7 +44,7 @@ public interface GroundItemsConfig extends Config keyName = "highlightedItems", name = "Highlighted Items", description = "Configures specifically highlighted ground items. Format: (item), (item)", - position = 1 + position = 0 ) default String getHighlightItems() { @@ -62,7 +62,7 @@ public interface GroundItemsConfig extends Config keyName = "hiddenItems", name = "Hidden Items", description = "Configures hidden ground items. Format: (item), (item)", - position = 2 + position = 1 ) default String getHiddenItems() { @@ -80,51 +80,40 @@ public interface GroundItemsConfig extends Config keyName = "showHighlightedOnly", name = "Show Highlighted items only", description = "Configures whether or not to draw items only on your highlighted list", - position = 3 + position = 2 ) default boolean showHighlightedOnly() { return false; } - @ConfigItem( - keyName = "showGEPrice", - name = "Show Grand Exchange Prices", - description = "Configures whether or not to draw GE prices alongside ground items", - position = 4 - ) - default boolean showGEPrice() - { - return true; - } - - @ConfigItem( - keyName = "showHAValue", - name = "Show High Alchemy Values", - description = "Configures whether or not to draw High Alchemy values alongside ground items", - position = 5 - ) - default boolean showHAValue() - { - return false; - } - @ConfigItem( keyName = "showMenuItemQuantities", name = "Show Menu Item Quantities", description = "Configures whether or not to show the item quantities in the menu", - position = 6 + position = 3 ) default boolean showMenuItemQuantities() { return true; } + @ConfigItem( + keyName = "priceDisplayMode", + name = "Price Display Mode", + description = "Configures what price types are shown alongside of ground item name", + position = 4 + ) + default PriceDisplayMode priceDisplayMode() + { + return PriceDisplayMode.BOTH; + } + @ConfigItem( keyName = "itemHighlightMode", name = "Item Highlight Mode", description = "Configures how ground items will be highlighted", - position = 7 + position = 5 ) default ItemHighlightMode itemHighlightMode() { @@ -135,7 +124,7 @@ public interface GroundItemsConfig extends Config keyName = "menuHighlightMode", name = "Menu Highlight Mode", description = "Configures what to highlight in right-click menu", - position = 8 + position = 6 ) default MenuHighlightMode menuHighlightMode() { @@ -146,7 +135,7 @@ public interface GroundItemsConfig extends Config keyName = "hideUnderGeValue", name = "Hide < GE Value", description = "Configures hidden ground items under GE value", - position = 9 + position = 7 ) default int getHideUnderGeValue() { @@ -157,7 +146,7 @@ public interface GroundItemsConfig extends Config keyName = "hideUnderHaValue", name = "Hide < HA Value", description = "Configures hidden ground items under High Alch value", - position = 10 + position = 8 ) default int getHideUnderHAValue() { @@ -168,7 +157,7 @@ public interface GroundItemsConfig extends Config keyName = "defaultColor", name = "Default items color", description = "Configures the color for default, non-highlighted items", - position = 11 + position = 9 ) default Color defaultColor() { @@ -179,7 +168,7 @@ public interface GroundItemsConfig extends Config keyName = "highlightedColor", name = "Highlighted items color", description = "Configures the color for highlighted items", - position = 12 + position = 10 ) default Color highlightedColor() { @@ -190,7 +179,7 @@ public interface GroundItemsConfig extends Config keyName = "lowValueColor", name = "Low value items color", description = "Configures the color for low value items", - position = 13 + position = 11 ) default Color lowValueColor() { @@ -201,7 +190,7 @@ public interface GroundItemsConfig extends Config keyName = "lowValuePrice", name = "Low value price", description = "Configures the start price for low value items", - position = 14 + position = 12 ) default int lowValuePrice() { @@ -212,7 +201,7 @@ public interface GroundItemsConfig extends Config keyName = "mediumValueColor", name = "Medium value items color", description = "Configures the color for medium value items", - position = 15 + position = 13 ) default Color mediumValueColor() { @@ -223,7 +212,7 @@ public interface GroundItemsConfig extends Config keyName = "mediumValuePrice", name = "Medium value price", description = "Configures the start price for medium value items", - position = 16 + position = 14 ) default int mediumValuePrice() { @@ -234,7 +223,7 @@ public interface GroundItemsConfig extends Config keyName = "highValueColor", name = "High value items color", description = "Configures the color for high value items", - position = 17 + position = 15 ) default Color highValueColor() { @@ -245,7 +234,7 @@ public interface GroundItemsConfig extends Config keyName = "highValuePrice", name = "High value price", description = "Configures the start price for high value items", - position = 18 + position = 16 ) default int highValuePrice() { @@ -256,7 +245,7 @@ public interface GroundItemsConfig extends Config keyName = "insaneValueColor", name = "Insane value items color", description = "Configures the color for insane value items", - position = 19 + position = 17 ) default Color insaneValueColor() { @@ -267,7 +256,7 @@ public interface GroundItemsConfig extends Config keyName = "insaneValuePrice", name = "Insane value price", description = "Configures the start price for insane value items", - position = 20 + position = 18 ) default int insaneValuePrice() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java index 9d5008b9cd..ff35177277 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java @@ -41,6 +41,7 @@ import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; import net.runelite.client.game.ItemManager; import static net.runelite.client.plugins.grounditems.config.ItemHighlightMode.MENU; +import net.runelite.client.plugins.grounditems.config.PriceDisplayMode; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; @@ -163,18 +164,35 @@ public class GroundItemsOverlay extends Overlay } } - if (config.showGEPrice() && item.getGePrice() > 0) + if (config.priceDisplayMode() == PriceDisplayMode.BOTH) { - itemStringBuilder.append(" (EX: ") - .append(StackFormatter.quantityToStackSize(item.getGePrice())) - .append(" gp)"); - } + if (item.getGePrice() > 0) + { + itemStringBuilder.append(" (EX: ") + .append(StackFormatter.quantityToStackSize(item.getGePrice())) + .append(" gp)"); + } - if (config.showHAValue() && item.getHaPrice() > 0) + if (item.getHaPrice() > 0) + { + itemStringBuilder.append(" (HA: ") + .append(StackFormatter.quantityToStackSize(item.getHaPrice())) + .append(" gp)"); + } + } + else if (config.priceDisplayMode() != PriceDisplayMode.OFF) { - itemStringBuilder.append(" (HA: ") - .append(StackFormatter.quantityToStackSize(item.getHaPrice())) - .append(" gp)"); + final int price = config.priceDisplayMode() == PriceDisplayMode.GE + ? item.getGePrice() + : item.getHaPrice(); + + if (price > 0) + { + itemStringBuilder + .append(" (") + .append(StackFormatter.quantityToStackSize(price)) + .append(" gp)"); + } } final String itemString = itemStringBuilder.toString(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/config/PriceDisplayMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/config/PriceDisplayMode.java new file mode 100644 index 0000000000..d98fecddeb --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/config/PriceDisplayMode.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018, Tomas Slusny + * 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.grounditems.config; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum PriceDisplayMode +{ + HA("High Alchemy"), + GE("Grand Exchange"), + BOTH("Both"), + OFF("Off"); + + private final String name; + + @Override + public String toString() + { + return name; + } +}