diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpAction.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpAction.java new file mode 100644 index 0000000000..4831c47cbf --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpAction.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018, Tomas Slusny + * 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.Data; + +@Data +class XpAction +{ + private int actions = 0; + private boolean actionsHistoryInitialized = false; + private int[] actionExps = new int[10]; + private int actionExpIndex = 0; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpActionType.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpActionType.java new file mode 100644 index 0000000000..502a77a3d8 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpActionType.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018, Tomas Slusny + * 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; + +@Getter +@AllArgsConstructor +enum XpActionType +{ + EXPERIENCE("Actions"); + + private final String label; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java index 17c1539f4e..7baf54a3ca 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java @@ -59,8 +59,8 @@ class XpInfoBox extends JPanel // Templates private static final String HTML_TOOL_TIP_TEMPLATE = - "%s actions done
" - + "%s actions/hr
" + "%s %s done
" + + "%s %s/hr
" + "%s till goal lvl"; private static final String HTML_LABEL_TEMPLATE = "%s%s"; @@ -197,7 +197,7 @@ class XpInfoBox extends JPanel // Update information labels expGained.setText(htmlLabel("XP Gained: ", xpSnapshotSingle.getXpGainedInSession())); expLeft.setText(htmlLabel("XP Left: ", xpSnapshotSingle.getXpRemainingToGoal())); - actionsLeft.setText(htmlLabel("Actions: ", xpSnapshotSingle.getActionsRemainingToGoal())); + actionsLeft.setText(htmlLabel(xpSnapshotSingle.getActionType().getLabel() + ": ", xpSnapshotSingle.getActionsRemainingToGoal())); // Update progress bar progressBar.setValue((int) xpSnapshotSingle.getSkillProgressToGoal()); @@ -210,7 +210,9 @@ class XpInfoBox extends JPanel progressBar.setToolTipText(String.format( HTML_TOOL_TIP_TEMPLATE, xpSnapshotSingle.getActionsInSession(), + xpSnapshotSingle.getActionType().getLabel(), xpSnapshotSingle.getActionsPerHour(), + xpSnapshotSingle.getActionType().getLabel(), xpSnapshotSingle.getTimeTillGoal())); progressBar.setDimmed(skillPaused); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpSnapshotSingle.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpSnapshotSingle.java index cc087b6bec..bb7f8a5ef7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpSnapshotSingle.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpSnapshotSingle.java @@ -31,6 +31,7 @@ import lombok.Value; @Value class XpSnapshotSingle { + private XpActionType actionType; private int startLevel; private int endLevel; private int startGoalXp; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpStateSingle.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpStateSingle.java index 44e1d079ca..0354f947ef 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpStateSingle.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpStateSingle.java @@ -25,8 +25,11 @@ */ package net.runelite.client.plugins.xptracker; +import java.util.HashMap; +import java.util.Map; import lombok.Getter; import lombok.RequiredArgsConstructor; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Experience; import net.runelite.api.Skill; @@ -36,6 +39,7 @@ import net.runelite.api.Skill; class XpStateSingle { private final Skill skill; + private final Map actions = new HashMap<>(); @Getter private final int startXp; @@ -43,13 +47,18 @@ class XpStateSingle @Getter private int xpGained = 0; + @Setter + private XpActionType actionType = XpActionType.EXPERIENCE; + private long skillTime = 0; - private int actions = 0; private int startLevelExp = 0; private int endLevelExp = 0; - private boolean actionsHistoryInitialized = false; - private int[] actionExps = new int[10]; - private int actionExpIndex = 0; + + private XpAction getXpAction(final XpActionType type) + { + actions.putIfAbsent(type, new XpAction()); + return actions.get(type); + } private int getCurrentXp() { @@ -58,7 +67,7 @@ class XpStateSingle private int getActionsHr() { - return toHourly(actions); + return toHourly(getXpAction(actionType).getActions()); } private int toHourly(int value) @@ -92,12 +101,14 @@ class XpStateSingle private int getActionsRemaining() { - if (actionsHistoryInitialized) + final XpAction action = getXpAction(actionType); + + if (action.isActionsHistoryInitialized()) { - long xpRemaining = getXpRemaining() * actionExps.length; + long xpRemaining = getXpRemaining() * action.getActionExps().length; long totalActionXp = 0; - for (int actionXp : actionExps) + for (int actionXp : action.getActionExps()) { totalActionXp += actionXp; } @@ -186,23 +197,26 @@ class XpStateSingle return false; } - if (actionsHistoryInitialized) + // Update EXPERIENCE action + final XpAction action = getXpAction(XpActionType.EXPERIENCE); + + if (action.isActionsHistoryInitialized()) { - actionExps[actionExpIndex] = actionExp; + action.getActionExps()[action.getActionExpIndex()] = actionExp; } else { // So we have a decent average off the bat, lets populate all values with what we see. - for (int i = 0; i < actionExps.length; i++) + for (int i = 0; i < action.getActionExps().length; i++) { - actionExps[i] = actionExp; + action.getActionExps()[i] = actionExp; } - actionsHistoryInitialized = true; + action.setActionsHistoryInitialized(true); } - actionExpIndex = (actionExpIndex + 1) % actionExps.length; - actions++; + action.setActionExpIndex((action.getActionExpIndex() + 1) % action.getActionExps().length); + action.setActions(action.getActions() + 1); // Calculate experience gained xpGained = currentXp - startXp; @@ -251,7 +265,8 @@ class XpStateSingle .xpRemainingToGoal(getXpRemaining()) .xpPerHour(getXpHr()) .skillProgressToGoal(getSkillProgress()) - .actionsInSession(actions) + .actionType(actionType) + .actionsInSession(getXpAction(actionType).getActions()) .actionsRemainingToGoal(getActionsRemaining()) .actionsPerHour(getActionsHr()) .timeTillGoal(getTimeTillLevel())