diff --git a/include/arm9/ui.h b/include/arm9/ui.h index 94cbcf3..bb69a29 100644 --- a/include/arm9/ui.h +++ b/include/arm9/ui.h @@ -3,9 +3,9 @@ #include "arm9/console.h" #include "hid.h" -#define uiPrintInfo(format, ...) uiPrintCentered(format, 0, ##__VA_ARGS__) -#define uiPrintWarning(format, ...) uiPrintCentered(format, 33, ##__VA_ARGS__) -#define uiPrintError(format, ...) uiPrintCentered(format, 31, ##__VA_ARGS__) +#define uiPrintInfo(format, ...) uiPrintLine(format, 0, false, ##__VA_ARGS__) +#define uiPrintWarning(format, ...) uiPrintLine(format, 33, false, ##__VA_ARGS__) +#define uiPrintError(format, ...) uiPrintLine(format, 31, false, ##__VA_ARGS__) // PrintConsole for each screen @@ -18,7 +18,7 @@ void uiSetVerbose(bool verb); bool uiDialogYesNo(const char *text, const char *textYes, const char *textNo); void uiPrintIfVerbose(const char *const format, ...); -void uiPrintCentered(const char *const format, unsigned int color, ...); +void uiPrintLine(const char *const format, unsigned int color, bool centered, ...); void uiPrintCenteredInLine(unsigned int y, const char *const format, ...); void uiPrintTextAt(unsigned int x, unsigned int y, const char *const format, ...); //void uiShowMessageWindow(format, args...); diff --git a/source/arm9/ui.c b/source/arm9/ui.c index fea09c3..da8555c 100644 --- a/source/arm9/ui.c +++ b/source/arm9/ui.c @@ -112,19 +112,26 @@ } } -/* Prints a given text in the center of the current line */ -void uiPrintCentered(const char *const format, unsigned int color, ...) +/* Prints a given text at the current line */ +void uiPrintLine(const char *const format, unsigned int color, bool centered, ...) { const unsigned int width = (unsigned int)consoleGet()->consoleWidth; char tmp[width + 1]; va_list args; - va_start(args, color); + va_start(args, centered); vsnprintf(tmp, width + 1, format, args); va_end(args); - size_t len = strlen(tmp); - printf("\x1B[%um%*s%s\n", color, (width - len) / 2, "", tmp); + if(centered) + { + size_t len = strlen(tmp); + printf("\x1B[%um%*s%s\n\x1B[0m", color, (width - len) / 2, "", tmp); + } + else + { + printf("\x1B[%um%s\n\x1B[0m", color, tmp); + } } void uiPrintCenteredInLine(unsigned int y, const char *const format, ...)