Merge pull request #8249 from paulbcook/xpbar

Use consistent rounding for XP bar markers
This commit is contained in:
Adam
2019-04-09 16:48:38 -04:00
committed by GitHub
2 changed files with 5 additions and 5 deletions

View File

@@ -215,13 +215,13 @@ class XpInfoBox extends JPanel
// Add intermediate level positions to progressBar
if (xpTrackerConfig.showIntermediateLevels() && xpSnapshotSingle.getEndLevel() - xpSnapshotSingle.getStartLevel() > 1)
{
final List<Double> positions = new ArrayList<>();
final List<Integer> positions = new ArrayList<>();
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);
positions.add((int) (relativeStartExperience / relativeEndExperience * 100));
}
progressBar.setPositions(positions);

View File

@@ -49,7 +49,7 @@ public class ProgressBar extends DimmableJPanel
private int value;
@Setter
private List<Double> positions = Collections.emptyList();
private List<Integer> positions = Collections.emptyList();
private final JLabel leftLabel = new JShadowedLabel();
private final JLabel rightLabel = new JShadowedLabel();
@@ -95,9 +95,9 @@ public class ProgressBar extends DimmableJPanel
g.setColor(getForeground());
g.fillRect(0, 0, topWidth, 16);
for (final Double position : positions)
for (final Integer position : positions)
{
final int xCord = (int) (getSize().width * position);
final int xCord = getSize().width * position / maximumValue;
if (xCord > topWidth)
{
g.fillRect(xCord, 0, 1, 16);