From 33ff3a2749372a1d98329d2c4aeddbeadf19434e Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 11 Aug 2021 16:51:14 -0400 Subject: [PATCH] npc indicators: add fill color config --- .../npchighlight/NpcIndicatorsConfig.java | 19 +++++++++-- .../npchighlight/NpcIndicatorsPlugin.java | 2 +- .../npchighlight/NpcMinimapOverlay.java | 2 +- .../plugins/npchighlight/NpcSceneOverlay.java | 32 ++++++++----------- .../npchighlight/NpcIndicatorsPluginTest.java | 2 +- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java index ba45c310ef..6c24e004fc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java @@ -95,16 +95,29 @@ public interface NpcIndicatorsConfig extends Config position = 4, keyName = "npcColor", name = "Highlight Color", - description = "Color of the NPC highlight", + description = "Color of the NPC highlight border, menu, and text", section = renderStyleSection ) - default Color getHighlightColor() + default Color highlightColor() { return Color.CYAN; } + @Alpha @ConfigItem( position = 5, + keyName = "fillColor", + name = "Fill Color", + description = "Color of the NPC highlight fill", + section = renderStyleSection + ) + default Color fillColor() + { + return new Color(0, 255, 255, 20); + } + + @ConfigItem( + position = 6, keyName = "borderWidth", name = "Border Width", description = "Width of the highlighted NPC border", @@ -116,7 +129,7 @@ public interface NpcIndicatorsConfig extends Config } @ConfigItem( - position = 6, + position = 7, keyName = "outlineFeather", name = "Outline feather", description = "Specify between 0-4 how much of the model outline should be faded", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index de84c15666..7ebe470d97 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -267,7 +267,7 @@ public class NpcIndicatorsPlugin extends Plugin implements NpcIndicatorsService if (color == null && highlightedNpcs.contains(npc) && config.highlightMenuNames() && (!npc.isDead() || !config.ignoreDeadNpcs())) { - color = config.getHighlightColor(); + color = config.highlightColor(); } if (color != null) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java index e1fd961216..52a17975a7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java @@ -57,7 +57,7 @@ public class NpcMinimapOverlay extends Overlay { for (NPC npc : plugin.getHighlightedNpcs()) { - renderNpcOverlay(graphics, npc, Text.removeTags(npc.getName()), config.getHighlightColor()); + renderNpcOverlay(graphics, npc, Text.removeTags(npc.getName()), config.highlightColor()); } return null; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java index 7b7bf9b461..8c2b2b3b06 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java @@ -49,7 +49,6 @@ 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.outline.ModelOutlineRenderer; -import net.runelite.client.util.ColorUtil; import net.runelite.client.util.Text; public class NpcSceneOverlay extends Overlay @@ -92,7 +91,7 @@ public class NpcSceneOverlay extends Overlay for (NPC npc : plugin.getHighlightedNpcs()) { - renderNpcOverlay(graphics, npc, config.getHighlightColor()); + renderNpcOverlay(graphics, npc); } return null; @@ -113,18 +112,12 @@ public class NpcSceneOverlay extends Overlay return; } - final Color color = config.getHighlightColor(); - final LocalPoint centerLp = new LocalPoint( lp.getX() + Perspective.LOCAL_TILE_SIZE * (npc.getNpcSize() - 1) / 2, lp.getY() + Perspective.LOCAL_TILE_SIZE * (npc.getNpcSize() - 1) / 2); final Polygon poly = Perspective.getCanvasTileAreaPoly(client, centerLp, npc.getNpcSize()); - - if (poly != null) - { - OverlayUtil.renderPolygon(graphics, poly, color); - } + renderPoly(graphics, config.highlightColor(), config.fillColor(), poly); final Instant now = Instant.now(); final double baseTick = ((npc.getDiedOnTick() + npc.getRespawnTime()) - client.getTickCount()) * (Constants.GAME_TICK_LENGTH / 1000.0); @@ -148,7 +141,7 @@ public class NpcSceneOverlay extends Overlay } } - private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color) + private void renderNpcOverlay(Graphics2D graphics, NPC actor) { NPCComposition npcComposition = actor.getTransformedComposition(); if (npcComposition == null || !npcComposition.isInteractible() @@ -157,10 +150,13 @@ public class NpcSceneOverlay extends Overlay return; } + final Color borderColor = config.highlightColor(); + final Color fillColor = config.fillColor(); + if (config.highlightHull()) { Shape objectClickbox = actor.getConvexHull(); - renderPoly(graphics, color, objectClickbox); + renderPoly(graphics, borderColor, fillColor, objectClickbox); } if (config.highlightTile()) @@ -169,7 +165,7 @@ public class NpcSceneOverlay extends Overlay LocalPoint lp = actor.getLocalLocation(); Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, lp, size); - renderPoly(graphics, color, tilePoly); + renderPoly(graphics, borderColor, fillColor, tilePoly); } if (config.highlightSouthWestTile()) @@ -182,12 +178,12 @@ public class NpcSceneOverlay extends Overlay Polygon southWestTilePoly = Perspective.getCanvasTilePoly(client, new LocalPoint(x, y)); - renderPoly(graphics, color, southWestTilePoly); + renderPoly(graphics, borderColor, fillColor, southWestTilePoly); } if (config.highlightOutline()) { - modelOutlineRenderer.drawOutline(actor, (int)config.borderWidth(), color, config.outlineFeather()); + modelOutlineRenderer.drawOutline(actor, (int)config.borderWidth(), borderColor, config.outlineFeather()); } if (config.drawNames() && actor.getName() != null) @@ -197,19 +193,19 @@ public class NpcSceneOverlay extends Overlay if (textLocation != null) { - OverlayUtil.renderTextLocation(graphics, textLocation, npcName, color); + OverlayUtil.renderTextLocation(graphics, textLocation, npcName, borderColor); } } } - private void renderPoly(Graphics2D graphics, Color color, Shape polygon) + private void renderPoly(Graphics2D graphics, Color borderColor, Color fillColor, Shape polygon) { if (polygon != null) { - graphics.setColor(color); + graphics.setColor(borderColor); graphics.setStroke(new BasicStroke((float) config.borderWidth())); graphics.draw(polygon); - graphics.setColor(ColorUtil.colorWithAlpha(color, 20)); + graphics.setColor(fillColor); graphics.fill(polygon); } } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java index 9ccbcf3423..8fd814b491 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java @@ -122,7 +122,7 @@ public class NpcIndicatorsPluginTest { when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin"); when(npcIndicatorsConfig.highlightMenuNames()).thenReturn(true); - when(npcIndicatorsConfig.getHighlightColor()).thenReturn(Color.BLUE); + when(npcIndicatorsConfig.highlightColor()).thenReturn(Color.BLUE); npcIndicatorsPlugin.rebuild();