2020-09-26 15:55:24 +01:00
|
|
|
#include "cheats_page.hpp"
|
2021-02-10 16:28:47 +00:00
|
|
|
#include "app_page.hpp"
|
|
|
|
#include "exclude_page.hpp"
|
|
|
|
#include "worker_page.hpp"
|
|
|
|
#include "confirm_page.hpp"
|
|
|
|
#include "current_cfw.hpp"
|
|
|
|
#include "extract.hpp"
|
2021-03-10 16:23:02 +00:00
|
|
|
#include "constants.hpp"
|
|
|
|
#include "current_cfw.hpp"
|
|
|
|
#include "download.hpp"
|
|
|
|
#include "utils.hpp"
|
|
|
|
|
2020-10-05 23:53:12 +01:00
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
2020-09-26 15:55:24 +01:00
|
|
|
CheatsPage::CheatsPage() : AppletFrame(true, true)
|
|
|
|
{
|
2021-03-10 16:23:02 +00:00
|
|
|
this->setTitle("menus/cheats/menu"_i18n);
|
2020-09-26 15:55:24 +01:00
|
|
|
list = new brls::List();
|
|
|
|
|
2021-06-28 15:58:04 +01:00
|
|
|
view = new brls::ListItem("menus/cheats/view"_i18n);
|
2020-09-26 15:55:24 +01:00
|
|
|
view->getClickEvent()->subscribe([&](brls::View* view){
|
2021-06-27 23:46:00 +01:00
|
|
|
brls::Application::pushView(new AppPage_DownloadedCheats());
|
2020-09-26 15:55:24 +01:00
|
|
|
});
|
2021-06-28 15:58:04 +01:00
|
|
|
list->addView(view);
|
2020-09-26 15:55:24 +01:00
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
exclude = new brls::ListItem("menus/cheats/exclude"_i18n);
|
|
|
|
exclude->getClickEvent()->subscribe([&](brls::View* view){
|
2021-06-27 23:46:00 +01:00
|
|
|
brls::Application::pushView(new AppPage_Exclude());
|
2021-03-10 20:54:17 +00:00
|
|
|
});
|
|
|
|
list->addView(exclude);
|
|
|
|
|
|
|
|
deleteCheats = new brls::ListItem("menus/cheats/delete_existing"_i18n);
|
|
|
|
deleteCheats->getClickEvent()->subscribe([&](brls::View* view){
|
|
|
|
stagedFrame = new brls::StagedAppletFrame();
|
|
|
|
stagedFrame->setTitle("menus/cheats/delete_all"_i18n);
|
|
|
|
stagedFrame->addStage(
|
2021-03-16 02:04:21 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/cheats/deleting"_i18n, [](){extract::removeCheats(CurrentCfw::running_cfw);})
|
2021-03-10 20:54:17 +00:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true)
|
|
|
|
);
|
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
|
|
|
list->addView(deleteCheats);
|
|
|
|
|
2021-06-27 23:46:00 +01:00
|
|
|
std::string cheatsVer = util::downloadFileToString(CHEATS_URL_VERSION);
|
2021-03-10 16:23:02 +00:00
|
|
|
if(cheatsVer != "") {
|
|
|
|
dlAll = new brls::ListItem("menus/cheats/dl_all"_i18n);
|
|
|
|
dlAll->getClickEvent()->subscribe([&, cheatsVer](brls::View* view) {
|
|
|
|
std::string url;
|
2021-03-16 02:04:21 +00:00
|
|
|
switch(CurrentCfw::running_cfw){
|
|
|
|
case CFW::sxos:
|
2021-03-10 16:23:02 +00:00
|
|
|
url = CHEATS_URL_TITLES;
|
|
|
|
break;
|
2021-03-16 02:04:21 +00:00
|
|
|
case CFW::ams:
|
2021-03-10 16:23:02 +00:00
|
|
|
url = CHEATS_URL_CONTENTS;
|
|
|
|
break;
|
2021-03-16 02:04:21 +00:00
|
|
|
case CFW::rnx:
|
2021-03-10 16:23:02 +00:00
|
|
|
url = CHEATS_URL_CONTENTS;
|
|
|
|
break;
|
|
|
|
}
|
2021-03-10 20:54:17 +00:00
|
|
|
std::string text("menus/main/get_cheats"_i18n + cheatsVer + ")" + "menus/common/from"_i18n + url);
|
2021-03-10 16:23:02 +00:00
|
|
|
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
|
|
|
stagedFrame->setTitle("menus/cheats/dl_all"_i18n);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, text)
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-16 02:04:21 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url](){util::downloadArchive(url, archiveType::cheats);})
|
2021-03-10 16:23:02 +00:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-16 02:04:21 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [](){extract::extractAllCheats(CHEATS_ZIP_PATH, CurrentCfw::running_cfw);})
|
2021-03-10 16:23:02 +00:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true)
|
|
|
|
);
|
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
|
|
|
list->addView(dlAll);
|
|
|
|
}
|
2020-09-26 15:55:24 +01:00
|
|
|
this->setContentView(list);
|
|
|
|
}
|