Add mode for launching titles.

This commit is contained in:
Steven Smith 2015-04-13 22:06:57 -07:00
parent 1bcf70252d
commit f2dc16c810

View File

@ -14,7 +14,8 @@
typedef enum { typedef enum {
INSTALL_CIA, INSTALL_CIA,
DELETE_CIA, DELETE_CIA,
DELETE_TITLE DELETE_TITLE,
LAUNCH_TITLE
} Mode; } Mode;
int main(int argc, char **argv) { int main(int argc, char **argv) {
@ -59,7 +60,9 @@ int main(int argc, char **argv) {
} else if(mode == DELETE_CIA) { } else if(mode == DELETE_CIA) {
mode = DELETE_TITLE; mode = DELETE_TITLE;
breakLoop = true; breakLoop = true;
} else { } else if(mode == DELETE_TITLE) {
mode = LAUNCH_TITLE;
} else if(mode == LAUNCH_TITLE) {
mode = INSTALL_CIA; mode = INSTALL_CIA;
breakLoop = true; breakLoop = true;
} }
@ -72,7 +75,7 @@ int main(int argc, char **argv) {
std::stringstream stream; std::stringstream stream;
stream << "Free Space: " << freeSpace << " bytes (" << std::fixed << std::setprecision(2) << freeSpace / 1024.0f / 1024.0f << "MB)" << "\n"; stream << "Free Space: " << freeSpace << " bytes (" << std::fixed << std::setprecision(2) << freeSpace / 1024.0f / 1024.0f << "MB)" << "\n";
stream << "Destination: " << (destination == NAND ? "NAND" : "SD") << ", Mode: " << (mode == INSTALL_CIA ? "Install CIA" : mode == DELETE_CIA ? "Delete CIA" : "Delete Title") << "\n"; stream << "Destination: " << (destination == NAND ? "NAND" : "SD") << ", Mode: " << (mode == INSTALL_CIA ? "Install CIA" : mode == DELETE_CIA ? "Delete CIA" : mode == DELETE_TITLE ? "Delete Title" : "Launch Title") << "\n";
stream << "L - Switch Destination, R - Switch Mode" << "\n"; stream << "L - Switch Destination, R - Switch Mode" << "\n";
if(mode == INSTALL_CIA) { if(mode == INSTALL_CIA) {
stream << "X - Install all CIAs in the current directory" << "\n"; stream << "X - Install all CIAs in the current directory" << "\n";
@ -201,10 +204,11 @@ int main(int argc, char **argv) {
return false; return false;
}); });
} else if(mode == DELETE_TITLE) { } else if(mode == DELETE_TITLE || mode == LAUNCH_TITLE) {
uiSelectApp(&appTarget, destination, [&](bool &updateList) { uiSelectApp(&appTarget, destination, [&](bool &updateList) {
return onLoop(); return onLoop();
}, [&](App app, bool &updateList) { }, [&](App app, bool &updateList) {
if(mode == DELETE_TITLE) {
if(uiPrompt(TOP_SCREEN, "Delete the selected title?", true)) { if(uiPrompt(TOP_SCREEN, "Delete the selected title?", true)) {
updateList = true; updateList = true;
uiDisplayMessage(TOP_SCREEN, "Deleting title..."); uiDisplayMessage(TOP_SCREEN, "Deleting title...");
@ -223,6 +227,23 @@ int main(int argc, char **argv) {
freeSpace = fsGetFreeSpace(destination); freeSpace = fsGetFreeSpace(destination);
} }
} else if(mode == LAUNCH_TITLE) {
if(uiPrompt(TOP_SCREEN, "Launch the selected title?", true)) {
updateList = true;
uiDisplayMessage(TOP_SCREEN, "Launching title...");
AppResult ret = appLaunch(app);
if(ret != APP_SUCCESS) {
std::stringstream resultMsg;
resultMsg << "Launch failed!" << "\n";
resultMsg << appGetResultString(ret) << "\n";
uiPrompt(TOP_SCREEN, resultMsg.str(), false);
} else {
while(true) {
}
}
}
}
return false; return false;
}); });