boosts plugin: Add stat change indicator when indicators are selected
This commit is contained in:
@@ -27,7 +27,6 @@ package net.runelite.client.plugins.boosts;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -75,9 +74,12 @@ class BoostsOverlay extends Overlay
|
|||||||
panelComponent = new PanelComponent();
|
panelComponent = new PanelComponent();
|
||||||
|
|
||||||
Instant lastChange = plugin.getLastChange();
|
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)
|
if (nextChange > 0)
|
||||||
{
|
{
|
||||||
panelComponent.getLines().add(new PanelComponent.Line(
|
panelComponent.getLines().add(new PanelComponent.Line(
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ package net.runelite.client.plugins.boosts;
|
|||||||
import com.google.common.collect.ObjectArrays;
|
import com.google.common.collect.ObjectArrays;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -37,6 +40,7 @@ import net.runelite.api.Skill;
|
|||||||
import net.runelite.api.events.BoostedLevelChanged;
|
import net.runelite.api.events.BoostedLevelChanged;
|
||||||
import net.runelite.api.events.ConfigChanged;
|
import net.runelite.api.events.ConfigChanged;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.client.game.SkillIconManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
@@ -76,9 +80,16 @@ public class BoostsPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private BoostsConfig config;
|
private BoostsConfig config;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SkillIconManager skillIconManager;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Skill[] shownSkills;
|
private Skill[] shownSkills;
|
||||||
|
|
||||||
|
private StatChangeIndicator statChangeIndicator;
|
||||||
|
|
||||||
|
private BufferedImage overallIcon;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
BoostsConfig provideConfig(ConfigManager configManager)
|
BoostsConfig provideConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -96,17 +107,29 @@ public class BoostsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
updateShownSkills(config.enableSkill());
|
updateShownSkills(config.enableSkill());
|
||||||
Arrays.fill(lastSkillLevels, -1);
|
Arrays.fill(lastSkillLevels, -1);
|
||||||
|
overallIcon = skillIconManager.getSkillImage(Skill.OVERALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutDown() throws Exception
|
protected void shutDown() throws Exception
|
||||||
{
|
{
|
||||||
infoBoxManager.removeIf(t -> t instanceof BoostIndicator);
|
infoBoxManager.removeIf(t -> t instanceof BoostIndicator || t instanceof StatChangeIndicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onConfigChanged(ConfigChanged event)
|
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;
|
Skill[] old = shownSkills;
|
||||||
updateShownSkills(config.enableSkill());
|
updateShownSkills(config.enableSkill());
|
||||||
|
|
||||||
@@ -137,6 +160,7 @@ public class BoostsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
log.debug("Skill {} healed", skill);
|
log.debug("Skill {} healed", skill);
|
||||||
lastChange = Instant.now();
|
lastChange = Instant.now();
|
||||||
|
addStatChangeIndicator();
|
||||||
}
|
}
|
||||||
lastSkillLevels[skillIdx] = cur;
|
lastSkillLevels[skillIdx] = cur;
|
||||||
}
|
}
|
||||||
@@ -152,4 +176,23 @@ public class BoostsPlugin extends Plugin
|
|||||||
shownSkills = COMBAT;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Seth <http://github.com/sethtroll>
|
||||||
|
* 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user