Add option to disable prompts when installing over the network.

This commit is contained in:
Steven Smith 2015-04-23 21:15:39 -07:00
parent e8e4f09268
commit a4615c95a4

View File

@ -73,7 +73,7 @@ int main(int argc, char **argv) {
} }
std::stringstream stream; std::stringstream stream;
stream << "FBI v1.3.4" << "\n"; stream << "FBI v1.3.5" << "\n";
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" : mode == DELETE_TITLE ? "Delete Title" : "Launch 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";
@ -107,6 +107,8 @@ int main(int argc, char **argv) {
return !inputIsPressed(BUTTON_B); return !inputIsPressed(BUTTON_B);
}; };
bool showNetworkPrompts = true;
while(platformIsRunning()) { while(platformIsRunning()) {
std::string fileTarget; std::string fileTarget;
App appTarget; App appTarget;
@ -114,7 +116,16 @@ int main(int argc, char **argv) {
if(netInstall && !exit) { if(netInstall && !exit) {
screenClearBuffers(BOTTOM_SCREEN, 0, 0, 0); screenClearBuffers(BOTTOM_SCREEN, 0, 0, 0);
RemoteFile file = uiAcceptRemoteFile(TOP_SCREEN); RemoteFile file = uiAcceptRemoteFile(TOP_SCREEN, [&](std::stringstream& infoStream) {
if(inputIsPressed(BUTTON_A)) {
showNetworkPrompts = !showNetworkPrompts;
}
infoStream << "\n";
infoStream << "Prompts: " << (showNetworkPrompts ? "Enabled" : "Disabled") << "\n";
infoStream << "Press A to toggle prompts." << "\n";
});
if(file.fd == NULL) { if(file.fd == NULL) {
netInstall = false; netInstall = false;
continue; continue;
@ -123,18 +134,20 @@ int main(int argc, char **argv) {
std::stringstream confirmStream; std::stringstream confirmStream;
confirmStream << "Install the received application?" << "\n"; confirmStream << "Install the received application?" << "\n";
confirmStream << "Size: " << file.fileSize << " bytes (" << std::fixed << std::setprecision(2) << file.fileSize / 1024.0f / 1024.0f << "MB)" << "\n"; confirmStream << "Size: " << file.fileSize << " bytes (" << std::fixed << std::setprecision(2) << file.fileSize / 1024.0f / 1024.0f << "MB)" << "\n";
if(uiPrompt(TOP_SCREEN, confirmStream.str(), true)) { if(!showNetworkPrompts || uiPrompt(TOP_SCREEN, confirmStream.str(), true)) {
AppResult ret = appInstall(destination, file.fd, file.fileSize, onProgress); AppResult ret = appInstall(destination, file.fd, file.fileSize, onProgress);
std::stringstream resultMsg; if(showNetworkPrompts || ret != APP_SUCCESS) {
resultMsg << "Install "; std::stringstream resultMsg;
if(ret == APP_SUCCESS) { resultMsg << "Install ";
resultMsg << "succeeded!"; if(ret == APP_SUCCESS) {
} else { resultMsg << "succeeded!";
resultMsg << "failed!" << "\n"; } else {
resultMsg << appGetResultString(ret) << "\n"; resultMsg << "failed!" << "\n";
} resultMsg << appGetResultString(ret) << "\n";
}
uiPrompt(TOP_SCREEN, resultMsg.str(), false); uiPrompt(TOP_SCREEN, resultMsg.str(), false);
}
} }
fclose(file.fd); fclose(file.fd);