diff --git a/include/arm9/ui.h b/include/arm9/ui.h index 28662dc..fb35bd6 100644 --- a/include/arm9/ui.h +++ b/include/arm9/ui.h @@ -27,5 +27,5 @@ void uiPrintCentered(const char *const format, ...); void uiPrintTextAt(unsigned int x, unsigned int y, const char *const format, ...); //void uiShowMessageWindow(format, args...); -void uiPrintProgressBar(unsigned int x, unsigned int y, unsigned int width, - unsigned int height, float percentage); +void uiPrintProgressBar(unsigned int x, unsigned int y, unsigned int w, + unsigned int h, unsigned int cur, unsigned int max); diff --git a/source/arm9/menu_nand.c b/source/arm9/menu_nand.c index 3204cdd..d28aac9 100644 --- a/source/arm9/menu_nand.c +++ b/source/arm9/menu_nand.c @@ -106,7 +106,7 @@ curSector, sectorCount); - uiPrintProgressBar(10, 200, 20, 150, 100 * (float) curSector/sectorCount); + uiPrintProgressBar(10, 200, 20, 150, curSector, sectorCount); switch(menuUpdateGlobalState()) { diff --git a/source/arm9/ui.c b/source/arm9/ui.c index a0ff4b9..474649c 100644 --- a/source/arm9/ui.c +++ b/source/arm9/ui.c @@ -124,15 +124,28 @@ }*/ -void uiPrintProgressBar(unsigned int x, unsigned int y, unsigned int width, - unsigned int height, float percentage) +void uiPrintProgressBar(unsigned int x, unsigned int y, unsigned int w, + unsigned int h, unsigned int cur, unsigned int max) { u16 *fb = consoleGet()->frameBuffer; const u16 color = consoleGetFgColor(); - for(u32 xx = x; xx < (u32)((x + width / 100) * percentage); xx++) + + for(u32 xx = x + 1; xx < x + w - 1; xx++) { - for(u32 yy = y; yy < y + height; yy++) + fb[xx * SCREEN_HEIGHT_TOP + y] = color; + fb[xx * SCREEN_HEIGHT_TOP + y + h - 1] = color; + } + + for(u32 yy = y; yy < y + h; yy++) + { + fb[x * SCREEN_HEIGHT_TOP + yy] = color; + fb[(x + w - 1) * SCREEN_HEIGHT_TOP + yy] = color; + } + + for(u32 xx = x + 2; xx < (u32)(((float)(x + w - 2) / max) * cur); xx++) + { + for(u32 yy = y + 2; yy < y + h - 2; yy++) { fb[xx * SCREEN_HEIGHT_TOP + yy] = color; }