1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-12-28 02:16:03 +00:00

add logout confirmation prompt

This commit is contained in:
flb 2022-03-30 22:23:15 +02:00
parent b7cf0dd132
commit e056903326
12 changed files with 41 additions and 105 deletions

View file

@ -11,7 +11,6 @@ namespace show_cheats {
void ShowCheatFiles(uint64_t tid, const std::string& name); void ShowCheatFiles(uint64_t tid, const std::string& name);
void ShowCheatSheet(u64 tid, const std::string& bid, const std::string& name); void ShowCheatSheet(u64 tid, const std::string& bid, const std::string& name);
bool CreateCheatList(const std::filesystem::path& path, brls::List** cheatsList); bool CreateCheatList(const std::filesystem::path& path, brls::List** cheatsList);
void NoCheatsFoundPopup();
void DeleteCheats(u64 tid, const std::string& bid); void DeleteCheats(u64 tid, const std::string& bid);
} // namespace show_cheats } // namespace show_cheats

View file

@ -32,8 +32,9 @@ namespace util {
std::vector<std::string> fetchPayloads(); std::vector<std::string> fetchPayloads();
void shutDown(bool reboot = false); void shutDown(bool reboot = false);
void rebootToPayload(const std::string& path); void rebootToPayload(const std::string& path);
int showDialogBox(const std::string& text, const std::string& opt); void showDialogBoxInfo(const std::string& text);
int showDialogBox(const std::string& text, const std::string& opt1, const std::string& opt2); int showDialogBoxBlocking(const std::string& text, const std::string& opt);
int showDialogBoxBlocking(const std::string& text, const std::string& opt1, const std::string& opt2);
std::string getLatestTag(const std::string& url); std::string getLatestTag(const std::string& url);
std::string downloadFileToString(const std::string& url); std::string downloadFileToString(const std::string& url);
std::string getCheatsVersion(); std::string getCheatsVersion();

View file

@ -180,14 +180,7 @@ void AmsTab::ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules)
} }
name_map.insert(std::pair(module_value.at("displayName"), module.key())); name_map.insert(std::pair(module_value.at("displayName"), module.key()));
deepseaListItem->registerAction("menus/ams_update/show_module_description"_i18n, brls::Key::Y, [module_value] { deepseaListItem->registerAction("menus/ams_update/show_module_description"_i18n, brls::Key::Y, [module_value] {
brls::Dialog* dialog; util::showDialogBoxInfo(fmt::format("{}:\n{}", module_value.at("repo"), module_value.at("description")));
dialog = new brls::Dialog(fmt::format("{}:\n{}", module_value.at("repo"), module_value.at("description")));
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
return true; return true;
}); });
list->addView(deepseaListItem); list->addView(deepseaListItem);

View file

@ -279,13 +279,7 @@ void AppPage_DownloadedCheats::DeclareGameListItem(const std::string& name, u64
if (titles.find(tid_str) != titles.end()) { if (titles.find(tid_str) != titles.end()) {
listItem->getClickEvent()->subscribe([tid, name](brls::View* view) { show_cheats::ShowCheatFiles(tid, name); }); listItem->getClickEvent()->subscribe([tid, name](brls::View* view) { show_cheats::ShowCheatFiles(tid, name); });
listItem->registerAction("menus/cheats/delete_cheats"_i18n, brls::Key::Y, [tid_str] { listItem->registerAction("menus/cheats/delete_cheats"_i18n, brls::Key::Y, [tid_str] {
brls::Dialog* dialog = new brls::Dialog(extract::removeCheatsDirectory(fmt::format("{}{}", util::getContentsPath(), tid_str)) ? "menus/common/all_done"_i18n : fmt::format("menus/cheats/deletion_error"_i18n, tid_str)); util::showDialogBoxInfo(extract::removeCheatsDirectory(fmt::format("{}{}", util::getContentsPath(), tid_str)) ? "menus/common/all_done"_i18n : fmt::format("menus/cheats/deletion_error"_i18n, tid_str));
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
return true; return true;
}); });
AppPage::DeclareGameListItem(name, tid, controlData); AppPage::DeclareGameListItem(name, tid, controlData);

View file

@ -1,5 +1,7 @@
#include "changelog_page.hpp" #include "changelog_page.hpp"
#include "utils.hpp"
namespace i18n = brls::i18n; namespace i18n = brls::i18n;
using namespace i18n::literals; using namespace i18n::literals;
ChangelogPage::ChangelogPage() : AppletFrame(true, true) ChangelogPage::ChangelogPage() : AppletFrame(true, true)
@ -233,13 +235,7 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
listItem = new brls::ListItem(verTitles[i]); listItem = new brls::ListItem(verTitles[i]);
change = changes[i]; change = changes[i];
listItem->getClickEvent()->subscribe([change](brls::View* view) { listItem->getClickEvent()->subscribe([change](brls::View* view) {
brls::Dialog* dialog = new brls::Dialog(change); util::showDialogBoxInfo(change);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
}); });
list->addView(listItem); list->addView(listItem);
} }

View file

@ -171,7 +171,7 @@ namespace JC {
ProgressEvent::instance().setStep(1); ProgressEvent::instance().setStep(1);
int res = setColor(values); int res = setColor(values);
if (res != 0) { if (res != 0) {
util::showDialogBox("Could not change the Joy-Cons color. Make sure they're docked and try again.\nError :" + std::to_string(res), "Ok"); util::showDialogBoxBlocking("Could not change the Joy-Cons color. Make sure they're docked and try again.\nError :" + std::to_string(res), "Ok");
} }
hiddbgExit(); hiddbgExit();
hidsysExit(); hidsysExit();
@ -329,7 +329,7 @@ namespace PC {
ProgressEvent::instance().setStep(1); ProgressEvent::instance().setStep(1);
int res = setColor(values); int res = setColor(values);
if (res != 0) { if (res != 0) {
util::showDialogBox("Could not change the Pro-Con color. Make they're connected to P1. This feature may not work on unofficial controllers. \nError :" + std::to_string(res), "Ok"); util::showDialogBoxBlocking("Could not change the Pro-Con color. Make they're connected to P1. This feature may not work on unofficial controllers. \nError :" + std::to_string(res), "Ok");
} }
hiddbgExit(); hiddbgExit();
hidsysExit(); hidsysExit();

View file

@ -25,19 +25,13 @@ namespace show_cheats {
appView->setContentView(cheatsList); appView->setContentView(cheatsList);
appView->registerAction("menus/cheats/delete_file"_i18n, brls::Key::X, [tid, bid] { appView->registerAction("menus/cheats/delete_file"_i18n, brls::Key::X, [tid, bid] {
DeleteCheats(tid, bid); DeleteCheats(tid, bid);
brls::Dialog* dialog = new brls::Dialog("menus/common/all_done"_i18n); util::showDialogBoxInfo("menus/common/all_done"_i18n);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
return true; return true;
}); });
brls::PopupFrame::open(name, appView, ""); brls::PopupFrame::open(name, appView, "");
} }
else { else {
NoCheatsFoundPopup(); util::showDialogBoxInfo("menus/cheats/not_found"_i18n);
} }
} }
@ -61,21 +55,10 @@ namespace show_cheats {
brls::PopupFrame::open(name, appView, ""); brls::PopupFrame::open(name, appView, "");
} }
else { else {
NoCheatsFoundPopup(); util::showDialogBoxInfo("menus/cheats/not_found"_i18n);
} }
} }
void NoCheatsFoundPopup()
{
brls::Dialog* dialog = new brls::Dialog("menus/cheats/not_found"_i18n);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
}
bool CreateCheatList(const std::filesystem::path& path, brls::List** cheatsList) bool CreateCheatList(const std::filesystem::path& path, brls::List** cheatsList)
{ {
bool res = false; bool res = false;
@ -276,21 +259,16 @@ DownloadCheatsPage_CheatSlips::DownloadCheatsPage_CheatSlips(uint64_t tid, const
} }
if (error != 0) { if (error != 0) {
brls::Dialog* dialog; std::string error_message;
switch (error) { switch (error) {
case 1: case 1:
dialog = new brls::Dialog("menus/cheats/quota"_i18n); error_message = "menus/cheats/quota"_i18n;
break; break;
case 2: case 2:
dialog = new brls::Dialog("menus/cheats/cheatslips_error"_i18n); error_message = "menus/cheats/cheatslips_error"_i18n;
break; break;
} }
brls::GenericEvent::Callback callback = [dialog](brls::View* view) { util::showDialogBoxInfo(error_message);
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
} }
} }
if (error == 0) { if (error == 0) {
@ -361,13 +339,7 @@ DownloadCheatsPage_GbaTemp::DownloadCheatsPage_GbaTemp(uint64_t tid, const std::
this->listItem = new brls::ListItem(cheat.at("title")); this->listItem = new brls::ListItem(cheat.at("title"));
listItem->registerAction("menus/cheats/gbatemp_dl_cheatcode"_i18n, brls::Key::A, [this, cheat] { listItem->registerAction("menus/cheats/gbatemp_dl_cheatcode"_i18n, brls::Key::A, [this, cheat] {
WriteCheats(cheat.at("content")); WriteCheats(cheat.at("content"));
brls::Dialog* dialog = new brls::Dialog(fmt::format("menus/cheats/gbatemp_dl_successful_dl"_i18n, cheat.at("title"))); util::showDialogBoxInfo(fmt::format("menus/cheats/gbatemp_dl_successful_dl"_i18n, cheat.at("title")));
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
return true; return true;
}); });
this->list->addView(listItem); this->list->addView(listItem);

View file

@ -80,7 +80,7 @@ namespace extract {
unzipper.extractEntry(entry.name); unzipper.extractEntry(entry.name);
if (entry.name.substr(0, 13) == "hekate_ctcaer") { if (entry.name.substr(0, 13) == "hekate_ctcaer") {
fs::copyFile("/" + entry.name, UPDATE_BIN_PATH); fs::copyFile("/" + entry.name, UPDATE_BIN_PATH);
if (CurrentCfw::running_cfw == CFW::ams && util::showDialogBox(fmt::format("menus/utils/set_hekate_reboot_payload"_i18n, UPDATE_BIN_PATH, REBOOT_PAYLOAD_PATH), "menus/common/yes"_i18n, "menus/common/no"_i18n) == 0) { if (CurrentCfw::running_cfw == CFW::ams && util::showDialogBoxBlocking(fmt::format("menus/utils/set_hekate_reboot_payload"_i18n, UPDATE_BIN_PATH, REBOOT_PAYLOAD_PATH), "menus/common/yes"_i18n, "menus/common/no"_i18n) == 0) {
fs::copyFile(UPDATE_BIN_PATH, REBOOT_PAYLOAD_PATH); fs::copyFile(UPDATE_BIN_PATH, REBOOT_PAYLOAD_PATH);
} }
} }

View file

@ -200,13 +200,7 @@ void ListDownloadTab::createCheatSlipItem()
return true; return true;
} }
else { else {
brls::Dialog* dialog = new brls::Dialog("menus/cheats/cheatslips_wrong_id"_i18n + "\n" + "menus/cheats/kb_error"_i18n); util::showDialogBoxInfo("menus/cheats/cheatslips_wrong_id"_i18n + "\n" + "menus/cheats/kb_error"_i18n);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
return true; return true;
} }
} }

View file

@ -57,13 +57,7 @@ void PayloadPage::RegisterCopyAction(brls::Key key, const std::string& payload_p
std::string res = fs::copyFile(payload_path, payload_dest) std::string res = fs::copyFile(payload_path, payload_dest)
? fmt::format("menus/payloads/copy_success"_i18n, payload_path, payload_dest) ? fmt::format("menus/payloads/copy_success"_i18n, payload_path, payload_dest)
: "Failed."; : "Failed.";
brls::Dialog* dialog = new brls::Dialog(res); util::showDialogBoxInfo(res);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
return true; return true;
}); });
} }

View file

@ -100,13 +100,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
error += "\uE016 Running in applet mode/through a forwarder.\n\uE016 Please launch hbmenu by holding [R] on a game"; error += "\uE016 Running in applet mode/through a forwarder.\n\uE016 Please launch hbmenu by holding [R] on a game";
} }
if (!error.empty()) { if (!error.empty()) {
brls::Dialog* dialog = new brls::Dialog(error); util::showDialogBoxInfo(error);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
} }
} }
}); });
@ -122,13 +116,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
else { else {
error = "menus/tools/batch_copy_config_not_found"_i18n; error = "menus/tools/batch_copy_config_not_found"_i18n;
} }
brls::Dialog* dialog = new brls::Dialog(error); util::showDialogBoxInfo(error);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
}); });
move->setHeight(LISTITEM_HEIGHT); move->setHeight(LISTITEM_HEIGHT);
@ -144,13 +132,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
fs::removeDir(AMS_DIRECTORY_PATH); fs::removeDir(AMS_DIRECTORY_PATH);
fs::removeDir(SEPT_DIRECTORY_PATH); fs::removeDir(SEPT_DIRECTORY_PATH);
fs::removeDir(FW_DIRECTORY_PATH); fs::removeDir(FW_DIRECTORY_PATH);
brls::Dialog* dialog = new brls::Dialog("menus/common/all_done"_i18n); util::showDialogBoxInfo("menus/common/all_done"_i18n);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
}); });
cleanUp->setHeight(LISTITEM_HEIGHT); cleanUp->setHeight(LISTITEM_HEIGHT);

View file

@ -67,7 +67,19 @@ namespace util {
ProgressEvent::instance().setStatusCode(status_code); ProgressEvent::instance().setStatusCode(status_code);
} }
int showDialogBox(const std::string& text, const std::string& opt) void showDialogBoxInfo(const std::string& text)
{
brls::Dialog* dialog;
dialog = new brls::Dialog(text);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
}
int showDialogBoxBlocking(const std::string& text, const std::string& opt)
{ {
int dialogResult = -1; int dialogResult = -1;
int result = -1; int result = -1;
@ -86,7 +98,7 @@ namespace util {
return result; return result;
} }
int showDialogBox(const std::string& text, const std::string& opt1, const std::string& opt2) int showDialogBoxBlocking(const std::string& text, const std::string& opt1, const std::string& opt2)
{ {
int dialogResult = -1; int dialogResult = -1;
int result = -1; int result = -1;
@ -167,14 +179,14 @@ namespace util {
brls::Application::quit(); brls::Application::quit();
break; break;
case contentType::bootloaders: { case contentType::bootloaders: {
int overwriteInis = showDialogBox("menus/utils/overwrite_inis"_i18n, "menus/common/no"_i18n, "menus/common/yes"_i18n); int overwriteInis = showDialogBoxBlocking("menus/utils/overwrite_inis"_i18n, "menus/common/no"_i18n, "menus/common/yes"_i18n);
extract::extract(CFW_FILENAME, ROOT_PATH, overwriteInis); extract::extract(CFW_FILENAME, ROOT_PATH, overwriteInis);
break; break;
} }
case contentType::ams_cfw: { case contentType::ams_cfw: {
int overwriteInis = showDialogBox("menus/utils/overwrite_inis"_i18n, "menus/common/no"_i18n, "menus/common/yes"_i18n); int overwriteInis = showDialogBoxBlocking("menus/utils/overwrite_inis"_i18n, "menus/common/no"_i18n, "menus/common/yes"_i18n);
usleep(800000); usleep(800000);
int deleteContents = showDialogBox("menus/ams_update/delete_sysmodules_flags"_i18n, "menus/common/no"_i18n, "menus/common/yes"_i18n); int deleteContents = showDialogBoxBlocking("menus/ams_update/delete_sysmodules_flags"_i18n, "menus/common/no"_i18n, "menus/common/yes"_i18n);
if (deleteContents == 1) if (deleteContents == 1)
removeSysmodulesFlags(AMS_CONTENTS); removeSysmodulesFlags(AMS_CONTENTS);
extract::extract(AMS_FILENAME, ROOT_PATH, overwriteInis); extract::extract(AMS_FILENAME, ROOT_PATH, overwriteInis);
@ -273,7 +285,6 @@ namespace util {
std::string readFile(const std::string& path) std::string readFile(const std::string& path)
{ {
std::string text = ""; std::string text = "";
std::ifstream file(path); std::ifstream file(path);
if (file.good()) { if (file.good()) {