diff --git a/arm9/src/bgMenu.cpp b/arm9/src/bgMenu.cpp index 44114ce..363b6bf 100644 --- a/arm9/src/bgMenu.cpp +++ b/arm9/src/bgMenu.cpp @@ -42,10 +42,10 @@ const char* backgroundMenu() for(const auto& [bgName, bgPath] : bgs) { - addMenuItem(m, bgName.data(), nullptr, 0); + addMenuItem(m, bgName.data(), nullptr, true, false); } - addMenuItem(m, "Default", nullptr, 0); - addMenuItem(m, "Cancel", nullptr, 0); + addMenuItem(m, "Default", nullptr, true, false); + addMenuItem(m, "Cancel", nullptr, true, false); m->cursor = 0; @@ -60,8 +60,13 @@ const char* backgroundMenu() if (moveCursor(m)) printMenu(m); - if (keysDown() & KEY_A) + if (auto keys = keysDown(); keys & KEY_A) break; + else if(keys & KEY_B) + { + m->cursor = bgs.size() + 1; + break; + } } const char* result = nullptr; diff --git a/arm9/src/main.c b/arm9/src/main.c index 893165b..8d109d6 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -73,22 +73,17 @@ static int mainMenu(int cursor) Menu* m = newMenu(); setMenuHeader(m, "MAIN MENU"); - char uninstallStr[32], installStr[32], soundPatchesStr[64], tidPatchesStr[32], customBgStr[32]; - sprintf(uninstallStr, "\x1B[%02omUninstall unlaunch", unlaunchFound ? 047 : 037); - sprintf(customBgStr, "\x1B[%02omCustom background", (foundUnlaunchInstallerVersion != INVALID) ? 047 : 037); - sprintf(tidPatchesStr, "\x1B[%02omDisable all patches: %s", - (foundUnlaunchInstallerVersion == v1_9 || foundUnlaunchInstallerVersion == v2_0) ? 047 : 037, + char soundPatchesStr[64], tidPatchesStr[32]; + sprintf(tidPatchesStr, "Disable all patches: %s", disableAllPatches ? "On" : "Off"); - sprintf(soundPatchesStr, "\x1B[%02omEnable sound and splash: %s", - (foundUnlaunchInstallerVersion == v2_0 && !disableAllPatches && splashSoundBinaryPatchPath != NULL) ? 047 : 037, + sprintf(soundPatchesStr, "Enable sound and splash: %s", enableSoundAndSplash ? "On" : "Off"); - sprintf(installStr, "\x1B[%02omInstall unlaunch", (foundUnlaunchInstallerVersion != INVALID && !unlaunchFound) ? 047 : 037); - addMenuItem(m, uninstallStr, NULL, 0); - addMenuItem(m, customBgStr, NULL, true); - addMenuItem(m, tidPatchesStr, NULL, 0); - addMenuItem(m, soundPatchesStr, NULL, 0); - addMenuItem(m, installStr, NULL, 0); - addMenuItem(m, "\x1B[47mExit", NULL, 0); + addMenuItem(m, "Uninstall unlaunch", NULL, unlaunchFound, false); + addMenuItem(m, "Custom background", NULL, foundUnlaunchInstallerVersion != INVALID, true); + addMenuItem(m, tidPatchesStr, NULL, foundUnlaunchInstallerVersion == v1_9 || foundUnlaunchInstallerVersion == v2_0, false); + addMenuItem(m, soundPatchesStr, NULL, foundUnlaunchInstallerVersion == v2_0 && !disableAllPatches && splashSoundBinaryPatchPath != NULL, false); + addMenuItem(m, "Install unlaunch", NULL, foundUnlaunchInstallerVersion != INVALID && !unlaunchFound, false); + addMenuItem(m, "Exit", NULL, true, false); m->cursor = cursor; @@ -290,7 +285,6 @@ int main(int argc, char **argv) case MAIN_MENU_TID_PATCHES: if(foundUnlaunchInstallerVersion == v1_9 || foundUnlaunchInstallerVersion == v2_0) { disableAllPatches = !disableAllPatches; - enableSoundAndSplash = true; } break; diff --git a/arm9/src/main.h b/arm9/src/main.h index 974ce78..2ff3ede 100644 --- a/arm9/src/main.h +++ b/arm9/src/main.h @@ -10,8 +10,8 @@ extern "C" { #endif extern volatile bool programEnd; -extern bool charging; -extern u8 batteryLevel; +extern volatile bool charging; +extern volatile u8 batteryLevel; extern PrintConsole topScreen; extern PrintConsole bottomScreen; diff --git a/arm9/src/menu.c b/arm9/src/menu.c index 9a2d422..df2cf4b 100644 --- a/arm9/src/menu.c +++ b/arm9/src/menu.c @@ -35,7 +35,7 @@ void freeMenu(Menu* m) m = NULL; } -void addMenuItem(Menu* m, char const* label, char const* value, bool directory) +void addMenuItem(Menu* m, char const* label, char const* value, bool enabled, bool directory) { if (!m) return; @@ -43,11 +43,12 @@ void addMenuItem(Menu* m, char const* label, char const* value, bool directory) if (i >= ITEMS_PER_PAGE) return; m->items[i].directory = directory; + m->items[i].enabled = enabled; if (label) { - m->items[i].label = (char*)malloc(64); - sprintf(m->items[i].label, "%.63s", label); + m->items[i].label = (char*)malloc(32); + sprintf(m->items[i].label, "%.31s", label); } if (value) @@ -147,10 +148,16 @@ void printMenu(Menu* m) { if (m->items[i].label) { + if(!m->items[i].enabled) + iprintf("\x1B[37m"); //gray + if (m->items[i].directory) - iprintf(" [%.58s]\n", m->items[i].label); + iprintf(" [%.26s]\n", m->items[i].label); else - iprintf(" %.60s\n", m->items[i].label); + iprintf(" %.28s\n", m->items[i].label); + + if(!m->items[i].enabled) + iprintf("\x1B[47m"); //white } else iprintf(" \n"); diff --git a/arm9/src/menu.h b/arm9/src/menu.h index b6cb591..f8c3e41 100644 --- a/arm9/src/menu.h +++ b/arm9/src/menu.h @@ -11,6 +11,7 @@ extern "C" { typedef struct { bool directory; + bool enabled; char* label; char* value; } Item; @@ -28,7 +29,7 @@ typedef struct { Menu* newMenu(); void freeMenu(Menu* m); -void addMenuItem(Menu* m, char const* label, char const* value, bool directory); +void addMenuItem(Menu* m, char const* label, char const* value, bool enabled, bool directory); void sortMenuItems(Menu* m); void setMenuHeader(Menu* m, const char* str);