From d4078a95553bee262f0d5ca032cea49dfca5ca3e Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 11 Jun 2021 12:47:39 -0400 Subject: [PATCH] ground markers: add configurable border width --- .../client/plugins/config/ConfigPanel.java | 14 ++++++++++++++ .../plugins/groundmarkers/GroundMarkerConfig.java | 12 +++++++++++- .../plugins/groundmarkers/GroundMarkerOverlay.java | 14 +++++++++++--- .../runelite/client/ui/overlay/OverlayUtil.java | 11 ++++++----- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java index b72286e3b1..f451debee8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java @@ -375,6 +375,20 @@ class ConfigPanel extends PluginPanel item.add(spinner, BorderLayout.EAST); } + else if (cid.getType() == double.class) + { + double value = configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName(), double.class); + + SpinnerModel model = new SpinnerNumberModel(value, 0, Double.MAX_VALUE, 0.1); + JSpinner spinner = new JSpinner(model); + Component editor = spinner.getEditor(); + JFormattedTextField spinnerTextField = ((JSpinner.DefaultEditor) editor).getTextField(); + spinnerTextField.setColumns(SPINNER_FIELD_WIDTH); + spinner.addChangeListener(ce -> changeConfiguration(spinner, cd, cid)); + + item.add(spinner, BorderLayout.EAST); + } + if (cid.getType() == String.class) { JTextComponent textField; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerConfig.java index 7a6538e22d..c577f72f35 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerConfig.java @@ -41,7 +41,7 @@ public interface GroundMarkerConfig extends Config @Alpha @ConfigItem( keyName = "markerColor", - name = "Color of the tile", + name = "Tile color", description = "Configures the color of marked tile" ) default Color markerColor() @@ -88,4 +88,14 @@ public interface GroundMarkerConfig extends Config { return false; } + + @ConfigItem( + keyName = "borderWidth", + name = "Border Width", + description = "Width of the marked tile border" + ) + default double borderWidth() + { + return 2; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerOverlay.java index 31d3e1bf08..266e89c9b5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerOverlay.java @@ -26,10 +26,12 @@ package net.runelite.client.plugins.groundmarkers; import com.google.common.base.Strings; +import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; +import java.awt.Stroke; import java.util.Collection; import javax.annotation.Nullable; import javax.inject.Inject; @@ -67,6 +69,12 @@ public class GroundMarkerOverlay extends Overlay public Dimension render(Graphics2D graphics) { final Collection points = plugin.getPoints(); + if (points.isEmpty()) + { + return null; + } + + Stroke stroke = new BasicStroke((float) config.borderWidth()); for (final ColorTileMarker point : points) { WorldPoint worldPoint = point.getWorldPoint(); @@ -82,13 +90,13 @@ public class GroundMarkerOverlay extends Overlay tileColor = config.markerColor(); } - drawTile(graphics, worldPoint, tileColor, point.getLabel()); + drawTile(graphics, worldPoint, tileColor, point.getLabel(), stroke); } return null; } - private void drawTile(Graphics2D graphics, WorldPoint point, Color color, @Nullable String label) + private void drawTile(Graphics2D graphics, WorldPoint point, Color color, @Nullable String label, Stroke borderStroke) { WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation(); @@ -106,7 +114,7 @@ public class GroundMarkerOverlay extends Overlay Polygon poly = Perspective.getCanvasTilePoly(client, lp); if (poly != null) { - OverlayUtil.renderPolygon(graphics, poly, color); + OverlayUtil.renderPolygon(graphics, poly, color, borderStroke); } if (!Strings.isNullOrEmpty(label)) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java index 7a59965f68..1caa3a7c01 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java @@ -42,20 +42,21 @@ import net.runelite.api.TileObject; import net.runelite.api.coords.LocalPoint; import net.runelite.client.util.ColorUtil; - -/** - * Created by Kyle Fricilone on Jun 09, 2017. - */ public class OverlayUtil { private static final int MINIMAP_DOT_RADIUS = 4; private static final double UNIT = Math.PI / 1024.0d; public static void renderPolygon(Graphics2D graphics, Shape poly, Color color) + { + renderPolygon(graphics, poly, color, new BasicStroke(2)); + } + + public static void renderPolygon(Graphics2D graphics, Shape poly, Color color, Stroke borderStroke) { graphics.setColor(color); final Stroke originalStroke = graphics.getStroke(); - graphics.setStroke(new BasicStroke(2)); + graphics.setStroke(borderStroke); graphics.draw(poly); graphics.setColor(new Color(0, 0, 0, 50)); graphics.fill(poly);