mining: Add configuration to allow for progress pie customization (#1072)
* mining: Add config to allow for progress pie customization
This commit is contained in:
@@ -1,62 +1,111 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019 Jarred Vardy <jarredvardy@gmail.com>
|
* Copyright 2019 Jarred Vardy <jarredvardy@gmail.com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
* list of conditions and the following disclaimer.
|
* list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* 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
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.mining;
|
package net.runelite.client.plugins.mining;
|
||||||
|
|
||||||
import net.runelite.client.config.Config;
|
import java.awt.Color;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.Alpha;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.Config;
|
||||||
|
import net.runelite.client.config.ConfigGroup;
|
||||||
@ConfigGroup("mining")
|
import net.runelite.client.config.ConfigItem;
|
||||||
public interface MiningConfig extends Config
|
import net.runelite.client.config.Range;
|
||||||
{
|
|
||||||
@ConfigItem(
|
@ConfigGroup("mining")
|
||||||
keyName = "showCoalBagOverlay",
|
public interface MiningConfig extends Config
|
||||||
name = "Show coal bag overlay",
|
{
|
||||||
description = "Overlays how much coal is inside of your coal bag"
|
@ConfigItem(
|
||||||
)
|
keyName = "showCoalBagOverlay",
|
||||||
default boolean showCoalBagOverlay()
|
name = "Show coal bag overlay",
|
||||||
{
|
description = "Overlays how much coal is inside of your coal bag"
|
||||||
return true;
|
)
|
||||||
}
|
default boolean showCoalBagOverlay()
|
||||||
|
{
|
||||||
@ConfigItem(
|
return true;
|
||||||
keyName = "amountOfCoalInCoalBag",
|
}
|
||||||
name = "",
|
|
||||||
description = "To store coal amount between sessions",
|
@ConfigItem(
|
||||||
hidden = true
|
keyName = "amountOfCoalInCoalBag",
|
||||||
)
|
name = "",
|
||||||
default int amountOfCoalInCoalBag()
|
description = "To store coal amount between sessions",
|
||||||
{
|
hidden = true
|
||||||
return 0;
|
)
|
||||||
}
|
default int amountOfCoalInCoalBag()
|
||||||
|
{
|
||||||
@ConfigItem(
|
return 0;
|
||||||
keyName = "amountOfCoalInCoalBag",
|
}
|
||||||
name = "",
|
|
||||||
description = "Overload to set coal amount",
|
@ConfigItem(
|
||||||
hidden = true
|
keyName = "amountOfCoalInCoalBag",
|
||||||
)
|
name = "",
|
||||||
void amountOfCoalInCoalBag(int amount);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user