mining: Add configuration to allow for progress pie customization (#1072)

* mining: Add config to allow for progress pie customization
This commit is contained in:
James
2019-07-22 00:50:07 -07:00
committed by Kyleeld
parent 1c1ac5a919
commit a367c46be5
2 changed files with 125 additions and 67 deletions

View File

@@ -24,17 +24,20 @@
*/ */
package net.runelite.client.plugins.mining; package net.runelite.client.plugins.mining;
import java.awt.Color;
import net.runelite.client.config.Alpha;
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.Range;
@ConfigGroup("mining") @ConfigGroup("mining")
public interface MiningConfig extends Config public interface MiningConfig extends Config
{ {
@ConfigItem( @ConfigItem(
keyName = "showCoalBagOverlay", keyName = "showCoalBagOverlay",
name = "Show coal bag overlay", name = "Show coal bag overlay",
description = "Overlays how much coal is inside of your coal bag" description = "Overlays how much coal is inside of your coal bag"
) )
default boolean showCoalBagOverlay() default boolean showCoalBagOverlay()
{ {
@@ -42,10 +45,10 @@ public interface MiningConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "amountOfCoalInCoalBag", keyName = "amountOfCoalInCoalBag",
name = "", name = "",
description = "To store coal amount between sessions", description = "To store coal amount between sessions",
hidden = true hidden = true
) )
default int amountOfCoalInCoalBag() default int amountOfCoalInCoalBag()
{ {
@@ -53,10 +56,56 @@ public interface MiningConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "amountOfCoalInCoalBag", keyName = "amountOfCoalInCoalBag",
name = "", name = "",
description = "Overload to set coal amount", description = "Overload to set coal amount",
hidden = true hidden = true
) )
void amountOfCoalInCoalBag(int amount); void amountOfCoalInCoalBag(int amount);
@Alpha
@ConfigItem(
keyName = "progressPieColor",
name = "Main progress pie color",
description = "Configures the color of the main progress pie"
)
default Color progressPieColor()
{
return Color.YELLOW;
}
@Alpha
@ConfigItem(
keyName = "progressPieColorMotherlode",
name = "Motherlode random respawn threshold progress pie color",
description = "Configures the color of the progress pie after Motherlode respawn threshold"
)
default Color progressPieColorMotherlode()
{
return Color.GREEN;
}
@ConfigItem(
keyName = "progressPieInverted",
name = "Invert progress pie",
description = "Configures whether the progress pie goes from empty to full or the other way around"
)
default boolean progressPieInverted()
{
return false;
}
@Range(
min = 1,
max = 50
)
@ConfigItem(
keyName = "progressPieDiameter",
name = "Progress pie diameter",
description = "Configures how big the progress pie is"
)
default int progressPieDiameter()
{
return 1;
}
} }

View File

@@ -54,14 +54,16 @@ class MiningOverlay extends Overlay
private final Client client; private final Client client;
private final MiningPlugin plugin; private final MiningPlugin plugin;
private final MiningConfig config;
@Inject @Inject
private MiningOverlay(final Client client, final MiningPlugin plugin) private MiningOverlay(final Client client, final MiningPlugin plugin, final MiningConfig config)
{ {
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_SCENE); setLayer(OverlayLayer.ABOVE_SCENE);
this.plugin = plugin; this.plugin = plugin;
this.client = client; this.client = client;
this.config = config;
} }
@Override @Override
@@ -76,8 +78,8 @@ class MiningOverlay extends Overlay
Instant now = Instant.now(); Instant now = Instant.now();
for (Iterator<RockRespawn> it = respawns.iterator(); it.hasNext();) for (Iterator<RockRespawn> it = respawns.iterator(); it.hasNext();)
{ {
Color pieFillColor = Color.YELLOW; Color pieFillColor = config.progressPieColor();
Color pieBorderColor = Color.ORANGE; Color pieBorderColor;
RockRespawn rockRespawn = it.next(); RockRespawn rockRespawn = it.next();
float percent = (now.toEpochMilli() - rockRespawn.getStartTime().toEpochMilli()) / (float) rockRespawn.getRespawnTime(); float percent = (now.toEpochMilli() - rockRespawn.getStartTime().toEpochMilli()) / (float) rockRespawn.getRespawnTime();
WorldPoint worldPoint = rockRespawn.getWorldPoint(); WorldPoint worldPoint = rockRespawn.getWorldPoint();
@@ -107,11 +109,18 @@ class MiningOverlay extends Overlay
// Recolour pie on motherlode veins during the portion of the timer where they may respawn // Recolour pie on motherlode veins during the portion of the timer where they may respawn
if (rock == Rock.ORE_VEIN && percent > ORE_VEIN_RANDOM_PERCENT_THRESHOLD) if (rock == Rock.ORE_VEIN && percent > ORE_VEIN_RANDOM_PERCENT_THRESHOLD)
{ {
pieFillColor = Color.GREEN; pieFillColor = config.progressPieColorMotherlode();
pieBorderColor = DARK_GREEN;
} }
if (config.progressPieInverted())
{
percent = 1.0f - percent;
}
pieBorderColor = pieFillColor.darker();
ProgressPieComponent ppc = new ProgressPieComponent(); ProgressPieComponent ppc = new ProgressPieComponent();
ppc.setDiameter(config.progressPieDiameter());
ppc.setBorderColor(pieBorderColor); ppc.setBorderColor(pieBorderColor);
ppc.setFill(pieFillColor); ppc.setFill(pieFillColor);
ppc.setPosition(point); ppc.setPosition(point);