Cleanup conditionals

This commit is contained in:
Edoardo Lolletti 2024-04-28 13:35:50 +02:00
parent 03f1df6f8e
commit 06d374d28b

View File

@ -143,6 +143,7 @@ static int mainMenu(int cursor)
if (konamiCode == 5)
{
advancedOptionsUnlocked = true;
addMenuItem(m, tidPatchesStr, NULL, foundUnlaunchInstallerVersion == v1_9 || foundUnlaunchInstallerVersion == v2_0, false);
addMenuItem(m, "Uninstall unlaunch no backup", NULL, unlaunchFound, false);
addMenuItem(m, "Write nocash footer", NULL, needsNocashFooterToBeWritten, false);
}
@ -318,7 +319,14 @@ int main(int argc, char **argv)
{
case MAIN_MENU_SAFE_UNLAUNCH_UNINSTALL:
case MAIN_MENU_SAFE_UNLAUNCH_UNINSTALL_NO_BACKUP:
if(unlaunchFound && nandio_unlock_writing()) {
if(!unlaunchFound)
{
break;
}
if(!nandio_unlock_writing())
{
break;
}
bool unsafeUninstall = advancedOptionsUnlocked && cursor == MAIN_MENU_SAFE_UNLAUNCH_UNINSTALL_NO_BACKUP;
printf("Uninstalling");
if(needsNocashFooterToBeWritten)
@ -326,6 +334,7 @@ int main(int argc, char **argv)
printf("Writing nocash footer\n");
if(!nandio_write_nocash_footer(&computedNocashFooter))
{
nandio_lock_writing();
messageBox("Failed to write nocash footer");
break;
}
@ -335,20 +344,26 @@ int main(int argc, char **argv)
{
messageBox("Uninstall successful!\n");
unlaunchFound = false;
} else {
}
else
{
messageBox("\x1B[31mError:\x1B[33m Uninstall failed\n");
}
nandio_lock_writing();
printf("Synchronizing FAT tables...\n");
nandio_synchronize_fats();
}
break;
case MAIN_MENU_CUSTOM_BG:
if(foundUnlaunchInstallerVersion != INVALID) {
if(foundUnlaunchInstallerVersion == INVALID)
{
break;
}
const char* customBg = backgroundMenu();
if(!customBg)
{
break;
}
if(strcmp(customBg, "default") == 0)
{
customBgPath = NULL;
@ -357,7 +372,6 @@ int main(int argc, char **argv)
{
customBgPath = customBg;
}
}
break;
case MAIN_MENU_TID_PATCHES:
@ -373,16 +387,32 @@ int main(int argc, char **argv)
break;
case MAIN_MENU_SAFE_UNLAUNCH_INSTALL:
if (!unlaunchFound && foundUnlaunchInstallerVersion != INVALID && (choiceBox("Install unlaunch?") == YES)
&& (retailLauncherTmdPresentAndToBePatched || (choiceBox("There doesn't seem to be a launcher.tmd\nfile matcing the hwinfo file\nKeep installing?") == YES))
&& nandio_unlock_writing())
if(unlaunchFound || foundUnlaunchInstallerVersion == INVALID)
{
break;
}
if(choiceBox("Install unlaunch?") == NO)
{
break;
}
if(!retailLauncherTmdPresentAndToBePatched
&& (choiceBox("There doesn't seem to be a launcher.tmd\n"
"file matcing the hwinfo file\n"
"Keep installing?") == NO))
{
break;
}
if(!nandio_unlock_writing())
{
break;
}
printf("Installing\n");
if(needsNocashFooterToBeWritten)
{
printf("Writing nocash footer\n");
if(!nandio_write_nocash_footer(&computedNocashFooter))
{
nandio_lock_writing();
messageBox("Failed to write nocash footer");
break;
}
@ -396,25 +426,27 @@ int main(int argc, char **argv)
{
messageBox("Install successful!\n");
unlaunchFound = true;
} else {
}
else
{
messageBox("\x1B[31mError:\x1B[33m Install failed\n");
}
nandio_lock_writing();
printf("Synchronizing FAT tables...\n");
nandio_synchronize_fats();
}
break;
case MAIN_MENU_WRITE_NOCASH_FOOTER_ONLY:
if(needsNocashFooterToBeWritten)
if(!needsNocashFooterToBeWritten)
{
break;
}
if(!nandio_write_nocash_footer(&computedNocashFooter))
{
messageBox("Failed to write nocash footer");
break;
}
needsNocashFooterToBeWritten = false;
}
break;
case MAIN_MENU_EXIT: