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
This commit is contained in:
parent
af46e93a5e
commit
e01d96b2eb
2 changed files with 50 additions and 0 deletions
27
source/ui_basic.c
Normal file
27
source/ui_basic.c
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <switch.h>
|
||||||
|
#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
|
||||||
|
}
|
||||||
23
source/ui_basic.h
Normal file
23
source/ui_basic.h
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue