From a367c46be5579ac30ab9784d04d2e2e28abb68e7 Mon Sep 17 00:00:00 2001 From: James <38226001+f0rmatme@users.noreply.github.com> Date: Mon, 22 Jul 2019 00:50:07 -0700 Subject: [PATCH] mining: Add configuration to allow for progress pie customization (#1072) * mining: Add config to allow for progress pie customization --- .../client/plugins/mining/MiningConfig.java | 173 +++++++++++------- .../client/plugins/mining/MiningOverlay.java | 19 +- 2 files changed, 125 insertions(+), 67 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java index 1d01ce3707..b4db7d6b52 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningConfig.java @@ -1,62 +1,111 @@ -/* - * Copyright 2019 Jarred Vardy - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.mining; - -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("mining") -public interface MiningConfig extends Config -{ - @ConfigItem( - keyName = "showCoalBagOverlay", - name = "Show coal bag overlay", - description = "Overlays how much coal is inside of your coal bag" - ) - default boolean showCoalBagOverlay() - { - return true; - } - - @ConfigItem( - keyName = "amountOfCoalInCoalBag", - name = "", - description = "To store coal amount between sessions", - hidden = true - ) - default int amountOfCoalInCoalBag() - { - return 0; - } - - @ConfigItem( - keyName = "amountOfCoalInCoalBag", - name = "", - description = "Overload to set coal amount", - hidden = true - ) - void amountOfCoalInCoalBag(int amount); -} +/* + * Copyright 2019 Jarred Vardy + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +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.ConfigGroup; +import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.Range; + +@ConfigGroup("mining") +public interface MiningConfig extends Config +{ + @ConfigItem( + keyName = "showCoalBagOverlay", + name = "Show coal bag overlay", + description = "Overlays how much coal is inside of your coal bag" + ) + default boolean showCoalBagOverlay() + { + return true; + } + + @ConfigItem( + keyName = "amountOfCoalInCoalBag", + name = "", + description = "To store coal amount between sessions", + hidden = true + ) + default int amountOfCoalInCoalBag() + { + return 0; + } + + @ConfigItem( + keyName = "amountOfCoalInCoalBag", + name = "", + description = "Overload to set coal amount", + hidden = true + ) + 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; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java index 763d52b38c..5fb773ece8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningOverlay.java @@ -54,14 +54,16 @@ class MiningOverlay extends Overlay private final Client client; private final MiningPlugin plugin; + private final MiningConfig config; @Inject - private MiningOverlay(final Client client, final MiningPlugin plugin) + private MiningOverlay(final Client client, final MiningPlugin plugin, final MiningConfig config) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.plugin = plugin; this.client = client; + this.config = config; } @Override @@ -76,8 +78,8 @@ class MiningOverlay extends Overlay Instant now = Instant.now(); for (Iterator it = respawns.iterator(); it.hasNext();) { - Color pieFillColor = Color.YELLOW; - Color pieBorderColor = Color.ORANGE; + Color pieFillColor = config.progressPieColor(); + Color pieBorderColor; RockRespawn rockRespawn = it.next(); float percent = (now.toEpochMilli() - rockRespawn.getStartTime().toEpochMilli()) / (float) rockRespawn.getRespawnTime(); 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 if (rock == Rock.ORE_VEIN && percent > ORE_VEIN_RANDOM_PERCENT_THRESHOLD) { - pieFillColor = Color.GREEN; - pieBorderColor = DARK_GREEN; + pieFillColor = config.progressPieColorMotherlode(); } + if (config.progressPieInverted()) + { + percent = 1.0f - percent; + } + + pieBorderColor = pieFillColor.darker(); + ProgressPieComponent ppc = new ProgressPieComponent(); + ppc.setDiameter(config.progressPieDiameter()); ppc.setBorderColor(pieBorderColor); ppc.setFill(pieFillColor); ppc.setPosition(point);