Adds an option to make the boosts plugin look kinda neat

This commit is contained in:
Thomas Cylke
2019-05-22 01:03:16 -04:00
parent 5679eff9c4
commit 30368a1487
10 changed files with 161 additions and 10 deletions

View File

@@ -71,11 +71,22 @@ public interface BoostsConfig extends Config
return false;
}
@ConfigItem(
keyName = "displayIconPanel",
name = "Icons",
description = "Show boosts next to icons (transparent background)",
position = 4
)
default boolean displayIcons()
{
return false;
}
@ConfigItem(
keyName = "displayNextBuffChange",
name = "Display next buff change",
description = "Configures whether or not to display when the next buffed stat change will be",
position = 4
position = 5
)
default DisplayChangeMode displayNextBuffChange()
{
@@ -86,7 +97,7 @@ public interface BoostsConfig extends Config
keyName = "displayNextDebuffChange",
name = "Display next debuff change",
description = "Configures whether or not to display when the next debuffed stat change will be",
position = 5
position = 6
)
default DisplayChangeMode displayNextDebuffChange()
{
@@ -97,7 +108,7 @@ public interface BoostsConfig extends Config
keyName = "boostThreshold",
name = "Boost Amount Threshold",
description = "The amount of levels boosted to send a notification at. A value of 0 will disable notification.",
position = 6
position = 7
)
default int boostThreshold()
{
@@ -108,7 +119,7 @@ public interface BoostsConfig extends Config
keyName = "groupNotifications",
name = "Group Notifications",
description = "Configures whether or not to group notifications for multiple skills into a single notification",
position = 7
position = 8
)
default boolean groupNotifications()
{

View File

@@ -62,7 +62,7 @@ class BoostsOverlay extends Overlay
@Override
public Dimension render(Graphics2D graphics)
{
if (config.displayInfoboxes())
if (config.displayInfoboxes() || config.displayIcons())
{
return null;
}

View File

@@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import javax.inject.Inject;
@@ -87,14 +87,16 @@ public class BoostsPlugin extends Plugin
@Inject
private BoostsOverlay boostsOverlay;
//made this a LinkedHashSet so the order stays consistent for my OCD
@Getter
private final Set<Skill> shownSkills = new LinkedHashSet<>();
@Inject
private BoostsConfig config;
@Inject
private SkillIconManager skillIconManager;
@Getter
private final Set<Skill> shownSkills = new HashSet<>();
@Inject
private CombatIconsOverlay combatIconsOverlay;
private boolean isChangedDown = false;
private boolean isChangedUp = false;
@@ -115,7 +117,7 @@ public class BoostsPlugin extends Plugin
protected void startUp() throws Exception
{
overlayManager.add(boostsOverlay);
overlayManager.add(combatIconsOverlay);
updateShownSkills();
updateBoostedStats();
Arrays.fill(lastSkillLevels, -1);
@@ -137,6 +139,7 @@ public class BoostsPlugin extends Plugin
protected void shutDown() throws Exception
{
overlayManager.remove(boostsOverlay);
overlayManager.remove(combatIconsOverlay);
infoBoxManager.removeIf(t -> t instanceof BoostIndicator || t instanceof StatChangeIndicator);
preserveBeenActive = false;
lastChangeDown = -1;

View File

@@ -0,0 +1,137 @@
package net.runelite.client.plugins.boosts;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.api.Skill;
import net.runelite.client.game.SkillIconManager;
import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
class CombatIconsOverlay extends Overlay
{
private final Client client;
private final BoostsConfig config;
private final PanelComponent panelComponent = new PanelComponent();
private final SkillIconManager iconManager;
private final BoostsPlugin plugin;
@Inject
private CombatIconsOverlay(Client client, BoostsConfig config, BoostsPlugin plugin, SkillIconManager iconManager)
{
super(plugin);
this.plugin = plugin;
this.client = client;
this.config = config;
this.iconManager = iconManager;
setPosition(OverlayPosition.TOP_LEFT);
setPriority(OverlayPriority.MED);
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Boosts overlay"));
}
@Override
public Dimension render(Graphics2D graphics)
{
if (config.displayInfoboxes() || !config.displayIcons())
{
return null;
}
panelComponent.getChildren().clear();
panelComponent.setPreferredSize(new Dimension(28, 0));
panelComponent.setWrapping(2);
panelComponent.setBackgroundColor(null);
panelComponent.setBorder(new Rectangle());
if (plugin.canShowBoosts())
{
for (Skill skill : plugin.getShownSkills())
{
final int boosted = client.getBoostedSkillLevel(skill);
final int base = client.getRealSkillLevel(skill);
if (boosted == base)
{
continue;
}
final int boost = boosted - base;
final Color strColor = getTextColor(boost);
String str;
if (config.useRelativeBoost())
{
str = String.valueOf(boost);
if (boost > 0)
{
str = "+" + str;
}
}
else
{
str = ColorUtil.prependColorTag(Integer.toString(boosted), strColor);
}
BufferedImage skillImage = iconManager.getSkillImage(skill, true);
panelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
panelComponent.getChildren().add(new ImageComponent(skillImage));
panelComponent.getChildren().add(LineComponent.builder()
.left("")
.right(str)
.rightColor(strColor)
.build());
}
}
int nextChange = plugin.getChangeDownTicks();
if (nextChange != -1)
{
BufferedImage buffImage = ImageUtil.getResourceStreamFromClass(getClass(), "buffedSmall.png");
panelComponent.getChildren().add(new ImageComponent(buffImage));
panelComponent.getChildren().add(LineComponent.builder()
.left("")
.right(String.valueOf(plugin.getChangeTime(nextChange)))
.build());
}
nextChange = plugin.getChangeUpTicks();
if (nextChange != -1)
{
BufferedImage debuffImage = ImageUtil.getResourceStreamFromClass(getClass(), "debuffedSmall.png");
panelComponent.getChildren().add(new ImageComponent(debuffImage));
panelComponent.getChildren().add(LineComponent.builder()
.left("")
.right(String.valueOf(plugin.getChangeTime(nextChange)))
.build());
}
return panelComponent.render(graphics);
}
private Color getTextColor(int boost)
{
if (boost < 0)
{
return new Color(238, 51, 51);
}
return boost <= config.boostThreshold() ? Color.YELLOW : Color.GREEN;
}
}