From d1320bd2c977c05f104e21eb85a003e65eb8d1d2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 30 Apr 2024 12:09:15 +1000 Subject: [PATCH] Consoles: Add exit button to bottom right of launcher menu --- src/LScreens.c | 17 +++++++++++++++-- src/Platform_NDS.c | 9 +++------ src/TouchUI.c | 4 +--- src/Window_NDS.c | 4 ++++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/LScreens.c b/src/LScreens.c index 676ccb8ac..44c6b1904 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -886,6 +886,12 @@ static void MainScreen_ApplyUpdateLabel(struct MainScreen* s) { } } +#ifdef CC_BUILD_CONSOLE +static void MainScreen_ExitApp(void* w) { + Window_Main.Exists = false; +} +#endif + static void MainScreen_Activated(struct LScreen* s_) { struct MainScreen* s = (struct MainScreen*)s_; @@ -909,8 +915,6 @@ static void MainScreen_Activated(struct LScreen* s_) { SwitchToSplitScreen, main_btnSplit); #endif - LLabel_Add(s, &s->lblUpdate, "&eChecking..", - Updater_Supported ? main_lblUpdate_N : main_lblUpdate_H); if (Process_OpenSupported) { LButton_Add(s, &s->btnRegister, 100, 35, "Register", MainScreen_Register, main_btnRegister); @@ -918,10 +922,19 @@ static void MainScreen_Activated(struct LScreen* s_) { LButton_Add(s, &s->btnOptions, 100, 35, "Options", SwitchToSettings, main_btnOptions); + +#ifdef CC_BUILD_CONSOLE + LLabel_Add(s, &s->lblUpdate, "&eChecking..", main_lblUpdate_N); + LButton_Add(s, &s->btnUpdates, 100, 35, "Exit", + MainScreen_ExitApp, main_btnUpdates); +#else + LLabel_Add(s, &s->lblUpdate, "&eChecking..", + Updater_Supported ? main_lblUpdate_N : main_lblUpdate_H); if (Updater_Supported) { LButton_Add(s, &s->btnUpdates, 100, 35, "Updates", SwitchToUpdates, main_btnUpdates); } +#endif s->btnResume.OnHover = MainScreen_ResumeHover; s->btnResume.OnUnhover = MainScreen_ResumeUnhover; diff --git a/src/Platform_NDS.c b/src/Platform_NDS.c index ac1062752..a56ba63f5 100644 --- a/src/Platform_NDS.c +++ b/src/Platform_NDS.c @@ -189,7 +189,7 @@ cc_result File_Length(cc_file file, cc_uint32* len) { *len = st.st_size; return 0; } -static void InitFilesystem(cc_bool dsiMode) { +static void InitFilesystem(void) { char* dir = fatGetDefaultCwd(); if (dir && dir[0]) { root_path.buffer = dir; @@ -199,7 +199,7 @@ static void InitFilesystem(cc_bool dsiMode) { // I don't know why I have to call this function, but if I don't, // then when running in DSi mode AND an SD card is readable, // fatInitDefault gets stuck somewhere (in disk_initialize it seems) - if (dsiMode) { + if (isDSiMode()) { const DISC_INTERFACE* sd_io = get_io_dsisd(); if (sd_io) sd_io->startup(); } @@ -404,10 +404,7 @@ static void InitNetworking(void) { *--------------------------------------------------------Platform---------------------------------------------------------* *#########################################################################################################################*/ void Platform_Init(void) { - cc_bool dsiMode = isDSiMode(); - Platform_Log1("Running in %c mode", dsiMode ? "DSi" : "DS"); - - InitFilesystem(dsiMode); + InitFilesystem(); InitNetworking(); cpuStartTiming(1); diff --git a/src/TouchUI.c b/src/TouchUI.c index 408a6195e..a6ae4105a 100644 --- a/src/TouchUI.c +++ b/src/TouchUI.c @@ -725,10 +725,8 @@ static void TouchScreen_LayoutOnscreen(struct TouchScreen* s, cc_uint8 alignment static void TouchScreen_Layout(void* screen) { struct TouchScreen* s = (struct TouchScreen*)screen; const struct TouchButtonDesc* desc; - int haligns = GetOnscreenHAligns(); float scale = Gui.RawTouchScale; - cc_uint8 halign; - int i, x, y, height; + int i, height; /* Need to align these relative to the hotbar */ height = HUDScreen_LayoutHotbar(); diff --git a/src/Window_NDS.c b/src/Window_NDS.c index 71cb74fd2..05b1e0d4f 100644 --- a/src/Window_NDS.c +++ b/src/Window_NDS.c @@ -15,6 +15,7 @@ #include #include #include +#include /*########################################################################################################################* @@ -151,6 +152,9 @@ void Window_Init(void) { vramSetBankI(VRAM_I_SUB_BG_0x06208000); setBrightness(2, 0); consoleInit(); + + cc_bool dsiMode = isDSiMode(); + Platform_Log1("Running in %c mode", dsiMode ? "DSi" : "DS"); } void Window_Free(void) { }