Skip to content

Commit

Permalink
Merge pull request #108 from conker-rsc/patch-3
Browse files Browse the repository at this point in the history
Show remaining hours to level goal
  • Loading branch information
Hubcapp authored Oct 13, 2022
2 parents dfbe3e6 + db5c608 commit 48c5aa9
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions src/Game/XPBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private static void drawInfoBox(Graphics2D g, int x, int y, int current_skill, b
int height = 50;

if (Client.getShowXpPerHour()[current_skill]) {
height += 12;
height += 24;
}
if (!post99xp) {
height += 20;
Expand All @@ -330,7 +330,7 @@ private static void drawInfoBox(Graphics2D g, int x, int y, int current_skill, b
if (hasGoalForSkill(current_skill)) {
height += 32;
if (Client.getShowXpPerHour()[current_skill]) {
height += 12;
height += 24;
}
}

Expand Down Expand Up @@ -378,6 +378,18 @@ private static void drawInfoBox(Graphics2D g, int x, int y, int current_skill, b
y,
true);
y += 12;

Renderer.drawColoredText(
g,
labelColour
+ "Time until Level: "
+ highlightColour
+ formatHours(
Client.getXPUntilLevel(current_skill) / Client.getXpPerHour()[current_skill]),
x,
y,
true);
y += 12;
}
y += 8;
}
Expand Down Expand Up @@ -405,6 +417,18 @@ private static void drawInfoBox(Graphics2D g, int x, int y, int current_skill, b
y,
true);
y += 12;

Renderer.drawColoredText(
g,
labelColour
+ "Time until Goal: "
+ highlightColour
+ formatHours(
Client.getXPUntilGoal(current_skill) / Client.getXpPerHour()[current_skill]),
x,
y,
true);
y += 12;
}
Renderer.drawColoredText(
g,
Expand All @@ -430,8 +454,8 @@ public static boolean hasGoalForSkill(int skill) {
}

/**
* Rounds up a double to to the nearest integer and adds commas, periods, etc. according to the
* local of the user
* Rounds up a double to the nearest integer and adds commas, periods, etc. according to the
* locale of the user
*
* @param number the number to round
* @return a formatted version of the double as a String
Expand All @@ -440,6 +464,19 @@ public static String formatXP(double number) {
return NumberFormat.getIntegerInstance().format(Math.ceil(number));
}

/**
* Formats a given decimal-form hour value to HH:mm
*
* @param fractionalHours the number of hours to format
* @return a formatted version of the double as a String
*/
public static String formatHours(double fractionalHours) {
long hours = Math.round(Math.floor(fractionalHours));
long minutes = Math.round(Math.floor((fractionalHours - hours) * 60));

return String.format("%02d:%02d", hours, minutes);
}

/*
* Goal Input code below this line
* ===================================
Expand Down

0 comments on commit 48c5aa9

Please sign in to comment.