diff --git a/src/main/java/work/fking/masteringmixology/HighlightedObject.java b/src/main/java/work/fking/masteringmixology/HighlightedObject.java new file mode 100644 index 0000000..293c975 --- /dev/null +++ b/src/main/java/work/fking/masteringmixology/HighlightedObject.java @@ -0,0 +1,36 @@ +package work.fking.masteringmixology; + +import net.runelite.api.TileObject; + +import java.awt.Color; + +public class HighlightedObject { + + private final TileObject object; + private final Color color; + private final boolean quickAction; + + public HighlightedObject(TileObject object, Color color, boolean quickAction) { + this.object = object; + this.color = color; + this.quickAction = quickAction; + } + + public TileObject object() { + return object; + } + + public Color color() { + return color; + } + + public boolean quickAction() { + return quickAction; + } + + public enum HighlightStyle { + OUTLINE, + CLICK_BOX, + HULL, + } +} \ No newline at end of file diff --git a/src/main/java/work/fking/masteringmixology/MasteringMixologyConfig.java b/src/main/java/work/fking/masteringmixology/MasteringMixologyConfig.java index e45a8f1..e975a5d 100644 --- a/src/main/java/work/fking/masteringmixology/MasteringMixologyConfig.java +++ b/src/main/java/work/fking/masteringmixology/MasteringMixologyConfig.java @@ -15,13 +15,7 @@ public interface MasteringMixologyConfig extends Config { String CONFIG_GROUP = "masteringmixology"; - @ConfigSection( - name = "Highlights", - description = "Highlighting related configuration", - position = 10 - ) - String HIGHLIGHTS = "Highlights"; - + // General Configurations @ConfigItem( keyName = "potionOrderSorting", name = "Order sorting", @@ -33,16 +27,47 @@ default PotionOrderSorting potionOrderSorting() { } @ConfigItem( + keyName = "displayResin", + name = "Display resin amount", + description = "Display total resin amounts", + position = 2 + ) + default boolean displayResin() { + return false; + } + + @ConfigItem( + keyName = "identifyPotions", + name = "Identify potions", + description = "Identify potions in your inventory", + position = 3 + ) + default boolean identifyPotions() { + return true; + } + + + // Highlights Section + @ConfigSection( + name = "Highlights", + description = "Highlighting related configuration", + position = 10 + ) + String HIGHLIGHTS = "Highlights"; + + @ConfigItem( + section = HIGHLIGHTS, keyName = "highlightLevers", name = "Highlight levers", description = "Highlight levers", - position = 2 + position = 1 ) default boolean highlightLevers() { return true; } @ConfigItem( + section = HIGHLIGHTS, keyName = "highlightStations", name = "Highlight stations", description = "Toggles alchemical station highlighting on or off", @@ -53,90 +78,99 @@ default boolean highlightStations() { } @ConfigItem( + section = HIGHLIGHTS, keyName = "highlightQuickActionEvents", name = "Highlight quick-action events", description = "Toggles station quick-action events highlighting on or off", - position = 2 + position = 3 ) default boolean highlightQuickActionEvents() { return true; } @ConfigItem( - keyName = "identifyPotions", - name = "Identify potions", - description = "Identify potions in your inventory", - position = 2 + section = HIGHLIGHTS, + keyName = "highlightDigweed", + name = "Highlight DigWeed", + description = "Toggles digweed highlighting on or off", + position = 4 ) - default boolean identifyPotions() { + default boolean highlightDigWeed() { return true; } @ConfigItem( - keyName = "displayResin", - name = "Display resin amount", - description = "Display total resin amounts", - position = 2 + section = HIGHLIGHTS, + keyName = "notifyDigweed", + name = "Notify DigWeed", + description = "Toggles digweed notifications on or off", + position = 5 ) - default boolean displayResin() { - return false; + default Notification notifyDigWeed() { + return Notification.ON; } @ConfigItem( + section = HIGHLIGHTS, keyName = "stationHighlightColor", name = "Station color", description = "Configures the default station highlight color", - position = 3 + position = 6 ) default Color stationHighlightColor() { return Color.MAGENTA; } @ConfigItem( + section = HIGHLIGHTS, keyName = "stationQuickActionHighlightColor", name = "Quick-action color", description = "Configures the station quick-action highlight color", - position = 4 + position = 7 ) default Color stationQuickActionHighlightColor() { return Color.GREEN; } @ConfigItem( - keyName = "notifyDigweed", - name = "Notify DigWeed", - description = "Toggles digweed notifications on or off", - position = 5 + section = HIGHLIGHTS, + keyName = "digweedHighlightColor", + name = "DigWeed color", + description = "Configures the digweed highlight color", + position = 8 ) - default Notification notifyDigWeed() { - return Notification.ON; + default Color digweedHighlightColor() { + return Color.GREEN; } @ConfigItem( - keyName = "highlightDigweed", - name = "Highlight DigWeed", - description = "Toggles digweed highlighting on or off", - position = 6 + section = HIGHLIGHTS, + keyName = "highlightStyle", + name = "Highlight Style", + description = "Change the style of the highlight", + position = 9 ) - default boolean highlightDigWeed() { - return true; + default HighlightedObject.HighlightStyle highlightStyle() { + return HighlightedObject.HighlightStyle.OUTLINE; } @ConfigItem( - keyName = "digweedHighlightColor", - name = "DigWeed color", - description = "Configures the digweed highlight color", - position = 7 + section = HIGHLIGHTS, + keyName = "stationQuickActionHighlightStyle", + name = "Quick-action Style", + description = "Configures the station quick-action highlight style", + position = 10 ) - default Color digweedHighlightColor() { - return Color.GREEN; + default HighlightedObject.HighlightStyle stationQuickActionHighlightStyle() { + return HighlightedObject.HighlightStyle.CLICK_BOX; } @ConfigItem( section = HIGHLIGHTS, keyName = "highlightBorderWidth", name = "Border width", - description = "Configures the border width of the object highlights" + description = "Configures the border width of the object highlights", + position = 11 ) default int highlightBorderWidth() { return 2; @@ -146,7 +180,8 @@ default int highlightBorderWidth() { section = HIGHLIGHTS, keyName = "highlightFeather", name = "Feather", - description = "Configures the amount of 'feathering' to be applied to the object highlights" + description = "Configures the amount of 'feathering' to be applied to the object highlights", + position = 12 ) default int highlightFeather() { return 1; diff --git a/src/main/java/work/fking/masteringmixology/MasteringMixologyOverlay.java b/src/main/java/work/fking/masteringmixology/MasteringMixologyOverlay.java index e2d5060..5309f94 100644 --- a/src/main/java/work/fking/masteringmixology/MasteringMixologyOverlay.java +++ b/src/main/java/work/fking/masteringmixology/MasteringMixologyOverlay.java @@ -1,22 +1,32 @@ package work.fking.masteringmixology; +import net.runelite.api.DecorativeObject; +import net.runelite.api.GameObject; +import net.runelite.api.TileObject; 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.outline.ModelOutlineRenderer; +import net.runelite.client.util.ColorUtil; import javax.inject.Inject; +import java.awt.BasicStroke; +import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.Stroke; public class MasteringMixologyOverlay extends Overlay { - private final MasteringMixologyPlugin plugin; + private final MasteringMixologyConfig config; private final ModelOutlineRenderer modelOutlineRenderer; @Inject - MasteringMixologyOverlay(MasteringMixologyPlugin plugin, ModelOutlineRenderer modelOutlineRenderer) { + MasteringMixologyOverlay(MasteringMixologyPlugin plugin, MasteringMixologyConfig config, ModelOutlineRenderer modelOutlineRenderer) { this.plugin = plugin; + this.config = config; this.modelOutlineRenderer = modelOutlineRenderer; setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); @@ -25,8 +35,37 @@ public class MasteringMixologyOverlay extends Overlay { @Override public Dimension render(Graphics2D graphics) { for (var highlightedObject : plugin.highlightedObjects().values()) { - modelOutlineRenderer.drawOutline(highlightedObject.object(), highlightedObject.outlineWidth(), highlightedObject.color(), highlightedObject.feather()); + TileObject object = highlightedObject.object(); + Color color = highlightedObject.color(); + + // Determine the highlight style to use + HighlightedObject.HighlightStyle highlightStyle = highlightedObject.quickAction() ? + config.stationQuickActionHighlightStyle() : config.highlightStyle(); + + switch (highlightStyle) { + case OUTLINE: + modelOutlineRenderer.drawOutline(object, config.highlightBorderWidth(), color, config.highlightFeather()); + break; + case CLICK_BOX: + drawShape(graphics, object.getClickbox(), color); + break; + case HULL: + if (object instanceof GameObject) { + drawShape(graphics, ((GameObject) object).getConvexHull(), color); + } else if (object instanceof DecorativeObject) { + drawShape(graphics, ((DecorativeObject) object).getConvexHull(), color); + } + break; + } } return null; } + + private void drawShape(Graphics2D graphics, Shape shape, Color color) { + if (shape != null) { + Stroke stroke = new BasicStroke((float) config.highlightBorderWidth()); + Color fillColor = ColorUtil.colorWithAlpha(color, 20); + OverlayUtil.renderPolygon(graphics, shape, color.darker(), fillColor, stroke); + } + } } diff --git a/src/main/java/work/fking/masteringmixology/MasteringMixologyPlugin.java b/src/main/java/work/fking/masteringmixology/MasteringMixologyPlugin.java index 4b8172f..eaa2916 100644 --- a/src/main/java/work/fking/masteringmixology/MasteringMixologyPlugin.java +++ b/src/main/java/work/fking/masteringmixology/MasteringMixologyPlugin.java @@ -359,14 +359,14 @@ public void onGraphicsObjectCreated(GraphicsObjectCreated event) { return; } if (spotAnimId == SPOT_ANIM_ALEMBIC && alembicPotionType != null) { - highlightObject(AlchemyObject.ALEMBIC, config.stationQuickActionHighlightColor()); + highlightObject(AlchemyObject.ALEMBIC, config.stationQuickActionHighlightColor(), true); // start counting ticks for alembic so we know to un-highlight on the next alembic varbit update // note this quick action has a 1 tick window, so we use an int that goes 0 -> 1 -> unhighlight alembicQuickActionTicks = 1; } if (spotAnimId == SPOT_ANIM_AGITATOR && agitatorPotionType != null) { - highlightObject(AlchemyObject.AGITATOR, config.stationQuickActionHighlightColor()); + highlightObject(AlchemyObject.AGITATOR, config.stationQuickActionHighlightColor(), true); // start counting ticks for agitator so we know to un-highlight on the next agitator varbit update // note this quick action has a 2-tick window, so we use an int that goes 0 -> 1 -> 2 -> unhighlight agitatorQuickActionTicks = 1; @@ -458,6 +458,10 @@ private void initialize() { } public void highlightObject(AlchemyObject alchemyObject, Color color) { + highlightObject(alchemyObject, color, false); + } + + public void highlightObject(AlchemyObject alchemyObject, Color color, boolean quickAction) { var worldView = client.getTopLevelWorldView(); if (worldView == null) { @@ -477,7 +481,7 @@ public void highlightObject(AlchemyObject alchemyObject, Color color) { } if (gameObject.getId() == alchemyObject.objectId()) { - highlightedObjects.put(alchemyObject, new HighlightedObject(gameObject, color, config.highlightBorderWidth(), config.highlightFeather())); + highlightedObjects.put(alchemyObject, new HighlightedObject(gameObject, color, quickAction)); return; } } @@ -485,7 +489,7 @@ public void highlightObject(AlchemyObject alchemyObject, Color color) { var decorativeObject = tile.getDecorativeObject(); if (decorativeObject != null && decorativeObject.getId() == alchemyObject.objectId()) { - highlightedObjects.put(alchemyObject, new HighlightedObject(decorativeObject, color, config.highlightBorderWidth(), config.highlightFeather())); + highlightedObjects.put(alchemyObject, new HighlightedObject(decorativeObject, color, quickAction)); } } @@ -628,35 +632,4 @@ private PotionModifier getPotionModifier(int orderIdx) { return null; } } - - public static class HighlightedObject { - - private final TileObject object; - private final Color color; - private final int outlineWidth; - private final int feather; - - private HighlightedObject(TileObject object, Color color, int outlineWidth, int feather) { - this.object = object; - this.color = color; - this.outlineWidth = outlineWidth; - this.feather = feather; - } - - public TileObject object() { - return object; - } - - public Color color() { - return color; - } - - public int outlineWidth() { - return outlineWidth; - } - - public int feather() { - return feather; - } - } }