mirror of
https://github.com/rvtr/unlaunch-installer_dev.git
synced 2026-01-26 13:43:08 -05:00
Clean up a bit menus
This commit is contained in:
parent
38b1efb15b
commit
30b5e7017d
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user