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:
parent
b7cf0dd132
commit
e056903326
12 changed files with 41 additions and 105 deletions
|
@ -11,7 +11,6 @@ namespace show_cheats {
|
|||
void ShowCheatFiles(uint64_t tid, 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);
|
||||
void NoCheatsFoundPopup();
|
||||
void DeleteCheats(u64 tid, const std::string& bid);
|
||||
|
||||
} // namespace show_cheats
|
||||
|
|
|
@ -32,8 +32,9 @@ namespace util {
|
|||
std::vector<std::string> fetchPayloads();
|
||||
void shutDown(bool reboot = false);
|
||||
void rebootToPayload(const std::string& path);
|
||||
int showDialogBox(const std::string& text, const std::string& opt);
|
||||
int showDialogBox(const std::string& text, const std::string& opt1, const std::string& opt2);
|
||||
void showDialogBoxInfo(const std::string& text);
|
||||
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 downloadFileToString(const std::string& url);
|
||||
std::string getCheatsVersion();
|
||||
|
|
|
@ -180,14 +180,7 @@ void AmsTab::ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules)
|
|||
}
|
||||
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] {
|
||||
brls::Dialog* dialog;
|
||||
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();
|
||||
util::showDialogBoxInfo(fmt::format("{}:\n{}", module_value.at("repo"), module_value.at("description")));
|
||||
return true;
|
||||
});
|
||||
list->addView(deepseaListItem);
|
||||
|
|
|
@ -279,13 +279,7 @@ void AppPage_DownloadedCheats::DeclareGameListItem(const std::string& name, u64
|
|||
if (titles.find(tid_str) != titles.end()) {
|
||||
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] {
|
||||
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));
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
};
|
||||
dialog->addButton("menus/common/ok"_i18n, callback);
|
||||
dialog->setCancelable(true);
|
||||
dialog->open();
|
||||
util::showDialogBoxInfo(extract::removeCheatsDirectory(fmt::format("{}{}", util::getContentsPath(), tid_str)) ? "menus/common/all_done"_i18n : fmt::format("menus/cheats/deletion_error"_i18n, tid_str));
|
||||
return true;
|
||||
});
|
||||
AppPage::DeclareGameListItem(name, tid, controlData);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "changelog_page.hpp"
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace i18n = brls::i18n;
|
||||
using namespace i18n::literals;
|
||||
ChangelogPage::ChangelogPage() : AppletFrame(true, true)
|
||||
|
@ -233,13 +235,7 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
|
|||
listItem = new brls::ListItem(verTitles[i]);
|
||||
change = changes[i];
|
||||
listItem->getClickEvent()->subscribe([change](brls::View* view) {
|
||||
brls::Dialog* dialog = new brls::Dialog(change);
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
};
|
||||
dialog->addButton("menus/common/ok"_i18n, callback);
|
||||
dialog->setCancelable(true);
|
||||
dialog->open();
|
||||
util::showDialogBoxInfo(change);
|
||||
});
|
||||
list->addView(listItem);
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ namespace JC {
|
|||
ProgressEvent::instance().setStep(1);
|
||||
int res = setColor(values);
|
||||
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();
|
||||
hidsysExit();
|
||||
|
@ -329,7 +329,7 @@ namespace PC {
|
|||
ProgressEvent::instance().setStep(1);
|
||||
int res = setColor(values);
|
||||
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();
|
||||
hidsysExit();
|
||||
|
|
|
@ -25,19 +25,13 @@ namespace show_cheats {
|
|||
appView->setContentView(cheatsList);
|
||||
appView->registerAction("menus/cheats/delete_file"_i18n, brls::Key::X, [tid, bid] {
|
||||
DeleteCheats(tid, bid);
|
||||
brls::Dialog* dialog = new brls::Dialog("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();
|
||||
util::showDialogBoxInfo("menus/common/all_done"_i18n);
|
||||
return true;
|
||||
});
|
||||
brls::PopupFrame::open(name, appView, "");
|
||||
}
|
||||
else {
|
||||
NoCheatsFoundPopup();
|
||||
util::showDialogBoxInfo("menus/cheats/not_found"_i18n);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,21 +55,10 @@ namespace show_cheats {
|
|||
brls::PopupFrame::open(name, appView, "");
|
||||
}
|
||||
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 res = false;
|
||||
|
@ -276,21 +259,16 @@ DownloadCheatsPage_CheatSlips::DownloadCheatsPage_CheatSlips(uint64_t tid, const
|
|||
}
|
||||
|
||||
if (error != 0) {
|
||||
brls::Dialog* dialog;
|
||||
std::string error_message;
|
||||
switch (error) {
|
||||
case 1:
|
||||
dialog = new brls::Dialog("menus/cheats/quota"_i18n);
|
||||
error_message = "menus/cheats/quota"_i18n;
|
||||
break;
|
||||
case 2:
|
||||
dialog = new brls::Dialog("menus/cheats/cheatslips_error"_i18n);
|
||||
error_message = "menus/cheats/cheatslips_error"_i18n;
|
||||
break;
|
||||
}
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
};
|
||||
dialog->addButton("menus/common/ok"_i18n, callback);
|
||||
dialog->setCancelable(true);
|
||||
dialog->open();
|
||||
util::showDialogBoxInfo(error_message);
|
||||
}
|
||||
}
|
||||
if (error == 0) {
|
||||
|
@ -361,13 +339,7 @@ DownloadCheatsPage_GbaTemp::DownloadCheatsPage_GbaTemp(uint64_t tid, const std::
|
|||
this->listItem = new brls::ListItem(cheat.at("title"));
|
||||
listItem->registerAction("menus/cheats/gbatemp_dl_cheatcode"_i18n, brls::Key::A, [this, cheat] {
|
||||
WriteCheats(cheat.at("content"));
|
||||
brls::Dialog* dialog = new brls::Dialog(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();
|
||||
util::showDialogBoxInfo(fmt::format("menus/cheats/gbatemp_dl_successful_dl"_i18n, cheat.at("title")));
|
||||
return true;
|
||||
});
|
||||
this->list->addView(listItem);
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace extract {
|
|||
unzipper.extractEntry(entry.name);
|
||||
if (entry.name.substr(0, 13) == "hekate_ctcaer") {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,13 +200,7 @@ void ListDownloadTab::createCheatSlipItem()
|
|||
return true;
|
||||
}
|
||||
else {
|
||||
brls::Dialog* dialog = new brls::Dialog("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();
|
||||
util::showDialogBoxInfo("menus/cheats/cheatslips_wrong_id"_i18n + "\n" + "menus/cheats/kb_error"_i18n);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,13 +57,7 @@ void PayloadPage::RegisterCopyAction(brls::Key key, const std::string& payload_p
|
|||
std::string res = fs::copyFile(payload_path, payload_dest)
|
||||
? fmt::format("menus/payloads/copy_success"_i18n, payload_path, payload_dest)
|
||||
: "Failed.";
|
||||
brls::Dialog* dialog = new brls::Dialog(res);
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
};
|
||||
dialog->addButton("menus/common/ok"_i18n, callback);
|
||||
dialog->setCancelable(true);
|
||||
dialog->open();
|
||||
util::showDialogBoxInfo(res);
|
||||
return true;
|
||||
});
|
||||
}
|
|
@ -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";
|
||||
}
|
||||
if (!error.empty()) {
|
||||
brls::Dialog* dialog = new brls::Dialog(error);
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
};
|
||||
dialog->addButton("menus/common/ok"_i18n, callback);
|
||||
dialog->setCancelable(true);
|
||||
dialog->open();
|
||||
util::showDialogBoxInfo(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -122,13 +116,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
else {
|
||||
error = "menus/tools/batch_copy_config_not_found"_i18n;
|
||||
}
|
||||
brls::Dialog* dialog = new brls::Dialog(error);
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
};
|
||||
dialog->addButton("menus/common/ok"_i18n, callback);
|
||||
dialog->setCancelable(true);
|
||||
dialog->open();
|
||||
util::showDialogBoxInfo(error);
|
||||
});
|
||||
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(SEPT_DIRECTORY_PATH);
|
||||
fs::removeDir(FW_DIRECTORY_PATH);
|
||||
brls::Dialog* dialog = new brls::Dialog("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();
|
||||
util::showDialogBoxInfo("menus/common/all_done"_i18n);
|
||||
});
|
||||
cleanUp->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
|
|
|
@ -67,7 +67,19 @@ namespace util {
|
|||
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 result = -1;
|
||||
|
@ -86,7 +98,7 @@ namespace util {
|
|||
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 result = -1;
|
||||
|
@ -167,14 +179,14 @@ namespace util {
|
|||
brls::Application::quit();
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
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)
|
||||
removeSysmodulesFlags(AMS_CONTENTS);
|
||||
extract::extract(AMS_FILENAME, ROOT_PATH, overwriteInis);
|
||||
|
@ -273,7 +285,6 @@ namespace util {
|
|||
|
||||
std::string readFile(const std::string& path)
|
||||
{
|
||||
|
||||
std::string text = "";
|
||||
std::ifstream file(path);
|
||||
if (file.good()) {
|
||||
|
|
Loading…
Reference in a new issue