Merge pull request #520 from Kamielvf/boosts-indicator-fix
Fix several issues with indicators
This commit is contained in:
@@ -26,6 +26,7 @@ package net.runelite.client.plugins.boosts;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import lombok.Getter;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBox;
|
import net.runelite.client.ui.overlay.infobox.InfoBox;
|
||||||
@@ -34,6 +35,8 @@ public class BoostIndicator extends InfoBox
|
|||||||
{
|
{
|
||||||
private final BoostsConfig config;
|
private final BoostsConfig config;
|
||||||
private final Client client;
|
private final Client client;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final Skill skill;
|
private final Skill skill;
|
||||||
|
|
||||||
public BoostIndicator(Skill skill, BufferedImage image, Client client, BoostsConfig config)
|
public BoostIndicator(Skill skill, BufferedImage image, Client client, BoostsConfig config)
|
||||||
|
|||||||
@@ -84,12 +84,13 @@ class BoostsOverlay extends Overlay
|
|||||||
int boosted = client.getBoostedSkillLevel(skill),
|
int boosted = client.getBoostedSkillLevel(skill),
|
||||||
base = client.getRealSkillLevel(skill);
|
base = client.getRealSkillLevel(skill);
|
||||||
|
|
||||||
|
BoostIndicator indicator = indicators[skill.ordinal()];
|
||||||
|
|
||||||
if (boosted == base)
|
if (boosted == base)
|
||||||
{
|
{
|
||||||
if (indicators[skill.ordinal()] != null)
|
if (indicator != null && infoBoxManager.getInfoBoxes().contains(indicator))
|
||||||
{
|
{
|
||||||
infoBoxManager.removeInfoBox(indicators[skill.ordinal()]);
|
infoBoxManager.removeInfoBox(indicator);
|
||||||
indicators[skill.ordinal()] = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -97,15 +98,24 @@ class BoostsOverlay extends Overlay
|
|||||||
|
|
||||||
if (config.displayIndicators())
|
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;
|
indicators[skill.ordinal()] = indicator;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!infoBoxManager.getInfoBoxes().contains(indicator))
|
||||||
|
{
|
||||||
infoBoxManager.addInfoBox(indicator);
|
infoBoxManager.addInfoBox(indicator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (indicator != null && infoBoxManager.getInfoBoxes().contains(indicator))
|
||||||
|
{
|
||||||
|
infoBoxManager.removeInfoBox(indicator);
|
||||||
|
}
|
||||||
|
|
||||||
String str;
|
String str;
|
||||||
Color strColor = Color.WHITE;
|
Color strColor = Color.WHITE;
|
||||||
if (!config.useRelativeBoost())
|
if (!config.useRelativeBoost())
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.google.common.collect.ObjectArrays;
|
|||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import java.util.Arrays;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.runelite.api.Skill;
|
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
|
@Subscribe
|
||||||
public void onConfigChanged(ConfigChanged event)
|
public void onConfigChanged(ConfigChanged event)
|
||||||
{
|
{
|
||||||
if (!config.enabled())
|
if (!config.enabled())
|
||||||
{
|
{
|
||||||
|
infoBoxManager.removeIf(t -> t instanceof BoostIndicator);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateShownSkills(config.enableSkill());
|
updateShownSkills(config.enableSkill());
|
||||||
|
|
||||||
if (event.getKey().equals("displayIndicators"))
|
infoBoxManager.removeIf(t -> t instanceof BoostIndicator
|
||||||
{
|
&& !Arrays.asList(shownSkills).contains(((BoostIndicator) t).getSkill()));
|
||||||
for (BoostIndicator indicator : boostsOverlay.getIndicators())
|
|
||||||
{
|
|
||||||
if (indicator == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.displayIndicators())
|
|
||||||
{
|
|
||||||
infoBoxManager.addInfoBox(indicator);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
infoBoxManager.removeInfoBox(indicator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShownSkills(boolean showSkillingSkills)
|
private void updateShownSkills(boolean showSkillingSkills)
|
||||||
|
|||||||
Reference in New Issue
Block a user