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)
|
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, "Default", nullptr, true, false);
|
||||||
addMenuItem(m, "Cancel", nullptr, 0);
|
addMenuItem(m, "Cancel", nullptr, true, false);
|
||||||
|
|
||||||
m->cursor = 0;
|
m->cursor = 0;
|
||||||
|
|
||||||
@ -60,8 +60,13 @@ const char* backgroundMenu()
|
|||||||
if (moveCursor(m))
|
if (moveCursor(m))
|
||||||
printMenu(m);
|
printMenu(m);
|
||||||
|
|
||||||
if (keysDown() & KEY_A)
|
if (auto keys = keysDown(); keys & KEY_A)
|
||||||
break;
|
break;
|
||||||
|
else if(keys & KEY_B)
|
||||||
|
{
|
||||||
|
m->cursor = bgs.size() + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* result = nullptr;
|
const char* result = nullptr;
|
||||||
|
|||||||
@ -73,22 +73,17 @@ static int mainMenu(int cursor)
|
|||||||
Menu* m = newMenu();
|
Menu* m = newMenu();
|
||||||
setMenuHeader(m, "MAIN MENU");
|
setMenuHeader(m, "MAIN MENU");
|
||||||
|
|
||||||
char uninstallStr[32], installStr[32], soundPatchesStr[64], tidPatchesStr[32], customBgStr[32];
|
char soundPatchesStr[64], tidPatchesStr[32];
|
||||||
sprintf(uninstallStr, "\x1B[%02omUninstall unlaunch", unlaunchFound ? 047 : 037);
|
sprintf(tidPatchesStr, "Disable all patches: %s",
|
||||||
sprintf(customBgStr, "\x1B[%02omCustom background", (foundUnlaunchInstallerVersion != INVALID) ? 047 : 037);
|
|
||||||
sprintf(tidPatchesStr, "\x1B[%02omDisable all patches: %s",
|
|
||||||
(foundUnlaunchInstallerVersion == v1_9 || foundUnlaunchInstallerVersion == v2_0) ? 047 : 037,
|
|
||||||
disableAllPatches ? "On" : "Off");
|
disableAllPatches ? "On" : "Off");
|
||||||
sprintf(soundPatchesStr, "\x1B[%02omEnable sound and splash: %s",
|
sprintf(soundPatchesStr, "Enable sound and splash: %s",
|
||||||
(foundUnlaunchInstallerVersion == v2_0 && !disableAllPatches && splashSoundBinaryPatchPath != NULL) ? 047 : 037,
|
|
||||||
enableSoundAndSplash ? "On" : "Off");
|
enableSoundAndSplash ? "On" : "Off");
|
||||||
sprintf(installStr, "\x1B[%02omInstall unlaunch", (foundUnlaunchInstallerVersion != INVALID && !unlaunchFound) ? 047 : 037);
|
addMenuItem(m, "Uninstall unlaunch", NULL, unlaunchFound, false);
|
||||||
addMenuItem(m, uninstallStr, NULL, 0);
|
addMenuItem(m, "Custom background", NULL, foundUnlaunchInstallerVersion != INVALID, true);
|
||||||
addMenuItem(m, customBgStr, NULL, true);
|
addMenuItem(m, tidPatchesStr, NULL, foundUnlaunchInstallerVersion == v1_9 || foundUnlaunchInstallerVersion == v2_0, false);
|
||||||
addMenuItem(m, tidPatchesStr, NULL, 0);
|
addMenuItem(m, soundPatchesStr, NULL, foundUnlaunchInstallerVersion == v2_0 && !disableAllPatches && splashSoundBinaryPatchPath != NULL, false);
|
||||||
addMenuItem(m, soundPatchesStr, NULL, 0);
|
addMenuItem(m, "Install unlaunch", NULL, foundUnlaunchInstallerVersion != INVALID && !unlaunchFound, false);
|
||||||
addMenuItem(m, installStr, NULL, 0);
|
addMenuItem(m, "Exit", NULL, true, false);
|
||||||
addMenuItem(m, "\x1B[47mExit", NULL, 0);
|
|
||||||
|
|
||||||
m->cursor = cursor;
|
m->cursor = cursor;
|
||||||
|
|
||||||
@ -290,7 +285,6 @@ int main(int argc, char **argv)
|
|||||||
case MAIN_MENU_TID_PATCHES:
|
case MAIN_MENU_TID_PATCHES:
|
||||||
if(foundUnlaunchInstallerVersion == v1_9 || foundUnlaunchInstallerVersion == v2_0) {
|
if(foundUnlaunchInstallerVersion == v1_9 || foundUnlaunchInstallerVersion == v2_0) {
|
||||||
disableAllPatches = !disableAllPatches;
|
disableAllPatches = !disableAllPatches;
|
||||||
enableSoundAndSplash = true;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -10,8 +10,8 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern volatile bool programEnd;
|
extern volatile bool programEnd;
|
||||||
extern bool charging;
|
extern volatile bool charging;
|
||||||
extern u8 batteryLevel;
|
extern volatile u8 batteryLevel;
|
||||||
|
|
||||||
extern PrintConsole topScreen;
|
extern PrintConsole topScreen;
|
||||||
extern PrintConsole bottomScreen;
|
extern PrintConsole bottomScreen;
|
||||||
|
|||||||
@ -35,7 +35,7 @@ void freeMenu(Menu* m)
|
|||||||
m = NULL;
|
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;
|
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;
|
if (i >= ITEMS_PER_PAGE) return;
|
||||||
|
|
||||||
m->items[i].directory = directory;
|
m->items[i].directory = directory;
|
||||||
|
m->items[i].enabled = enabled;
|
||||||
|
|
||||||
if (label)
|
if (label)
|
||||||
{
|
{
|
||||||
m->items[i].label = (char*)malloc(64);
|
m->items[i].label = (char*)malloc(32);
|
||||||
sprintf(m->items[i].label, "%.63s", label);
|
sprintf(m->items[i].label, "%.31s", label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
@ -147,10 +148,16 @@ void printMenu(Menu* m)
|
|||||||
{
|
{
|
||||||
if (m->items[i].label)
|
if (m->items[i].label)
|
||||||
{
|
{
|
||||||
|
if(!m->items[i].enabled)
|
||||||
|
iprintf("\x1B[37m"); //gray
|
||||||
|
|
||||||
if (m->items[i].directory)
|
if (m->items[i].directory)
|
||||||
iprintf(" [%.58s]\n", m->items[i].label);
|
iprintf(" [%.26s]\n", m->items[i].label);
|
||||||
else
|
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
|
else
|
||||||
iprintf(" \n");
|
iprintf(" \n");
|
||||||
|
|||||||
@ -11,6 +11,7 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool directory;
|
bool directory;
|
||||||
|
bool enabled;
|
||||||
char* label;
|
char* label;
|
||||||
char* value;
|
char* value;
|
||||||
} Item;
|
} Item;
|
||||||
@ -28,7 +29,7 @@ typedef struct {
|
|||||||
Menu* newMenu();
|
Menu* newMenu();
|
||||||
void freeMenu(Menu* m);
|
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 sortMenuItems(Menu* m);
|
||||||
void setMenuHeader(Menu* m, const char* str);
|
void setMenuHeader(Menu* m, const char* str);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user