1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-09 20:11:48 +00:00
AIO-switch-updater/source/cheats_page.cpp

79 lines
3.4 KiB
C++
Raw Normal View History

#include "cheats_page.hpp"
2021-09-11 14:48:13 +01:00
2021-02-10 16:28:47 +00:00
#include "app_page.hpp"
#include "confirm_page.hpp"
#include "constants.hpp"
#include "current_cfw.hpp"
#include "download.hpp"
2021-09-11 14:48:13 +01:00
#include "exclude_page.hpp"
#include "extract.hpp"
#include "utils.hpp"
2021-09-11 14:48:13 +01:00
#include "worker_page.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;
CheatsPage::CheatsPage() : AppletFrame(true, true)
{
this->setTitle("menus/cheats/menu"_i18n);
list = new brls::List();
2021-10-14 20:50:18 +01:00
item = new brls::ListItem("menus/cheats/view"_i18n);
item->getClickEvent()->subscribe([](brls::View* view) {
brls::Application::pushView(new AppPage_DownloadedCheats());
});
2021-10-14 20:50:18 +01:00
list->addView(item);
2021-10-14 20:50:18 +01:00
item = new brls::ListItem("menus/cheats/exclude"_i18n);
item->getClickEvent()->subscribe([](brls::View* view) {
brls::Application::pushView(new AppPage_Exclude());
2021-03-10 20:54:17 +00:00
});
2021-10-14 20:50:18 +01:00
list->addView(item);
2021-09-11 14:48:13 +01:00
2021-10-14 20:50:18 +01:00
item = new brls::ListItem("menus/cheats/delete_existing"_i18n);
item->getClickEvent()->subscribe([](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
2021-10-14 20:50:18 +01:00
stagedFrame->setTitle("menus/cheats/delete_existing"_i18n);
2021-03-10 20:54:17 +00:00
stagedFrame->addStage(
2021-09-11 14:48:13 +01:00
new WorkerPage(stagedFrame, "menus/cheats/deleting"_i18n, []() { extract::removeCheats(); }));
2021-03-10 20:54:17 +00:00
stagedFrame->addStage(
2021-09-11 14:48:13 +01:00
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
2021-03-10 20:54:17 +00:00
brls::Application::pushView(stagedFrame);
});
2021-10-14 20:50:18 +01:00
list->addView(item);
item = new brls::ListItem("menus/cheats/delete_orphaned"_i18n);
item->getClickEvent()->subscribe([](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("menus/cheats/delete_orphaned"_i18n);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/cheats/deleting"_i18n, []() { extract::removeOrphanedCheats(); }));
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
brls::Application::pushView(stagedFrame);
});
list->addView(item);
2021-03-10 20:54:17 +00:00
std::string cheatsVer = util::getCheatsVersion();
2021-09-11 14:48:13 +01:00
if (cheatsVer != "") {
2021-10-14 20:50:18 +01:00
item = new brls::ListItem("menus/cheats/dl_all"_i18n);
item->getClickEvent()->subscribe([cheatsVer](brls::View* view) {
std::string url = CurrentCfw::running_cfw == CFW::sxos ? CHEATS_URL_TITLES : CHEATS_URL_CONTENTS;
std::string text(fmt::format("menus/main/get_cheats"_i18n, cheatsVer) + "menus/common/from"_i18n + url);
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("menus/cheats/dl_all"_i18n);
stagedFrame->addStage(
2021-09-11 14:48:13 +01:00
new ConfirmPage(stagedFrame, text));
if (cheatsVer != "offline") {
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url]() { util::downloadArchive(url, contentType::cheats); }));
}
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [cheatsVer]() { extract::extractAllCheats(CHEATS_ZIP_PATH, CurrentCfw::running_cfw, cheatsVer); }));
stagedFrame->addStage(
2021-09-11 14:48:13 +01:00
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true));
brls::Application::pushView(stagedFrame);
});
2021-10-14 20:50:18 +01:00
list->addView(item);
}
this->setContentView(list);
}