Fix several issues with indicators

- Fix issue with indicators showing up multiple times
- Fix issue with disabling skill boosts not removing indicators
This commit is contained in:
Kamiel
2018-02-03 01:50:11 +01:00
committed by Adam
parent 181c717a05
commit 00e3503cfe
3 changed files with 28 additions and 24 deletions

View File

@@ -26,6 +26,7 @@ package net.runelite.client.plugins.boosts;
import java.awt.Color;
import java.awt.image.BufferedImage;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.Skill;
import net.runelite.client.ui.overlay.infobox.InfoBox;
@@ -34,6 +35,8 @@ public class BoostIndicator extends InfoBox
{
private final BoostsConfig config;
private final Client client;
@Getter
private final Skill skill;
public BoostIndicator(Skill skill, BufferedImage image, Client client, BoostsConfig config)

View File

@@ -84,12 +84,13 @@ class BoostsOverlay extends Overlay
int boosted = client.getBoostedSkillLevel(skill),
base = client.getRealSkillLevel(skill);
BoostIndicator indicator = indicators[skill.ordinal()];
if (boosted == base)
{
if (indicators[skill.ordinal()] != null)
if (indicator != null && infoBoxManager.getInfoBoxes().contains(indicator))
{
infoBoxManager.removeInfoBox(indicators[skill.ordinal()]);
indicators[skill.ordinal()] = null;
infoBoxManager.removeInfoBox(indicator);
}
continue;
@@ -97,15 +98,24 @@ class BoostsOverlay extends Overlay
if (config.displayIndicators())
{
if (indicators[skill.ordinal()] == null)
if (indicator == null)
{
BoostIndicator indicator = new BoostIndicator(skill, iconManager.getSkillImage(skill), client, config);
indicator = new BoostIndicator(skill, iconManager.getSkillImage(skill), client, config);
indicators[skill.ordinal()] = indicator;
}
if (!infoBoxManager.getInfoBoxes().contains(indicator))
{
infoBoxManager.addInfoBox(indicator);
}
}
else
{
if (indicator != null && infoBoxManager.getInfoBoxes().contains(indicator))
{
infoBoxManager.removeInfoBox(indicator);
}
String str;
Color strColor = Color.WHITE;
if (!config.useRelativeBoost())

View File

@@ -28,6 +28,7 @@ import com.google.common.collect.ObjectArrays;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Binder;
import com.google.inject.Provides;
import java.util.Arrays;
import javax.inject.Inject;
import lombok.Getter;
import net.runelite.api.Skill;
@@ -93,35 +94,25 @@ public class BoostsPlugin extends Plugin
}
}
@Override
protected void shutDown() throws Exception
{
infoBoxManager.removeIf(t -> t instanceof BoostIndicator);
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (!config.enabled())
{
infoBoxManager.removeIf(t -> t instanceof BoostIndicator);
return;
}
updateShownSkills(config.enableSkill());
if (event.getKey().equals("displayIndicators"))
{
for (BoostIndicator indicator : boostsOverlay.getIndicators())
{
if (indicator == null)
{
continue;
}
if (config.displayIndicators())
{
infoBoxManager.addInfoBox(indicator);
}
else
{
infoBoxManager.removeInfoBox(indicator);
}
}
}
infoBoxManager.removeIf(t -> t instanceof BoostIndicator
&& !Arrays.asList(shownSkills).contains(((BoostIndicator) t).getSkill()));
}
private void updateShownSkills(boolean showSkillingSkills)