From 7bbd0b3de75058109e2d3b86536ede55beccd7e6 Mon Sep 17 00:00:00 2001 From: Seth Date: Mon, 23 Apr 2018 14:31:29 -0500 Subject: [PATCH 1/2] boosts overlay: move next change text to display at the top --- .../client/plugins/boosts/BoostsOverlay.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java index 6f7e46bbce..ee0991d835 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java @@ -57,6 +57,8 @@ class BoostsOverlay extends Overlay private PanelComponent panelComponent; + private boolean overlayActive; + @Inject BoostsOverlay(Client client, BoostsConfig config, InfoBoxManager infoBoxManager) { @@ -71,7 +73,23 @@ class BoostsOverlay extends Overlay public Dimension render(Graphics2D graphics) { panelComponent = new PanelComponent(); - boolean overlayActive = false; + + Instant lastChange = plugin.getLastChange(); + if (config.displayNextChange() && lastChange != null && overlayActive) + { + int nextChange = 60 - (int)Duration.between(lastChange, Instant.now()).getSeconds(); + if (nextChange > 0) + { + panelComponent.getLines().add(new PanelComponent.Line( + "Next change in", + Color.WHITE, + String.valueOf(nextChange), + Color.WHITE + )); + } + } + + overlayActive = false; for (Skill skill : plugin.getShownSkills()) { @@ -137,21 +155,6 @@ class BoostsOverlay extends Overlay } } - Instant lastChange = plugin.getLastChange(); - if (config.displayNextChange() && lastChange != null && overlayActive) - { - int nextChange = 60 - (int)Duration.between(lastChange, Instant.now()).getSeconds(); - if (nextChange > 0) - { - panelComponent.getLines().add(new PanelComponent.Line( - "Next change in", - Color.WHITE, - String.valueOf(nextChange), - Color.WHITE - )); - } - } - return panelComponent.getLines().isEmpty() ? null : panelComponent.render(graphics); } From 90b2c38c0c71ce505457c71ef880828f7cbfd6f6 Mon Sep 17 00:00:00 2001 From: Seth Date: Mon, 23 Apr 2018 14:33:51 -0500 Subject: [PATCH 2/2] boosts plugin: Add stat change indicator when indicators are selected --- .../client/plugins/boosts/BoostsOverlay.java | 8 ++-- .../client/plugins/boosts/BoostsPlugin.java | 45 ++++++++++++++++++- .../plugins/boosts/StatChangeIndicator.java | 41 +++++++++++++++++ 3 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/boosts/StatChangeIndicator.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java index ee0991d835..1b51345445 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java @@ -27,7 +27,6 @@ package net.runelite.client.plugins.boosts; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; -import java.time.Duration; import java.time.Instant; import javax.inject.Inject; import lombok.Getter; @@ -75,9 +74,12 @@ class BoostsOverlay extends Overlay panelComponent = new PanelComponent(); Instant lastChange = plugin.getLastChange(); - if (config.displayNextChange() && lastChange != null && overlayActive) + if (!config.displayIndicators() + && config.displayNextChange() + && lastChange != null + && overlayActive) { - int nextChange = 60 - (int)Duration.between(lastChange, Instant.now()).getSeconds(); + int nextChange = plugin.getChangeTime(); if (nextChange > 0) { panelComponent.getLines().add(new PanelComponent.Line( diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsPlugin.java index b01318710b..44e104078b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsPlugin.java @@ -27,7 +27,10 @@ package net.runelite.client.plugins.boosts; import com.google.common.collect.ObjectArrays; import com.google.common.eventbus.Subscribe; import com.google.inject.Provides; +import java.awt.image.BufferedImage; +import java.time.Duration; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.Arrays; import javax.inject.Inject; import lombok.Getter; @@ -37,6 +40,7 @@ import net.runelite.api.Skill; import net.runelite.api.events.BoostedLevelChanged; import net.runelite.api.events.ConfigChanged; import net.runelite.client.config.ConfigManager; +import net.runelite.client.game.SkillIconManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.Overlay; @@ -76,9 +80,16 @@ public class BoostsPlugin extends Plugin @Inject private BoostsConfig config; + @Inject + private SkillIconManager skillIconManager; + @Getter private Skill[] shownSkills; + private StatChangeIndicator statChangeIndicator; + + private BufferedImage overallIcon; + @Provides BoostsConfig provideConfig(ConfigManager configManager) { @@ -96,17 +107,29 @@ public class BoostsPlugin extends Plugin { updateShownSkills(config.enableSkill()); Arrays.fill(lastSkillLevels, -1); + overallIcon = skillIconManager.getSkillImage(Skill.OVERALL); } @Override protected void shutDown() throws Exception { - infoBoxManager.removeIf(t -> t instanceof BoostIndicator); + infoBoxManager.removeIf(t -> t instanceof BoostIndicator || t instanceof StatChangeIndicator); } @Subscribe public void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals("boosts")) + { + return; + } + + if (event.getKey().equals("displayIndicators") || event.getKey().equals("displayNextChange")) + { + addStatChangeIndicator(); + return; + } + Skill[] old = shownSkills; updateShownSkills(config.enableSkill()); @@ -137,6 +160,7 @@ public class BoostsPlugin extends Plugin { log.debug("Skill {} healed", skill); lastChange = Instant.now(); + addStatChangeIndicator(); } lastSkillLevels[skillIdx] = cur; } @@ -152,4 +176,23 @@ public class BoostsPlugin extends Plugin shownSkills = COMBAT; } } + + public void addStatChangeIndicator() + { + infoBoxManager.removeInfoBox(statChangeIndicator); + statChangeIndicator = null; + + if (lastChange != null + && config.displayIndicators() + && config.displayNextChange()) + { + statChangeIndicator = new StatChangeIndicator(getChangeTime(), ChronoUnit.SECONDS, overallIcon, this); + infoBoxManager.addInfoBox(statChangeIndicator); + } + } + + public int getChangeTime() + { + return 60 - (int) Duration.between(lastChange, Instant.now()).getSeconds(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/StatChangeIndicator.java b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/StatChangeIndicator.java new file mode 100644 index 0000000000..78275e4027 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/StatChangeIndicator.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018, Seth + * 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.boosts; + +import java.awt.image.BufferedImage; +import java.time.temporal.ChronoUnit; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.ui.overlay.infobox.InfoBoxPriority; +import net.runelite.client.ui.overlay.infobox.Timer; + +public class StatChangeIndicator extends Timer +{ + public StatChangeIndicator(long period, ChronoUnit unit, BufferedImage image, Plugin plugin) + { + super(period, unit, image, plugin); + setPriority(InfoBoxPriority.MED); + setTooltip("Next stat change"); + } +}