Merge pull request #609 from Fire-Proof/fix-nmz-absorp-color
Fix color of text in the NMZ absorption infobox
This commit is contained in:
@@ -24,18 +24,51 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.nightmarezone;
|
package net.runelite.client.plugins.nightmarezone;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.runelite.client.ui.overlay.infobox.Counter;
|
import net.runelite.client.ui.overlay.infobox.Counter;
|
||||||
|
|
||||||
public class AbsorptionCounter extends 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,22 +24,23 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.nightmarezone;
|
package net.runelite.client.plugins.nightmarezone;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
@ConfigGroup(
|
@ConfigGroup(
|
||||||
keyName = "nightmareZone",
|
keyName = "nightmareZone",
|
||||||
name = "Nightmare Zone",
|
name = "Nightmare Zone",
|
||||||
description = "Configuration for the nightmare zone plugin"
|
description = "Configuration for the nightmare zone plugin"
|
||||||
)
|
)
|
||||||
public interface NightmareZoneConfig extends Config
|
public interface NightmareZoneConfig extends Config
|
||||||
{
|
{
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "tray",
|
keyName = "tray",
|
||||||
name = "Send Tray Notification",
|
name = "Send Tray Notification",
|
||||||
description = "Toggles tray notifications",
|
description = "Toggles tray notifications",
|
||||||
position = 2
|
position = 1
|
||||||
)
|
)
|
||||||
default boolean sendTrayNotification()
|
default boolean sendTrayNotification()
|
||||||
{
|
{
|
||||||
@@ -47,10 +48,10 @@ public interface NightmareZoneConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "request",
|
keyName = "request",
|
||||||
name = "Request Window Focus",
|
name = "Request Window Focus",
|
||||||
description = "Toggles window focus request",
|
description = "Toggles window focus request",
|
||||||
position = 3
|
position = 2
|
||||||
)
|
)
|
||||||
default boolean requestFocus()
|
default boolean requestFocus()
|
||||||
{
|
{
|
||||||
@@ -58,10 +59,10 @@ public interface NightmareZoneConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "overloadnotification",
|
keyName = "overloadnotification",
|
||||||
name = "Overload notification",
|
name = "Overload notification",
|
||||||
description = "Toggles notifications when your overload runs out",
|
description = "Toggles notifications when your overload runs out",
|
||||||
position = 4
|
position = 3
|
||||||
)
|
)
|
||||||
default boolean overloadNotification()
|
default boolean overloadNotification()
|
||||||
{
|
{
|
||||||
@@ -69,10 +70,21 @@ public interface NightmareZoneConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "absorptionnotification",
|
keyName = "moveoverlay",
|
||||||
name = "Absorption notification",
|
name = "Override NMZ overlay",
|
||||||
description = "Toggles notifications when your absorption points gets below your threshold",
|
description = "Overrides the overlay so it doesn't conflict with other RuneLite plugins",
|
||||||
position = 5
|
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 = 5
|
||||||
)
|
)
|
||||||
default boolean absorptionNotification()
|
default boolean absorptionNotification()
|
||||||
{
|
{
|
||||||
@@ -80,10 +92,10 @@ public interface NightmareZoneConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "absorptionthreshold",
|
keyName = "absorptionthreshold",
|
||||||
name = "Absorption Threshold",
|
name = "Absorption Threshold",
|
||||||
description = "The amount of absorption points to send a notification at",
|
description = "The amount of absorption points to send a notification at",
|
||||||
position = 6
|
position = 6
|
||||||
)
|
)
|
||||||
default int absorptionThreshold()
|
default int absorptionThreshold()
|
||||||
{
|
{
|
||||||
@@ -91,13 +103,25 @@ public interface NightmareZoneConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "moveoverlay",
|
keyName = "absorptioncoloroverthreshold",
|
||||||
name = "Override NMZ overlay",
|
name = "Color above threshold",
|
||||||
description = "Overrides the overlay so it doesn't conflict with other RuneLite plugins",
|
description = "Configures the color for the absorption widget when above the threshold",
|
||||||
position = 7
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,15 +133,25 @@ class NightmareZoneOverlay extends Overlay
|
|||||||
|
|
||||||
private void addAbsorptionCounter(int startValue)
|
private void addAbsorptionCounter(int startValue)
|
||||||
{
|
{
|
||||||
absorptionCounter = new AbsorptionCounter(itemManager.getImage(ItemID.ABSORPTION_4), "0");
|
absorptionCounter = new AbsorptionCounter(itemManager.getImage(ItemID.ABSORPTION_4), startValue, config.absorptionThreshold());
|
||||||
absorptionCounter.setAbsorption(startValue);
|
absorptionCounter.setAboveThresholdColor(config.absorptionColorAboveThreshold());
|
||||||
|
absorptionCounter.setBelowThresholdColor(config.absorptionColorBelowThreshold());
|
||||||
infoBoxManager.addInfoBox(absorptionCounter);
|
infoBoxManager.addInfoBox(absorptionCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeAbsorptionCounter()
|
public void removeAbsorptionCounter()
|
||||||
{
|
{
|
||||||
infoBoxManager.removeInfoBox(absorptionCounter);
|
infoBoxManager.removeInfoBox(absorptionCounter);
|
||||||
absorptionCounter = null;
|
absorptionCounter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateConfig()
|
||||||
|
{
|
||||||
|
if (absorptionCounter != null)
|
||||||
|
{
|
||||||
|
absorptionCounter.setAboveThresholdColor(config.absorptionColorAboveThreshold());
|
||||||
|
absorptionCounter.setBelowThresholdColor(config.absorptionColorBelowThreshold());
|
||||||
|
absorptionCounter.setThreshold(config.absorptionThreshold());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import net.runelite.api.ChatMessageType;
|
|||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
|
import net.runelite.api.events.ConfigChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
@@ -66,6 +67,18 @@ public class NightmareZonePlugin extends Plugin
|
|||||||
// above the threshold before sending notifications
|
// above the threshold before sending notifications
|
||||||
private boolean absorptionNotificationSend = true;
|
private boolean absorptionNotificationSend = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shutDown()
|
||||||
|
{
|
||||||
|
overlay.removeAbsorptionCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void updateConfig(ConfigChanged event)
|
||||||
|
{
|
||||||
|
overlay.updateConfig();
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
NightmareZoneConfig getConfig(ConfigManager configManager)
|
NightmareZoneConfig getConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user