Skip to content

Commit

Permalink
Add configurable highlight styles
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueSoapTurtle committed Oct 30, 2024
1 parent 76480f0 commit 650d52f
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 81 deletions.
36 changes: 36 additions & 0 deletions src/main/java/work/fking/masteringmixology/HighlightedObject.java
Original file line number Diff line number Diff line change
@@ -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,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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);
}
}
}
Loading

0 comments on commit 650d52f

Please sign in to comment.