Merge pull request #11334 from while-loop/xp-tracker-ttl
xp-tracker: Add Time-To-Level to Canvas And XP Tracker
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||||
* Copyright (c) 2018, Psikoi <https://github.com/psikoi>
|
* Copyright (c) 2018, Psikoi <https://github.com/psikoi>
|
||||||
|
* Copyright (c) 2020, Anthony <https://github.com/while-loop>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -60,7 +61,7 @@ import net.runelite.client.util.QuantityFormatter;
|
|||||||
|
|
||||||
class XpInfoBox extends JPanel
|
class XpInfoBox extends JPanel
|
||||||
{
|
{
|
||||||
private static final DecimalFormat TWO_DECIMAL_FORMAT = new DecimalFormat("0.00");
|
static final DecimalFormat TWO_DECIMAL_FORMAT = new DecimalFormat("0.00");
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
@@ -95,10 +96,10 @@ class XpInfoBox extends JPanel
|
|||||||
|
|
||||||
private final ProgressBar progressBar = new ProgressBar();
|
private final ProgressBar progressBar = new ProgressBar();
|
||||||
|
|
||||||
private final JLabel expGained = new JLabel();
|
private final JLabel topLeftStat = new JLabel();
|
||||||
private final JLabel expHour = new JLabel();
|
private final JLabel bottomLeftStat = new JLabel();
|
||||||
private final JLabel expLeft = new JLabel();
|
private final JLabel topRightStat = new JLabel();
|
||||||
private final JLabel actionsLeft = new JLabel();
|
private final JLabel bottomRightStat = new JLabel();
|
||||||
private final JMenuItem pauseSkill = new JMenuItem("Pause");
|
private final JMenuItem pauseSkill = new JMenuItem("Pause");
|
||||||
private final JMenuItem canvasItem = new JMenuItem(ADD_STATE);
|
private final JMenuItem canvasItem = new JMenuItem(ADD_STATE);
|
||||||
|
|
||||||
@@ -184,15 +185,16 @@ class XpInfoBox extends JPanel
|
|||||||
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
|
||||||
statsPanel.setBorder(new EmptyBorder(9, 2, 9, 2));
|
statsPanel.setBorder(new EmptyBorder(9, 2, 9, 2));
|
||||||
|
|
||||||
expGained.setFont(FontManager.getRunescapeSmallFont());
|
|
||||||
expHour.setFont(FontManager.getRunescapeSmallFont());
|
|
||||||
expLeft.setFont(FontManager.getRunescapeSmallFont());
|
|
||||||
actionsLeft.setFont(FontManager.getRunescapeSmallFont());
|
|
||||||
|
|
||||||
statsPanel.add(expGained);
|
topLeftStat.setFont(FontManager.getRunescapeSmallFont());
|
||||||
statsPanel.add(expLeft);
|
bottomLeftStat.setFont(FontManager.getRunescapeSmallFont());
|
||||||
statsPanel.add(expHour);
|
topRightStat.setFont(FontManager.getRunescapeSmallFont());
|
||||||
statsPanel.add(actionsLeft);
|
bottomRightStat.setFont(FontManager.getRunescapeSmallFont());
|
||||||
|
|
||||||
|
statsPanel.add(topLeftStat); // top left
|
||||||
|
statsPanel.add(topRightStat); // top right
|
||||||
|
statsPanel.add(bottomLeftStat); // bottom left
|
||||||
|
statsPanel.add(bottomRightStat); // bottom right
|
||||||
|
|
||||||
headerPanel.add(skillIcon, BorderLayout.WEST);
|
headerPanel.add(skillIcon, BorderLayout.WEST);
|
||||||
headerPanel.add(statsPanel, BorderLayout.CENTER);
|
headerPanel.add(statsPanel, BorderLayout.CENTER);
|
||||||
@@ -243,14 +245,9 @@ class XpInfoBox extends JPanel
|
|||||||
|
|
||||||
paused = skillPaused;
|
paused = skillPaused;
|
||||||
|
|
||||||
// Update information labels
|
|
||||||
expGained.setText(htmlLabel("XP Gained: ", xpSnapshotSingle.getXpGainedInSession()));
|
|
||||||
expLeft.setText(htmlLabel("XP Left: ", xpSnapshotSingle.getXpRemainingToGoal()));
|
|
||||||
actionsLeft.setText(htmlLabel(xpSnapshotSingle.getActionType().getLabel() + ": ", xpSnapshotSingle.getActionsRemainingToGoal()));
|
|
||||||
|
|
||||||
// Update progress bar
|
// Update progress bar
|
||||||
progressBar.setValue((int) xpSnapshotSingle.getSkillProgressToGoal());
|
progressBar.setValue((int) xpSnapshotSingle.getSkillProgressToGoal());
|
||||||
progressBar.setCenterLabel(TWO_DECIMAL_FORMAT.format(xpSnapshotSingle.getSkillProgressToGoal()) + "%");
|
progressBar.setCenterLabel(xpTrackerConfig.progressBarLabel().getValueFunc().apply(xpSnapshotSingle));
|
||||||
progressBar.setLeftLabel("Lvl. " + xpSnapshotSingle.getStartLevel());
|
progressBar.setLeftLabel("Lvl. " + xpSnapshotSingle.getStartLevel());
|
||||||
progressBar.setRightLabel(xpSnapshotSingle.getEndGoalXp() == Experience.MAX_SKILL_XP
|
progressBar.setRightLabel(xpSnapshotSingle.getEndGoalXp() == Experience.MAX_SKILL_XP
|
||||||
? "200M"
|
? "200M"
|
||||||
@@ -304,13 +301,29 @@ class XpInfoBox extends JPanel
|
|||||||
pauseSkill.setText("Pause");
|
pauseSkill.setText("Pause");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update information labels
|
||||||
// Update exp per hour separately, every time (not only when there's an update)
|
// Update exp per hour separately, every time (not only when there's an update)
|
||||||
expHour.setText(htmlLabel("XP/Hour: ", xpSnapshotSingle.getXpPerHour()));
|
topLeftStat.setText(htmlLabel(xpTrackerConfig.xpPanelLabel1(), xpSnapshotSingle));
|
||||||
|
topRightStat.setText(htmlLabel(xpTrackerConfig.xpPanelLabel2(), xpSnapshotSingle));
|
||||||
|
bottomLeftStat.setText(htmlLabel(xpTrackerConfig.xpPanelLabel3(), xpSnapshotSingle));
|
||||||
|
bottomRightStat.setText(htmlLabel(xpTrackerConfig.xpPanelLabel4(), xpSnapshotSingle));
|
||||||
|
}
|
||||||
|
|
||||||
|
static String htmlLabel(XpPanelLabel panelLabel, XpSnapshotSingle xpSnapshotSingle)
|
||||||
|
{
|
||||||
|
String key = panelLabel.getActionKey(xpSnapshotSingle) + ": ";
|
||||||
|
String value = panelLabel.getValueFunc().apply(xpSnapshotSingle);
|
||||||
|
return htmlLabel(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String htmlLabel(String key, int value)
|
static String htmlLabel(String key, int value)
|
||||||
{
|
{
|
||||||
String valueStr = QuantityFormatter.quantityToRSDecimalStack(value, true);
|
String valueStr = QuantityFormatter.quantityToRSDecimalStack(value, true);
|
||||||
|
return htmlLabel(key, valueStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String htmlLabel(String key, String valueStr)
|
||||||
|
{
|
||||||
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR), key, valueStr);
|
return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR), key, valueStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Jasper Ketelaar <Jasper0781@gmail.com>
|
* Copyright (c) 2018, Jasper Ketelaar <Jasper0781@gmail.com>
|
||||||
|
* Copyright (c) 2020, Anthony <https://github.com/while-loop>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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.PanelComponent;
|
||||||
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
|
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
|
||||||
import net.runelite.client.ui.overlay.components.SplitComponent;
|
import net.runelite.client.ui.overlay.components.SplitComponent;
|
||||||
import net.runelite.client.util.QuantityFormatter;
|
|
||||||
|
|
||||||
class XpInfoBoxOverlay extends OverlayPanel
|
class XpInfoBoxOverlay extends OverlayPanel
|
||||||
{
|
{
|
||||||
@@ -91,54 +91,20 @@ class XpInfoBoxOverlay extends OverlayPanel
|
|||||||
|
|
||||||
final XpSnapshotSingle snapshot = plugin.getSkillSnapshot(skill);
|
final XpSnapshotSingle snapshot = plugin.getSkillSnapshot(skill);
|
||||||
|
|
||||||
final String leftStr;
|
final String leftStr = config.onScreenDisplayMode().getActionKey(snapshot);
|
||||||
final int rightNum;
|
final String rightNum = config.onScreenDisplayMode().getValueFunc().apply(snapshot);
|
||||||
|
|
||||||
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 LineComponent xpLine = LineComponent.builder()
|
final LineComponent xpLine = LineComponent.builder()
|
||||||
.left(leftStr + ":")
|
.left(leftStr + ":")
|
||||||
.right(QuantityFormatter.quantityToRSDecimalStack(rightNum, true))
|
.right(rightNum)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final String bottemLeftStr;
|
final String bottomLeftStr = config.onScreenDisplayModeBottom().getActionKey(snapshot);
|
||||||
final int bottomRightNum;
|
final String bottomRightNum = config.onScreenDisplayModeBottom().getValueFunc().apply(snapshot);
|
||||||
|
|
||||||
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 LineComponent xpLineBottom = LineComponent.builder()
|
final LineComponent xpLineBottom = LineComponent.builder()
|
||||||
.left(bottemLeftStr + ":")
|
.left(bottomLeftStr + ":")
|
||||||
.right(QuantityFormatter.quantityToRSDecimalStack(bottomRightNum, true))
|
.right(bottomRightNum)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final SplitComponent xpSplit = SplitComponent.builder()
|
final SplitComponent xpSplit = SplitComponent.builder()
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Anthony <https://github.com/while-loop>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.plugins.xptracker;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum XpPanelLabel
|
||||||
|
{
|
||||||
|
TIME_TO_LEVEL("TTL", XpSnapshotSingle::getTimeTillGoalShort),
|
||||||
|
|
||||||
|
XP_GAINED("XP Gained", snap -> format(snap.getXpGainedInSession())),
|
||||||
|
XP_HOUR("XP/hr", snap -> format(snap.getXpPerHour())),
|
||||||
|
XP_LEFT("XP Left", snap -> format(snap.getXpRemainingToGoal())),
|
||||||
|
|
||||||
|
ACTIONS_LEFT("Actions", snap -> format(snap.getActionsRemainingToGoal())),
|
||||||
|
ACTIONS_HOUR("Actions/hr", snap -> format(snap.getActionsPerHour())),
|
||||||
|
ACTIONS_DONE("Actions Done", snap -> format(snap.getActionsInSession())),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String key;
|
||||||
|
private final Function<XpSnapshotSingle, String> valueFunc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the action key label based on if the Action type is an xp drop or kill
|
||||||
|
*
|
||||||
|
* @param snapshot
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getActionKey(XpSnapshotSingle snapshot)
|
||||||
|
{
|
||||||
|
String actionKey = key;
|
||||||
|
if (snapshot.getActionType() == XpActionType.ACTOR_HEALTH)
|
||||||
|
{
|
||||||
|
return actionKey.replace("Action", "Kill");
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String format(int val)
|
||||||
|
{
|
||||||
|
return QuantityFormatter.quantityToRSDecimalStack(val, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Anthony <https://github.com/while-loop>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.plugins.xptracker;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import static net.runelite.client.plugins.xptracker.XpInfoBox.TWO_DECIMAL_FORMAT;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum XpProgressBarLabel
|
||||||
|
{
|
||||||
|
PERCENTAGE((snap) -> TWO_DECIMAL_FORMAT.format(snap.getSkillProgressToGoal()) + "%"),
|
||||||
|
TIME_TO_LEVEL(XpSnapshotSingle::getTimeTillGoal),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final Function<XpSnapshotSingle, String> valueFunc;
|
||||||
|
}
|
||||||
@@ -44,4 +44,5 @@ class XpSnapshotSingle
|
|||||||
private int actionsRemainingToGoal;
|
private int actionsRemainingToGoal;
|
||||||
private int actionsPerHour;
|
private int actionsPerHour;
|
||||||
private String timeTillGoal;
|
private String timeTillGoal;
|
||||||
|
private String timeTillGoalShort;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Cameron <moberg@tuta.io>
|
* Copyright (c) 2017, Cameron <moberg@tuta.io>
|
||||||
* Copyright (c) 2018, Levi <me@levischuck.com>
|
* Copyright (c) 2018, Levi <me@levischuck.com>
|
||||||
|
* Copyright (c) 2020, Anthony <https://github.com/while-loop>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -128,24 +129,31 @@ class XpStateSingle
|
|||||||
return (xpGained / xpGoal) * 100;
|
return (xpGained / xpGoal) * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTimeTillLevel()
|
private long getSecondsTillLevel()
|
||||||
{
|
{
|
||||||
|
// Java 8 doesn't have good duration / period objects to represent spans of time that can be formatted
|
||||||
|
// Rather than importing another dependency like joda time (which is practically built into java 10)
|
||||||
|
// below will be a custom formatter that handles spans larger than 1 day
|
||||||
long seconds = getTimeElapsedInSeconds();
|
long seconds = getTimeElapsedInSeconds();
|
||||||
|
|
||||||
if (seconds <= 0 || xpGained <= 0)
|
if (seconds <= 0 || xpGained <= 0)
|
||||||
{
|
{
|
||||||
// Infinity symbol
|
return -1;
|
||||||
return "\u221e";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// formula is xpRemaining / xpPerSecond
|
// formula is xpRemaining / xpPerSecond
|
||||||
// xpPerSecond being xpGained / seconds
|
// xpPerSecond being xpGained / seconds
|
||||||
// This can be simplified so division is only done once and we can work in whole numbers!
|
// This can be simplified so division is only done once and we can work in whole numbers!
|
||||||
long remainingSeconds = (getXpRemaining() * seconds) / xpGained;
|
return (getXpRemaining() * seconds) / xpGained;
|
||||||
|
}
|
||||||
|
|
||||||
// Java 8 doesn't have good duration / period objects to represent spans of time that can be formatted
|
private String getTimeTillLevel()
|
||||||
// Rather than importing another dependency like joda time (which is practically built into java 10)
|
{
|
||||||
// below will be a custom formatter that handles spans larger than 1 day
|
long remainingSeconds = getSecondsTillLevel();
|
||||||
|
if (remainingSeconds < 0)
|
||||||
|
{
|
||||||
|
return "\u221e";
|
||||||
|
}
|
||||||
|
|
||||||
long durationDays = remainingSeconds / (24 * 60 * 60);
|
long durationDays = remainingSeconds / (24 * 60 * 60);
|
||||||
long durationHours = (remainingSeconds % (24 * 60 * 60)) / (60 * 60);
|
long durationHours = (remainingSeconds % (24 * 60 * 60)) / (60 * 60);
|
||||||
@@ -160,7 +168,29 @@ class XpStateSingle
|
|||||||
{
|
{
|
||||||
return String.format("1 day %02d:%02d:%02d", durationHours, durationMinutes, durationSeconds);
|
return String.format("1 day %02d:%02d:%02d", durationHours, durationMinutes, durationSeconds);
|
||||||
}
|
}
|
||||||
else if (durationHours > 0)
|
|
||||||
|
// durationDays = 0 if we got here.
|
||||||
|
// return time remaining in hh:mm:ss or mm:ss format
|
||||||
|
return getTimeTillLevelShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get time to level in `hh:mm:ss` or `mm:ss` format,
|
||||||
|
* where `hh` can be > 24.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getTimeTillLevelShort()
|
||||||
|
{
|
||||||
|
long remainingSeconds = getSecondsTillLevel();
|
||||||
|
if (remainingSeconds < 0)
|
||||||
|
{
|
||||||
|
return "\u221e";
|
||||||
|
}
|
||||||
|
|
||||||
|
long durationHours = remainingSeconds / (60 * 60);
|
||||||
|
long durationMinutes = (remainingSeconds % (60 * 60)) / 60;
|
||||||
|
long durationSeconds = remainingSeconds % 60;
|
||||||
|
if (durationHours > 0)
|
||||||
{
|
{
|
||||||
return String.format("%02d:%02d:%02d", durationHours, durationMinutes, durationSeconds);
|
return String.format("%02d:%02d:%02d", durationHours, durationMinutes, durationSeconds);
|
||||||
}
|
}
|
||||||
@@ -269,6 +299,7 @@ class XpStateSingle
|
|||||||
.actionsRemainingToGoal(getActionsRemaining())
|
.actionsRemainingToGoal(getActionsRemaining())
|
||||||
.actionsPerHour(getActionsHr())
|
.actionsPerHour(getActionsHr())
|
||||||
.timeTillGoal(getTimeTillLevel())
|
.timeTillGoal(getTimeTillLevel())
|
||||||
|
.timeTillGoalShort(getTimeTillLevelShort())
|
||||||
.startGoalXp(startLevelExp)
|
.startGoalXp(startLevelExp)
|
||||||
.endGoalXp(endLevelExp)
|
.endGoalXp(endLevelExp)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Levi <me@levischuck.com>
|
* Copyright (c) 2018, Levi <me@levischuck.com>
|
||||||
|
* Copyright (c) 2020, Anthony <https://github.com/while-loop>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -24,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.xptracker;
|
package net.runelite.client.plugins.xptracker;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import net.runelite.client.config.Config;
|
import net.runelite.client.config.Config;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
@@ -33,22 +33,6 @@ import net.runelite.client.config.Units;
|
|||||||
@ConfigGroup("xpTracker")
|
@ConfigGroup("xpTracker")
|
||||||
public interface XpTrackerConfig extends Config
|
public interface XpTrackerConfig extends Config
|
||||||
{
|
{
|
||||||
@AllArgsConstructor
|
|
||||||
enum OnScreenDisplayMode
|
|
||||||
{
|
|
||||||
XP_GAINED,
|
|
||||||
XP_LEFT,
|
|
||||||
ACTIONS_DONE,
|
|
||||||
ACTIONS_LEFT
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
enum OnScreenDisplayModeBottom
|
|
||||||
{
|
|
||||||
XP_HOUR,
|
|
||||||
ACTIONS_HOUR,
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 0,
|
position = 0,
|
||||||
keyName = "hideMaxed",
|
keyName = "hideMaxed",
|
||||||
@@ -111,9 +95,9 @@ public interface XpTrackerConfig extends Config
|
|||||||
name = "On-screen tracker display mode (top)",
|
name = "On-screen tracker display mode (top)",
|
||||||
description = "Configures the information displayed in the first line of on-screen XP overlays"
|
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(
|
@ConfigItem(
|
||||||
@@ -122,8 +106,64 @@ public interface XpTrackerConfig extends Config
|
|||||||
name = "On-screen tracker display mode (bottom)",
|
name = "On-screen tracker display mode (bottom)",
|
||||||
description = "Configures the information displayed in the second line of on-screen XP overlays"
|
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(
|
||||||
|
position = 7,
|
||||||
|
keyName = "xpPanelLabel1",
|
||||||
|
name = "Top-left XP info label",
|
||||||
|
description = "Configures the information displayed in the top-left of XP info box"
|
||||||
|
)
|
||||||
|
default XpPanelLabel xpPanelLabel1()
|
||||||
|
{
|
||||||
|
return XpPanelLabel.XP_GAINED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 8,
|
||||||
|
keyName = "xpPanelLabel2",
|
||||||
|
name = "Top-right XP info label",
|
||||||
|
description = "Configures the information displayed in the top-right of XP info box"
|
||||||
|
)
|
||||||
|
|
||||||
|
default XpPanelLabel xpPanelLabel2()
|
||||||
|
{
|
||||||
|
return XpPanelLabel.XP_LEFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 9,
|
||||||
|
keyName = "xpPanelLabel3",
|
||||||
|
name = "Bottom-left XP info label",
|
||||||
|
description = "Configures the information displayed in the bottom-left of XP info box"
|
||||||
|
)
|
||||||
|
default XpPanelLabel xpPanelLabel3()
|
||||||
|
{
|
||||||
|
return XpPanelLabel.XP_HOUR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 10,
|
||||||
|
keyName = "xpPanelLabel4",
|
||||||
|
name = "Bottom-right XP info label",
|
||||||
|
description = "Configures the information displayed in the bottom-right of XP info box"
|
||||||
|
)
|
||||||
|
default XpPanelLabel xpPanelLabel4()
|
||||||
|
{
|
||||||
|
return XpPanelLabel.ACTIONS_LEFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 11,
|
||||||
|
keyName = "progressBarLabel",
|
||||||
|
name = "Progress bar label",
|
||||||
|
description = "Configures the info box progress bar to show Time to goal or percentage complete"
|
||||||
|
)
|
||||||
|
default XpProgressBarLabel progressBarLabel()
|
||||||
|
{
|
||||||
|
return XpProgressBarLabel.PERCENTAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user