xp tracker (onscreen): add toggle between displaying XP Left/XP Gained

This commit is contained in:
Lotto
2019-05-07 17:00:51 +02:00
parent c95cd3bfd5
commit ad16bf5b3f
3 changed files with 18 additions and 3 deletions

View File

@@ -56,6 +56,7 @@ class XpInfoBoxOverlay extends Overlay
private final PanelComponent panel = new PanelComponent();
private final PanelComponent iconXpSplitPanel = new PanelComponent();
private final XpTrackerPlugin plugin;
private final XpTrackerConfig config;
@Getter(AccessLevel.PACKAGE)
private final Skill skill;
@@ -63,11 +64,13 @@ class XpInfoBoxOverlay extends Overlay
XpInfoBoxOverlay(
XpTrackerPlugin plugin,
XpTrackerConfig config,
Skill skill,
BufferedImage icon)
{
super(plugin);
this.plugin = plugin;
this.config = config;
this.skill = skill;
this.icon = icon;
panel.setBorder(new Rectangle(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
@@ -90,8 +93,9 @@ class XpInfoBoxOverlay extends Overlay
final XpSnapshotSingle snapshot = plugin.getSkillSnapshot(skill);
final LineComponent xpLine = LineComponent.builder()
.left("XP Gained:")
.right(StackFormatter.quantityToRSDecimalStack(snapshot.getXpGainedInSession()))
.left(config.displayXpLeftOnScreen() ? "XP Left:" : "XP Gained:")
.right(StackFormatter.quantityToRSDecimalStack(config.displayXpLeftOnScreen()
? snapshot.getXpRemainingToGoal() : snapshot.getXpGainedInSession()))
.build();
final LineComponent xpHour = LineComponent.builder()

View File

@@ -74,4 +74,15 @@ public interface XpTrackerConfig extends Config
{
return 0;
}
@ConfigItem(
position = 4,
keyName = "onScreenXpLeft",
name = "Display XP Left on-screen",
description = "Display remaining experience instead of experience gained on on-screen trackers"
)
default boolean displayXpLeftOnScreen()
{
return false;
}
}

View File

@@ -221,7 +221,7 @@ public class XpTrackerPlugin extends Plugin
void addOverlay(Skill skill)
{
removeOverlay(skill);
overlayManager.add(new XpInfoBoxOverlay(this, skill, skillIconManager.getSkillImage(skill)));
overlayManager.add(new XpInfoBoxOverlay(this, xpTrackerConfig, skill, skillIconManager.getSkillImage(skill)));
}
/**