From 2ccb0bb8cdd547ddb5099be2533ab8093086980f Mon Sep 17 00:00:00 2001 From: Tememexas <40266954+Tememexas@users.noreply.github.com> Date: Wed, 20 Jun 2018 11:15:09 +0300 Subject: [PATCH] Add option to highlight tiles under ground items (#3895) Add new option to GroundItemConfig to highlight tiles under ground items based on color configuration. --- .../grounditems/GroundItemsConfig.java | 43 ++++++++++++------- .../grounditems/GroundItemsOverlay.java | 28 ++++++++++-- 2 files changed, 51 insertions(+), 20 deletions(-) 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 0dbb390df3..0aa8d1471e 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 @@ -119,12 +119,23 @@ public interface GroundItemsConfig extends Config { return false; } + + @ConfigItem( + keyName = "highlightTiles", + name = "Highlight Tiles", + description = "Configures whether or not to highlight tiles containing ground items", + position = 6 + ) + default boolean highlightTiles() + { + return false; + } @ConfigItem( keyName = "priceDisplayMode", name = "Price Display Mode", description = "Configures what price types are shown alongside of ground item name", - position = 6 + position = 7 ) default PriceDisplayMode priceDisplayMode() { @@ -135,7 +146,7 @@ public interface GroundItemsConfig extends Config keyName = "itemHighlightMode", name = "Item Highlight Mode", description = "Configures how ground items will be highlighted", - position = 7 + position = 8 ) default ItemHighlightMode itemHighlightMode() { @@ -146,7 +157,7 @@ public interface GroundItemsConfig extends Config keyName = "menuHighlightMode", name = "Menu Highlight Mode", description = "Configures what to highlight in right-click menu", - position = 8 + position = 9 ) default MenuHighlightMode menuHighlightMode() { @@ -157,7 +168,7 @@ public interface GroundItemsConfig extends Config keyName = "highlightOverValue2", name = "Highlight > Value", description = "Configures highlighted ground items over either GE or HA value", - position = 9 + position = 10 ) default int getHighlightOverValue() { @@ -168,7 +179,7 @@ public interface GroundItemsConfig extends Config keyName = "hideUnderValue", name = "Hide < Value", description = "Configures hidden ground items under both GE and HA value", - position = 10 + position = 11 ) default int getHideUnderValue() { @@ -179,7 +190,7 @@ public interface GroundItemsConfig extends Config keyName = "defaultColor", name = "Default items color", description = "Configures the color for default, non-highlighted items", - position = 11 + position = 12 ) default Color defaultColor() { @@ -190,7 +201,7 @@ public interface GroundItemsConfig extends Config keyName = "highlightedColor", name = "Highlighted items color", description = "Configures the color for highlighted items", - position = 12 + position = 13 ) default Color highlightedColor() { @@ -201,7 +212,7 @@ public interface GroundItemsConfig extends Config keyName = "hiddenColor", name = "Hidden items color", description = "Configures the color for hidden items in right-click menu and when holding ALT", - position = 13 + position = 14 ) default Color hiddenColor() { @@ -212,7 +223,7 @@ public interface GroundItemsConfig extends Config keyName = "lowValueColor", name = "Low value items color", description = "Configures the color for low value items", - position = 14 + position = 15 ) default Color lowValueColor() { @@ -223,7 +234,7 @@ public interface GroundItemsConfig extends Config keyName = "lowValuePrice", name = "Low value price", description = "Configures the start price for low value items", - position = 15 + position = 16 ) default int lowValuePrice() { @@ -234,7 +245,7 @@ public interface GroundItemsConfig extends Config keyName = "mediumValueColor", name = "Medium value items color", description = "Configures the color for medium value items", - position = 16 + position = 17 ) default Color mediumValueColor() { @@ -245,7 +256,7 @@ public interface GroundItemsConfig extends Config keyName = "mediumValuePrice", name = "Medium value price", description = "Configures the start price for medium value items", - position = 17 + position = 18 ) default int mediumValuePrice() { @@ -256,7 +267,7 @@ public interface GroundItemsConfig extends Config keyName = "highValueColor", name = "High value items color", description = "Configures the color for high value items", - position = 18 + position = 19 ) default Color highValueColor() { @@ -267,7 +278,7 @@ public interface GroundItemsConfig extends Config keyName = "highValuePrice", name = "High value price", description = "Configures the start price for high value items", - position = 19 + position = 20 ) default int highValuePrice() { @@ -278,7 +289,7 @@ public interface GroundItemsConfig extends Config keyName = "insaneValueColor", name = "Insane value items color", description = "Configures the color for insane value items", - position = 20 + position = 21 ) default Color insaneValueColor() { @@ -289,7 +300,7 @@ public interface GroundItemsConfig extends Config keyName = "insaneValuePrice", name = "Insane value price", description = "Configures the start price for insane value items", - position = 21 + position = 22 ) 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 01dec4de24..20bf6ad373 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 @@ -29,6 +29,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; +import java.awt.Polygon; import java.awt.Rectangle; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; @@ -48,6 +49,7 @@ 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; +import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.components.BackgroundComponent; import net.runelite.client.ui.overlay.components.TextComponent; import net.runelite.client.util.StackFormatter; @@ -77,7 +79,7 @@ public class GroundItemsOverlay extends Overlay private final ItemManager itemManager; @Inject - public GroundItemsOverlay(Client client, GroundItemsPlugin plugin, GroundItemsConfig config, ItemManager itemManager) + private GroundItemsOverlay(Client client, GroundItemsPlugin plugin, GroundItemsConfig config, ItemManager itemManager) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); @@ -90,7 +92,9 @@ public class GroundItemsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isHotKeyPressed() && config.itemHighlightMode() == MENU) + final boolean dontShowOverlay = config.itemHighlightMode() == MENU && !plugin.isHotKeyPressed(); + + if (dontShowOverlay && !config.highlightTiles()) { return null; } @@ -200,6 +204,22 @@ public class GroundItemsOverlay extends Overlay } final Color color = plugin.getItemColor(highlighted, hidden); + + if (config.highlightTiles()) + { + final Polygon poly = Perspective.getCanvasTilePoly(client, groundPoint); + + if (poly != null) + { + OverlayUtil.renderPolygon(graphics, poly, color); + } + } + + if (dontShowOverlay) + { + continue; + } + itemStringBuilder.append(item.getName()); if (item.getQuantity() > 1) @@ -211,8 +231,8 @@ public class GroundItemsOverlay extends Overlay else { itemStringBuilder.append(" (") - .append(StackFormatter.quantityToStackSize(item.getQuantity())) - .append(")"); + .append(StackFormatter.quantityToStackSize(item.getQuantity())) + .append(")"); } }