diff --git a/include/arm9/console.h b/include/arm9/console.h index 85ccf9c..c73672f 100644 --- a/include/arm9/console.h +++ b/include/arm9/console.h @@ -155,6 +155,12 @@ PrintConsole *consoleSelect(PrintConsole* console); /** + * @brief Returns the currently used console. + * @return A pointer to the current console. + */ +PrintConsole *consoleGet(void); + +/** * @brief Initialise the console. * @param screen The screen to use for the console. * @param console A pointer to the console data to initialize (if it's NULL, the default console will be used). diff --git a/source/arm9/console.c b/source/arm9/console.c index f7b365f..8e00cc0 100644 --- a/source/arm9/console.c +++ b/source/arm9/console.c @@ -566,6 +566,12 @@ } //--------------------------------------------------------------------------------- +PrintConsole *consoleGet(void){ +//--------------------------------------------------------------------------------- + return currentConsole; +} + +//--------------------------------------------------------------------------------- void consoleSetFont(PrintConsole* console, ConsoleFont* font){ //--------------------------------------------------------------------------------- diff --git a/source/arm9/ui.c b/source/arm9/ui.c index 131e0c9..a2d72b0 100644 --- a/source/arm9/ui.c +++ b/source/arm9/ui.c @@ -8,6 +8,7 @@ #include "arm9/timer.h" #include "arm9/main.h" #include "arm9/ui.h" +#include "arm9/console.h" static void consoleMainInit() @@ -75,30 +76,39 @@ } /* Prints a given text in the center of the current line */ -void uiPrintCentered(format, args...) +void uiPrintCentered(const char *const format, ...) { - // TODO + const unsigned int width = (unsigned int)consoleGet()->consoleWidth; + char tmp[width + 1]; + + va_list args; + va_start(args, format); + vsnprintf(tmp, width + 1, format, args); + va_end(args); + + size_t len = strlen(tmp); + printf("%*s\n", (width - len) / 2, tmp); } /* Prints a given text at a certain position in the current window */ -void uiPrintTextAt(unsigned x, unsigned y, format, args...) +/*void uiPrintTextAt(unsigned x, unsigned y, format, args...) { // TODO -} +}*/ /* Prints a given text surrounded by a graphical window */ /* centered in the middle of the screen. */ /* Waits for the user to press any button, after that the */ /* original framebuffer gets restored */ -void uiShowMessageWindow(format, args...) +/*void uiShowMessageWindow(format, args...) { // TODO -} +}*/ -void uiPrintProgressBar(unsigned x, unsigned y, unsigned width, unsigned height, +/*void uiPrintProgressBar(unsigned x, unsigned y, unsigned width, unsigned height, double percentage) { // TODO -} +}*/