From 240b14453f018ddc7bf85ebd0ad68bd03391f899 Mon Sep 17 00:00:00 2001 From: Anthony Alves Date: Mon, 20 Apr 2020 20:36:48 -0400 Subject: [PATCH] xp-tracker: add more configurable labels to canvas overlay --- .../plugins/xptracker/XpInfoBoxOverlay.java | 50 +++---------------- .../plugins/xptracker/XpTrackerConfig.java | 25 ++-------- 2 files changed, 12 insertions(+), 63 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBoxOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBoxOverlay.java index ec9ab50b71..95f9beefbd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBoxOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBoxOverlay.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2018, Jasper Ketelaar + * Copyright (c) 2020, Anthony * 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() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerConfig.java index 4ebeb2a075..f2655bb127 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerConfig.java @@ -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(