Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show remaining hours to level goal #108

Merged
merged 2 commits into from
Oct 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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