Add ntermediate progress markers for xptracker plugin (#6895)
Closes #6863
This commit is contained in:
committed by
Tomas Slusny
parent
b6406c30a5
commit
10a3c4139e
@@ -30,6 +30,8 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
@@ -88,10 +90,13 @@ class XpInfoBox extends JPanel
|
|||||||
private final JLabel actionsLeft = new JLabel();
|
private final JLabel actionsLeft = new JLabel();
|
||||||
private final JMenuItem pauseSkill = new JMenuItem("Pause");
|
private final JMenuItem pauseSkill = new JMenuItem("Pause");
|
||||||
|
|
||||||
|
private final XpTrackerConfig xpTrackerConfig;
|
||||||
|
|
||||||
private boolean paused = false;
|
private boolean paused = false;
|
||||||
|
|
||||||
XpInfoBox(XpTrackerPlugin xpTrackerPlugin, Client client, JPanel panel, Skill skill, SkillIconManager iconManager) throws IOException
|
XpInfoBox(XpTrackerPlugin xpTrackerPlugin, XpTrackerConfig xpTrackerConfig, Client client, JPanel panel, Skill skill, SkillIconManager iconManager) throws IOException
|
||||||
{
|
{
|
||||||
|
this.xpTrackerConfig = xpTrackerConfig;
|
||||||
this.panel = panel;
|
this.panel = panel;
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
|
|
||||||
@@ -207,6 +212,24 @@ class XpInfoBox extends JPanel
|
|||||||
? "200M"
|
? "200M"
|
||||||
: "Lvl. " + xpSnapshotSingle.getEndLevel());
|
: "Lvl. " + xpSnapshotSingle.getEndLevel());
|
||||||
|
|
||||||
|
// Add intermediate level positions to progressBar
|
||||||
|
final List<Double> positions = new ArrayList<>();
|
||||||
|
if (xpTrackerConfig.showIntermediateLevels() && xpSnapshotSingle.getEndLevel() - xpSnapshotSingle.getStartLevel() > 1)
|
||||||
|
{
|
||||||
|
for (int level = xpSnapshotSingle.getStartLevel() + 1; level < xpSnapshotSingle.getEndLevel(); level++)
|
||||||
|
{
|
||||||
|
double relativeStartExperience = Experience.getXpForLevel(level) - xpSnapshotSingle.getStartGoalXp();
|
||||||
|
double relativeEndExperience = xpSnapshotSingle.getEndGoalXp() - xpSnapshotSingle.getStartGoalXp();
|
||||||
|
positions.add(relativeStartExperience / relativeEndExperience);
|
||||||
|
}
|
||||||
|
|
||||||
|
progressBar.setPositions(positions);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
progressBar.setPositions(positions);
|
||||||
|
}
|
||||||
|
|
||||||
progressBar.setToolTipText(String.format(
|
progressBar.setToolTipText(String.format(
|
||||||
HTML_TOOL_TIP_TEMPLATE,
|
HTML_TOOL_TIP_TEMPLATE,
|
||||||
xpSnapshotSingle.getActionsInSession(),
|
xpSnapshotSingle.getActionsInSession(),
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class XpPanel extends PluginPanel
|
|||||||
/* This displays the "No exp gained" text */
|
/* This displays the "No exp gained" text */
|
||||||
private final PluginErrorPanel errorPanel = new PluginErrorPanel();
|
private final PluginErrorPanel errorPanel = new PluginErrorPanel();
|
||||||
|
|
||||||
XpPanel(XpTrackerPlugin xpTrackerPlugin, Client client, SkillIconManager iconManager)
|
XpPanel(XpTrackerPlugin xpTrackerPlugin, XpTrackerConfig xpTrackerConfig, Client client, SkillIconManager iconManager)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ class XpPanel extends PluginPanel
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
infoBoxes.put(skill, new XpInfoBox(xpTrackerPlugin, client, infoBoxPanel, skill, iconManager));
|
infoBoxes.put(skill, new XpInfoBox(xpTrackerPlugin, xpTrackerConfig, client, infoBoxPanel, skill, iconManager));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
|||||||
@@ -55,6 +55,17 @@ public interface XpTrackerConfig extends Config
|
|||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 2,
|
position = 2,
|
||||||
|
keyName = "intermediateLevelMarkers",
|
||||||
|
name = "Show intermediate level markers",
|
||||||
|
description = "Marks intermediate levels on the progressbar"
|
||||||
|
)
|
||||||
|
default boolean showIntermediateLevels()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 3,
|
||||||
keyName = "pauseSkillAfter",
|
keyName = "pauseSkillAfter",
|
||||||
name = "Auto pause after",
|
name = "Auto pause after",
|
||||||
description = "Configures how many minutes passes before pausing a skill while in game and there's no XP, 0 means disabled"
|
description = "Configures how many minutes passes before pausing a skill while in game and there's no XP, 0 means disabled"
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
xpPanel = new XpPanel(this, client, skillIconManager);
|
xpPanel = new XpPanel(this, xpTrackerConfig, client, skillIconManager);
|
||||||
|
|
||||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "/skill_icons/overall.png");
|
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "/skill_icons/overall.png");
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import java.awt.BorderLayout;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
@@ -46,6 +48,9 @@ public class ProgressBar extends DimmableJPanel
|
|||||||
@Setter
|
@Setter
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private List<Double> positions = new ArrayList<>();
|
||||||
|
|
||||||
private final JLabel leftLabel = new JShadowedLabel();
|
private final JLabel leftLabel = new JShadowedLabel();
|
||||||
private final JLabel rightLabel = new JShadowedLabel();
|
private final JLabel rightLabel = new JShadowedLabel();
|
||||||
private final JLabel centerLabel = new JShadowedLabel();
|
private final JLabel centerLabel = new JShadowedLabel();
|
||||||
@@ -89,6 +94,17 @@ public class ProgressBar extends DimmableJPanel
|
|||||||
super.paint(g);
|
super.paint(g);
|
||||||
g.setColor(getForeground());
|
g.setColor(getForeground());
|
||||||
g.fillRect(0, 0, topWidth, 16);
|
g.fillRect(0, 0, topWidth, 16);
|
||||||
|
g.setColor(getForeground().darker());
|
||||||
|
|
||||||
|
for (final Double position : positions)
|
||||||
|
{
|
||||||
|
final int xCord = (int) (getSize().width * (position));
|
||||||
|
if (xCord > topWidth)
|
||||||
|
{
|
||||||
|
g.fillRect(xCord, 0, 1, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
super.paintComponents(g);
|
super.paintComponents(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,4 +158,4 @@ public class ProgressBar extends DimmableJPanel
|
|||||||
|
|
||||||
return (value * 100) / maximumValue;
|
return (value * 100) / maximumValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user