Merge pull request #719 from gazivodag/runedoku_update

Runedoku ability to render only selected rune
This commit is contained in:
Ganom
2019-06-24 01:29:54 -04:00
committed by GitHub
3 changed files with 123 additions and 38 deletions

View File

@@ -28,16 +28,29 @@ import java.awt.Color;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Stub;
@ConfigGroup("runedoku") @ConfigGroup("runedoku")
public interface RunedokuConfig extends Config public interface RunedokuConfig extends Config
{ {
@ConfigItem( @ConfigItem(
position = 0, position = 0,
keyName = "mindRuneColor", keyName = "colorStub",
name = "Mind Rune Color", name = "Colors",
description = "Color used to highlight Mind runes." description = "" //stubs don't show descriptions when hovered over
)
default Stub colorStub()
{
return new Stub();
}
@ConfigItem(
position = 1,
keyName = "mindRuneColor",
name = "Mind Rune Color",
description = "Color used to highlight Mind runes.",
parent = "colorStub"
) )
default Color mindRuneColor() default Color mindRuneColor()
{ {
@@ -45,10 +58,11 @@ public interface RunedokuConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 1, position = 2,
keyName = "fireRuneColor", keyName = "fireRuneColor",
name = "Fire Rune Color", name = "Fire Rune Color",
description = "Color used to highlight Fire runes." description = "Color used to highlight Fire runes.",
parent = "colorStub"
) )
default Color fireRuneColor() default Color fireRuneColor()
{ {
@@ -56,10 +70,11 @@ public interface RunedokuConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 2, position = 3,
keyName = "bodyRuneColor", keyName = "bodyRuneColor",
name = "Body Rune Color", name = "Body Rune Color",
description = "Color used to highlight Body runes." description = "Color used to highlight Body runes.",
parent = "colorStub"
) )
default Color bodyRuneColor() default Color bodyRuneColor()
{ {
@@ -67,10 +82,11 @@ public interface RunedokuConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 3, position = 4,
keyName = "airRuneColor", keyName = "airRuneColor",
name = "Air Rune Color", name = "Air Rune Color",
description = "Color used to highlight Air runes." description = "Color used to highlight Air runes.",
parent = "colorStub"
) )
default Color airRuneColor() default Color airRuneColor()
{ {
@@ -78,10 +94,11 @@ public interface RunedokuConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 4, position = 5,
keyName = "deathRuneColor", keyName = "deathRuneColor",
name = "Death Rune Color", name = "Death Rune Color",
description = "Color used to highlight Death runes." description = "Color used to highlight Death runes.",
parent = "colorStub"
) )
default Color deathRuneColor() default Color deathRuneColor()
{ {
@@ -89,10 +106,11 @@ public interface RunedokuConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 5, position = 6,
keyName = "waterRuneColor", keyName = "waterRuneColor",
name = "Water Rune Color", name = "Water Rune Color",
description = "Color used to highlight Water runes." description = "Color used to highlight Water runes.",
parent = "colorStub"
) )
default Color waterRuneColor() default Color waterRuneColor()
{ {
@@ -100,10 +118,11 @@ public interface RunedokuConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 6, position = 7,
keyName = "chaosRuneColor", keyName = "chaosRuneColor",
name = "Chaos Rune Color", name = "Chaos Rune Color",
description = "Color used to highlight Chaos runes." description = "Color used to highlight Chaos runes.",
parent = "colorStub"
) )
default Color chaosRuneColor() default Color chaosRuneColor()
{ {
@@ -111,10 +130,11 @@ public interface RunedokuConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 7, position = 8,
keyName = "earthRuneColor", keyName = "earthRuneColor",
name = "Earth Rune Color", name = "Earth Rune Color",
description = "Color used to highlight Earth runes." description = "Color used to highlight Earth runes.",
parent = "colorStub"
) )
default Color earthRuneColor() default Color earthRuneColor()
{ {
@@ -122,14 +142,37 @@ public interface RunedokuConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 8, position = 9,
keyName = "lawRuneColor", keyName = "lawRuneColor",
name = "Law Rune Color", name = "Law Rune Color",
description = "Color used to highlight Law runes." description = "Color used to highlight Law runes.",
parent = "colorStub"
) )
default Color lawRuneColor() default Color lawRuneColor()
{ {
return Color.CYAN; return Color.CYAN;
} }
@ConfigItem(
position = 10,
keyName = "miscFeature",
name = "Miscellaneous Features",
description = ""
)
default Stub miscFeature()
{
return new Stub();
}
@ConfigItem(
position = 11,
keyName = "onlyHighlightSelectedPiece",
name = "Only Highlight Selected Piece",
description = "Instead of showing all, this option only show what rune you have selected."
)
default boolean onlyHighlightSelectedPiece()
{
return false;
}
} }

View File

@@ -47,15 +47,17 @@ class RunedokuOverlay extends Overlay
private final RunedokuPlugin plugin; private final RunedokuPlugin plugin;
private final Client client; private final Client client;
private final RunedokuUtil util; private final RunedokuUtil util;
private final RunedokuConfig config;
@Inject @Inject
private RunedokuOverlay(final RunedokuPlugin plugin, final Client client, final RunedokuUtil util) private RunedokuOverlay(final RunedokuPlugin plugin, final Client client, final RunedokuUtil util, final RunedokuConfig config)
{ {
super(plugin); super(plugin);
this.plugin = plugin; this.plugin = plugin;
this.client = client; this.client = client;
this.util = util; this.util = util;
this.config = config;
setPosition(OverlayPosition.DETACHED); setPosition(OverlayPosition.DETACHED);
setLayer(OverlayLayer.ALWAYS_ON_TOP); setLayer(OverlayLayer.ALWAYS_ON_TOP);
@@ -138,7 +140,10 @@ class RunedokuOverlay extends Overlay
} }
else else
{ {
OverlayUtil.renderPolygon(graphics, RunedokuUtil.rectangleToPolygon(squareToHighlight.getBounds()), util.sudokuPieceToColor(simpleArr.get(iteration))); if (!config.onlyHighlightSelectedPiece() ^ (config.onlyHighlightSelectedPiece() && util.getSelectedPiece(client) == simpleArr.get(iteration)))
{
OverlayUtil.renderPolygon(graphics, RunedokuUtil.rectangleToPolygon(squareToHighlight.getBounds()), util.sudokuPieceToColor(simpleArr.get(iteration)));
}
} }
iteration++; iteration++;
} }

View File

@@ -180,4 +180,41 @@ class RunedokuUtil
return myArr; return myArr;
} }
/**
* @param client
* @return
*/
int getSelectedPiece(Client client)
{
for (int i = 91; i < 100; i++)
{
Widget selectedPieceWidget = client.getWidget(288, i);
if (!selectedPieceWidget.isHidden())
{
switch (i)
{
case 91:
return 8;
case 92:
return 6;
case 93:
return 4;
case 94:
return 2;
case 95:
return 1;
case 96:
return 3;
case 97:
return 5;
case 98:
return 7;
case 99:
return 9;
}
}
}
return -1;
}
} }