xp-tracker: add more configurable labels to canvas overlay

This commit is contained in:
Anthony Alves
2020-04-20 20:36:48 -04:00
parent 3cb2f68725
commit 240b14453f
2 changed files with 12 additions and 63 deletions

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018, Jasper Ketelaar <Jasper0781@gmail.com>
* Copyright (c) 2020, Anthony <https://github.com/while-loop>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -46,7 +47,6 @@ import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
import net.runelite.client.ui.overlay.components.SplitComponent;
import net.runelite.client.util.QuantityFormatter;
class XpInfoBoxOverlay extends OverlayPanel
{
@@ -91,54 +91,20 @@ class XpInfoBoxOverlay extends OverlayPanel
final XpSnapshotSingle snapshot = plugin.getSkillSnapshot(skill);
final String leftStr;
final int rightNum;
switch (config.onScreenDisplayMode())
{
case ACTIONS_DONE:
leftStr = snapshot.getActionType().getLabel() + " Done";
rightNum = snapshot.getActionsInSession();
break;
case ACTIONS_LEFT:
leftStr = snapshot.getActionType().getLabel() + " Left";
rightNum = snapshot.getActionsRemainingToGoal();
break;
case XP_LEFT:
leftStr = "XP Left";
rightNum = snapshot.getXpRemainingToGoal();
break;
case XP_GAINED:
default:
leftStr = "XP Gained";
rightNum = snapshot.getXpGainedInSession();
break;
}
final String leftStr = config.onScreenDisplayMode().getActionKey(snapshot);
final String rightNum = config.onScreenDisplayMode().getValueFunc().apply(snapshot);
final LineComponent xpLine = LineComponent.builder()
.left(leftStr + ":")
.right(QuantityFormatter.quantityToRSDecimalStack(rightNum, true))
.right(rightNum)
.build();
final String bottemLeftStr;
final int bottomRightNum;
switch (config.onScreenDisplayModeBottom())
{
case ACTIONS_HOUR:
bottemLeftStr = snapshot.getActionType().getLabel() + "/Hour";
bottomRightNum = snapshot.getActionsPerHour();
break;
case XP_HOUR:
default:
bottemLeftStr = "XP/Hour";
bottomRightNum = snapshot.getXpPerHour();
break;
}
final String bottomLeftStr = config.onScreenDisplayModeBottom().getActionKey(snapshot);
final String bottomRightNum = config.onScreenDisplayModeBottom().getValueFunc().apply(snapshot);
final LineComponent xpLineBottom = LineComponent.builder()
.left(bottemLeftStr + ":")
.right(QuantityFormatter.quantityToRSDecimalStack(bottomRightNum, true))
.left(bottomLeftStr + ":")
.right(bottomRightNum)
.build();
final SplitComponent xpSplit = SplitComponent.builder()

View File

@@ -25,7 +25,6 @@
*/
package net.runelite.client.plugins.xptracker;
import lombok.AllArgsConstructor;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@@ -34,22 +33,6 @@ import net.runelite.client.config.Units;
@ConfigGroup("xpTracker")
public interface XpTrackerConfig extends Config
{
@AllArgsConstructor
enum OnScreenDisplayMode
{
XP_GAINED,
XP_LEFT,
ACTIONS_DONE,
ACTIONS_LEFT
}
@AllArgsConstructor
enum OnScreenDisplayModeBottom
{
XP_HOUR,
ACTIONS_HOUR,
}
@ConfigItem(
position = 0,
keyName = "hideMaxed",
@@ -112,9 +95,9 @@ public interface XpTrackerConfig extends Config
name = "On-screen tracker display mode (top)",
description = "Configures the information displayed in the first line of on-screen XP overlays"
)
default OnScreenDisplayMode onScreenDisplayMode()
default XpPanelLabel onScreenDisplayMode()
{
return OnScreenDisplayMode.XP_GAINED;
return XpPanelLabel.XP_GAINED;
}
@ConfigItem(
@@ -123,9 +106,9 @@ public interface XpTrackerConfig extends Config
name = "On-screen tracker display mode (bottom)",
description = "Configures the information displayed in the second line of on-screen XP overlays"
)
default OnScreenDisplayModeBottom onScreenDisplayModeBottom()
default XpPanelLabel onScreenDisplayModeBottom()
{
return OnScreenDisplayModeBottom.XP_HOUR;
return XpPanelLabel.XP_HOUR;
}
@ConfigItem(