nmz plugin: add color config for the absorption infobox

This commit is contained in:
Nickolaj Jepsen
2018-02-19 17:10:23 -05:00
committed by Adam
parent d90fcba09e
commit 265a353aac
4 changed files with 95 additions and 15 deletions

View File

@@ -24,18 +24,51 @@
*/
package net.runelite.client.plugins.nightmarezone;
import java.awt.Color;
import java.awt.image.BufferedImage;
import lombok.Getter;
import lombok.Setter;
import net.runelite.client.ui.overlay.infobox.Counter;
public class AbsorptionCounter extends Counter
{
public AbsorptionCounter(BufferedImage image, String text)
private int absorption;
@Getter
@Setter
private int threshold;
@Getter
@Setter
private Color aboveThresholdColor = Color.GREEN;
@Getter
@Setter
private Color belowThresholdColor = Color.RED;
public AbsorptionCounter(BufferedImage image, int absorption, int threshold)
{
super(image, text);
super(image, "");
this.threshold = threshold;
setAbsorption(absorption);
}
public void setAbsorption(int value)
public void setAbsorption(int absorption)
{
setText(String.valueOf(value));
this.absorption = absorption;
setText(String.valueOf(absorption));
}
@Override
public Color getTextColor()
{
if (absorption >= threshold)
{
return aboveThresholdColor;
}
else
{
return belowThresholdColor;
}
}
}

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.nightmarezone;
import java.awt.Color;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@@ -68,11 +69,22 @@ public interface NightmareZoneConfig extends Config
return true;
}
@ConfigItem(
keyName = "moveoverlay",
name = "Override NMZ overlay",
description = "Overrides the overlay so it doesn't conflict with other RuneLite plugins",
position = 4
)
default boolean moveOverlay()
{
return true;
}
@ConfigItem(
keyName = "absorptionnotification",
name = "Absorption notification",
description = "Toggles notifications when your absorption points gets below your threshold",
position = 4
position = 5
)
default boolean absorptionNotification()
{
@@ -83,7 +95,7 @@ public interface NightmareZoneConfig extends Config
keyName = "absorptionthreshold",
name = "Absorption Threshold",
description = "The amount of absorption points to send a notification at",
position = 5
position = 6
)
default int absorptionThreshold()
{
@@ -91,13 +103,25 @@ public interface NightmareZoneConfig extends Config
}
@ConfigItem(
keyName = "moveoverlay",
name = "Override NMZ overlay",
description = "Overrides the overlay so it doesn't conflict with other RuneLite plugins",
position = 6
keyName = "absorptioncoloroverthreshold",
name = "Color above threshold",
description = "Configures the color for the absorption widget when above the threshold",
position = 7
)
default boolean moveOverlay()
default Color absorptionColorAboveThreshold()
{
return true;
return Color.YELLOW;
}
@ConfigItem(
keyName = "absorptioncolorbelowthreshold",
name = "Color below threshold",
description = "Configures the color for the absorption widget when below the threshold",
position = 8
)
default Color absorptionColorBelowThreshold()
{
return Color.RED;
}
}

View File

@@ -133,15 +133,25 @@ class NightmareZoneOverlay extends Overlay
private void addAbsorptionCounter(int startValue)
{
absorptionCounter = new AbsorptionCounter(itemManager.getImage(ItemID.ABSORPTION_4), "0");
absorptionCounter.setAbsorption(startValue);
absorptionCounter = new AbsorptionCounter(itemManager.getImage(ItemID.ABSORPTION_4), startValue, config.absorptionThreshold());
absorptionCounter.setAboveThresholdColor(config.absorptionColorAboveThreshold());
absorptionCounter.setBelowThresholdColor(config.absorptionColorBelowThreshold());
infoBoxManager.addInfoBox(absorptionCounter);
}
private void removeAbsorptionCounter()
public void removeAbsorptionCounter()
{
infoBoxManager.removeInfoBox(absorptionCounter);
absorptionCounter = null;
}
public void updateConfig()
{
if (absorptionCounter != null)
{
absorptionCounter.setAboveThresholdColor(config.absorptionColorAboveThreshold());
absorptionCounter.setBelowThresholdColor(config.absorptionColorBelowThreshold());
absorptionCounter.setThreshold(config.absorptionThreshold());
}
}
}

View File

@@ -32,6 +32,7 @@ import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameTick;
import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager;
@@ -66,6 +67,18 @@ public class NightmareZonePlugin extends Plugin
// above the threshold before sending notifications
private boolean absorptionNotificationSend = true;
@Override
protected void shutDown()
{
overlay.removeAbsorptionCounter();
}
@Subscribe
public void updateConfig(ConfigChanged event)
{
overlay.updateConfig();
}
@Provides
NightmareZoneConfig getConfig(ConfigManager configManager)
{