Use the whole length of the progress bar for text

This commit is contained in:
d0k3 2016-07-20 15:18:04 +02:00
parent 75ce08681d
commit b51af7ceb4

View File

@ -523,8 +523,8 @@ bool ShowProgress(u64 current, u64 total, const char* opstr)
const u32 text_pos_y = bar_pos_y + bar_height + 2; const u32 text_pos_y = bar_pos_y + bar_height + 2;
u32 prog_width = ((total > 0) && (current <= total)) ? (current * (bar_width-4)) / total : 0; u32 prog_width = ((total > 0) && (current <= total)) ? (current * (bar_width-4)) / total : 0;
u32 prog_percent = ((total > 0) && (current <= total)) ? (current * 100) / total : 0; u32 prog_percent = ((total > 0) && (current <= total)) ? (current * 100) / total : 0;
char tempstr[32]; char tempstr[64];
char progstr[32]; char progstr[64];
if (!current || last_prog_width > prog_width) { if (!current || last_prog_width > prog_width) {
ClearScreenF(true, false, COLOR_STD_BG); ClearScreenF(true, false, COLOR_STD_BG);
@ -533,8 +533,8 @@ bool ShowProgress(u64 current, u64 total, const char* opstr)
} }
DrawRectangle(TOP_SCREEN, bar_pos_x + 2, bar_pos_y + 2, prog_width, bar_height - 4, COLOR_STD_FONT); DrawRectangle(TOP_SCREEN, bar_pos_x + 2, bar_pos_y + 2, prog_width, bar_height - 4, COLOR_STD_FONT);
TruncateString(tempstr, opstr, 24, 8); TruncateString(tempstr, opstr, (bar_width / FONT_WIDTH_EXT) - 7, 8);
snprintf(progstr, 32, "%s (%lu%%)", tempstr, prog_percent); snprintf(progstr, 64, "%s (%lu%%)", tempstr, prog_percent);
DrawString(TOP_SCREEN, progstr, bar_pos_x, text_pos_y, COLOR_STD_FONT, COLOR_STD_BG); DrawString(TOP_SCREEN, progstr, bar_pos_x, text_pos_y, COLOR_STD_FONT, COLOR_STD_BG);
DrawString(TOP_SCREEN, "(hold B to cancel)", bar_pos_x + 2, text_pos_y + 14, COLOR_STD_FONT, COLOR_STD_BG); DrawString(TOP_SCREEN, "(hold B to cancel)", bar_pos_x + 2, text_pos_y + 14, COLOR_STD_FONT, COLOR_STD_BG);