From e01d96b2ebbc2f715fb9c3315c5786ae6ad11fde Mon Sep 17 00:00:00 2001 From: badbl0cks <4161747+badbl0cks@users.noreply.github.com> Date: Wed, 17 May 2023 16:58:22 -0700 Subject: [PATCH] Add basic UI system - Create UI header with menu structures - Implement screen clearing and title display - Add message printing functionality - Foundation for menu-driven interface --- source/ui_basic.c | 27 +++++++++++++++++++++++++++ source/ui_basic.h | 23 +++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 source/ui_basic.c create mode 100644 source/ui_basic.h diff --git a/source/ui_basic.c b/source/ui_basic.c new file mode 100644 index 0000000..c00a022 --- /dev/null +++ b/source/ui_basic.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include "ui_basic.h" + +void initUI() { + printf("\x1b[2J"); // Clear screen + printf("\x1b[1;1H"); // Move cursor to top-left + printf("═══════════════════════════════════════\n"); + printf(" BOTW Completer v0.3\n"); + printf("═══════════════════════════════════════\n"); + printf("\n"); +} + +void printMessage(const char* message, ...) { + va_list args; + va_start(args, message); + vprintf(message, args); + va_end(args); +} + +bool handleButtonPress(u64 button) { + if (button & HidNpadButton_Plus) { + return true; // Exit requested + } + return false; // Continue running +} \ No newline at end of file diff --git a/source/ui_basic.h b/source/ui_basic.h new file mode 100644 index 0000000..8326224 --- /dev/null +++ b/source/ui_basic.h @@ -0,0 +1,23 @@ +#ifndef UI_H +#define UI_H + +typedef void (*func_t)(); + +typedef struct { + char ItemStr[30]; + func_t ItemFunc; +} MenuItem; + +typedef struct { + char HeaderStr[30]; + u32 ItemCount; + u32 StartLine; + u32 SelectedIndex; + MenuItem *Menu_Items; +} Menu; + +void initUI(); +void printMessage(const char* message, ...); +bool handleButtonPress(u64 button); + +#endif \ No newline at end of file