2020-09-20 01:21:28 +01:00
|
|
|
#include "tools_tab.hpp"
|
2021-09-11 14:48:13 +01:00
|
|
|
|
|
|
|
#include <filesystem>
|
|
|
|
#include <fstream>
|
|
|
|
|
2021-02-10 16:28:47 +00:00
|
|
|
#include "JC_page.hpp"
|
|
|
|
#include "PC_page.hpp"
|
2022-05-16 14:39:50 +01:00
|
|
|
#include "app_page.hpp"
|
2021-09-11 14:48:13 +01:00
|
|
|
#include "cheats_page.hpp"
|
|
|
|
#include "confirm_page.hpp"
|
2021-02-10 16:28:47 +00:00
|
|
|
#include "extract.hpp"
|
2021-03-16 14:56:46 +00:00
|
|
|
#include "fs.hpp"
|
2021-02-10 16:28:47 +00:00
|
|
|
#include "hide_tabs_page.hpp"
|
2021-09-11 14:48:13 +01:00
|
|
|
#include "net_page.hpp"
|
|
|
|
#include "payload_page.hpp"
|
|
|
|
#include "utils.hpp"
|
|
|
|
#include "worker_page.hpp"
|
2021-01-28 19:26:41 +00:00
|
|
|
|
2020-10-05 23:53:12 +01:00
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
2022-10-31 18:59:48 +00:00
|
|
|
using json = nlohmann::ordered_json;
|
2021-02-12 22:20:16 +00:00
|
|
|
|
2021-06-03 21:51:00 +01:00
|
|
|
namespace {
|
|
|
|
constexpr const char AppVersion[] = APP_VERSION;
|
|
|
|
}
|
|
|
|
|
2022-10-31 18:59:48 +00:00
|
|
|
ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payloads, bool erista, const nlohmann::ordered_json& hideStatus) : brls::List()
|
2020-09-20 01:21:28 +01:00
|
|
|
{
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!tag.empty() && tag != AppVersion) {
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* updateApp = new brls::ListItem(fmt::format("menus/tools/update_app"_i18n, tag));
|
2021-03-10 20:54:17 +00:00
|
|
|
std::string text("menus/tools/dl_app"_i18n + std::string(APP_URL));
|
2021-10-03 18:54:09 +01:00
|
|
|
updateApp->getClickEvent()->subscribe([text, tag](brls::View* view) {
|
2021-02-12 22:20:16 +00:00
|
|
|
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
2021-03-10 20:54:17 +00:00
|
|
|
stagedFrame->setTitle("menus/common/updating"_i18n);
|
2021-02-12 22:20:16 +00:00
|
|
|
stagedFrame->addStage(
|
2021-09-11 14:48:13 +01:00
|
|
|
new ConfirmPage(stagedFrame, text));
|
2021-02-12 22:20:16 +00:00
|
|
|
stagedFrame->addStage(
|
2021-09-27 20:56:41 +01:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, []() { util::downloadArchive(APP_URL, contentType::app); }));
|
2021-02-12 22:20:16 +00:00
|
|
|
stagedFrame->addStage(
|
2022-01-05 22:05:29 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(contentType::app); }));
|
2021-02-12 22:20:16 +00:00
|
|
|
stagedFrame->addStage(
|
2022-09-26 23:14:13 +01:00
|
|
|
new ConfirmPage_AppUpdate(stagedFrame, "menus/common/all_done"_i18n));
|
2021-02-12 22:20:16 +00:00
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
|
|
|
updateApp->setHeight(LISTITEM_HEIGHT);
|
|
|
|
this->addView(updateApp);
|
|
|
|
}
|
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* cheats = new brls::ListItem("menus/tools/cheats"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
cheats->getClickEvent()->subscribe([](brls::View* view) {
|
2021-11-19 13:28:10 +00:00
|
|
|
brls::PopupFrame::open("menus/cheats/menu"_i18n, new CheatsPage(), "", "");
|
2020-09-20 01:21:28 +01:00
|
|
|
});
|
2020-10-05 16:14:10 +01:00
|
|
|
cheats->setHeight(LISTITEM_HEIGHT);
|
2020-09-20 01:21:28 +01:00
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* outdatedTitles = new brls::ListItem("menus/tools/outdated_titles"_i18n);
|
|
|
|
outdatedTitles->getClickEvent()->subscribe([](brls::View* view) {
|
|
|
|
brls::PopupFrame::open("menus/tools/outdated_titles"_i18n, new AppPage_OutdatedTitles(), "menus/tools/outdated_titles_desc"_i18n, "");
|
|
|
|
});
|
|
|
|
outdatedTitles->setHeight(LISTITEM_HEIGHT);
|
|
|
|
|
|
|
|
brls::ListItem* JCcolor = new brls::ListItem("menus/tools/joy_cons"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
JCcolor->getClickEvent()->subscribe([](brls::View* view) {
|
2020-09-20 01:21:28 +01:00
|
|
|
brls::Application::pushView(new JCPage());
|
|
|
|
});
|
2020-10-05 16:14:10 +01:00
|
|
|
JCcolor->setHeight(LISTITEM_HEIGHT);
|
2020-09-20 01:21:28 +01:00
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* PCcolor = new brls::ListItem("menus/tools/pro_cons"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
PCcolor->getClickEvent()->subscribe([](brls::View* view) {
|
2020-12-28 18:28:58 +00:00
|
|
|
brls::Application::pushView(new PCPage());
|
|
|
|
});
|
|
|
|
PCcolor->setHeight(LISTITEM_HEIGHT);
|
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* rebootPayload = new brls::ListItem("menus/tools/inject_payloads"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
rebootPayload->getClickEvent()->subscribe([](brls::View* view) {
|
2021-10-26 14:48:24 +01:00
|
|
|
brls::PopupFrame::open("menus/tools/inject_payloads"_i18n, new PayloadPage(), "", "");
|
2021-07-21 14:38:43 +01:00
|
|
|
});
|
|
|
|
rebootPayload->setHeight(LISTITEM_HEIGHT);
|
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* netSettings = new brls::ListItem("menus/tools/internet_settings"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
netSettings->getClickEvent()->subscribe([](brls::View* view) {
|
2021-03-14 15:24:56 +00:00
|
|
|
brls::PopupFrame::open("menus/tools/internet_settings"_i18n, new NetPage(), "", "");
|
2021-01-02 23:22:45 +00:00
|
|
|
});
|
|
|
|
netSettings->setHeight(LISTITEM_HEIGHT);
|
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* browser = new brls::ListItem("menus/tools/browser"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
browser->getClickEvent()->subscribe([](brls::View* view) {
|
2021-07-19 22:06:40 +01:00
|
|
|
std::string url;
|
2023-05-06 00:54:01 +01:00
|
|
|
if (brls::Swkbd::openForText([&url](std::string text) { url = text; }, "cheatslips.com e-mail", "", 256, "https://duckduckgo.com", 0, "Submit", "https://website.tld")) {
|
2023-05-14 15:52:22 +01:00
|
|
|
util::openWebBrowser(url);
|
2021-01-02 23:22:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
browser->setHeight(LISTITEM_HEIGHT);
|
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* move = new brls::ListItem("menus/tools/batch_copy"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
move->getClickEvent()->subscribe([](brls::View* view) {
|
2021-02-12 22:20:16 +00:00
|
|
|
chdir("/");
|
|
|
|
std::string error = "";
|
2021-09-11 14:48:13 +01:00
|
|
|
if (std::filesystem::exists(COPY_FILES_TXT)) {
|
2021-05-22 17:10:34 +01:00
|
|
|
error = fs::copyFiles(COPY_FILES_TXT);
|
2021-02-12 22:20:16 +00:00
|
|
|
}
|
2021-09-11 14:48:13 +01:00
|
|
|
else {
|
2021-03-01 18:19:17 +00:00
|
|
|
error = "menus/tools/batch_copy_config_not_found"_i18n;
|
2021-02-12 22:20:16 +00:00
|
|
|
}
|
2022-03-30 21:23:15 +01:00
|
|
|
util::showDialogBoxInfo(error);
|
2021-02-12 22:20:16 +00:00
|
|
|
});
|
2021-02-15 00:02:34 +00:00
|
|
|
move->setHeight(LISTITEM_HEIGHT);
|
2021-02-12 22:20:16 +00:00
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* cleanUp = new brls::ListItem("menus/tools/clean_up"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
cleanUp->getClickEvent()->subscribe([](brls::View* view) {
|
2022-10-16 12:31:02 +01:00
|
|
|
std::filesystem::remove(AMS_FILENAME);
|
|
|
|
std::filesystem::remove(APP_FILENAME);
|
|
|
|
std::filesystem::remove(FIRMWARE_FILENAME);
|
|
|
|
std::filesystem::remove(CHEATS_FILENAME);
|
|
|
|
std::filesystem::remove(BOOTLOADER_FILENAME);
|
2021-11-19 13:28:10 +00:00
|
|
|
std::filesystem::remove(CHEATS_VERSION);
|
2022-10-16 12:31:02 +01:00
|
|
|
std::filesystem::remove(CUSTOM_FILENAME);
|
2021-03-16 14:56:46 +00:00
|
|
|
fs::removeDir(AMS_DIRECTORY_PATH);
|
|
|
|
fs::removeDir(SEPT_DIRECTORY_PATH);
|
|
|
|
fs::removeDir(FW_DIRECTORY_PATH);
|
2022-03-30 21:23:15 +01:00
|
|
|
util::showDialogBoxInfo("menus/common/all_done"_i18n);
|
2020-12-27 17:11:40 +00:00
|
|
|
});
|
|
|
|
cleanUp->setHeight(LISTITEM_HEIGHT);
|
2021-02-06 17:24:47 +00:00
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* language = new brls::ListItem("menus/tools/language"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
language->getClickEvent()->subscribe([](brls::View* view) {
|
2021-03-14 15:24:56 +00:00
|
|
|
std::vector<std::pair<std::string, std::string>> languages{
|
2022-04-21 00:58:50 +01:00
|
|
|
std::make_pair("American English ({})", "en-US"),
|
|
|
|
std::make_pair("日本語 ({})", "ja"),
|
|
|
|
std::make_pair("Français ({})", "fr"),
|
|
|
|
std::make_pair("Deutsch ({})", "de"),
|
|
|
|
std::make_pair("Italiano ({})", "it"),
|
|
|
|
std::make_pair("Español ({})", "es"),
|
|
|
|
std::make_pair("Português ({})", "pt"),
|
|
|
|
std::make_pair("Nederlands ({})", "nl"),
|
|
|
|
std::make_pair("Русский ({})", "ru"),
|
|
|
|
std::make_pair("한국어 ({})", "ko"),
|
|
|
|
std::make_pair("Polski ({})", "pl"),
|
|
|
|
std::make_pair("简体中文 ({})", "zh-CN"),
|
|
|
|
std::make_pair("繁體中文 ({})", "zh-TW"),
|
|
|
|
std::make_pair("English (Great Britain) ({})", "en-GB"),
|
|
|
|
std::make_pair("Français (Canada) ({})", "fr-CA"),
|
|
|
|
std::make_pair("Español (Latinoamérica) ({})", "es-419"),
|
|
|
|
std::make_pair("Português brasileiro ({})", "pt-BR"),
|
|
|
|
std::make_pair("Traditional Chinese ({})", "zh-Hant"),
|
|
|
|
std::make_pair("Simplified Chinese ({})", "zh-Hans")};
|
2021-03-14 15:24:56 +00:00
|
|
|
brls::AppletFrame* appView = new brls::AppletFrame(true, true);
|
|
|
|
brls::List* list = new brls::List();
|
|
|
|
brls::ListItem* listItem;
|
2022-04-21 00:58:50 +01:00
|
|
|
listItem = new brls::ListItem(fmt::format("System Default ({})", i18n::getCurrentLocale()));
|
2021-10-01 18:22:52 +01:00
|
|
|
listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [] {
|
2021-03-14 22:13:49 +00:00
|
|
|
std::filesystem::remove(LANGUAGE_JSON);
|
|
|
|
brls::Application::quit();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
list->addView(listItem);
|
2021-10-01 18:22:52 +01:00
|
|
|
for (auto& language : languages) {
|
2022-04-21 00:58:50 +01:00
|
|
|
if (std::filesystem::exists(fmt::format(LOCALISATION_FILE, language.second))) {
|
|
|
|
listItem = new brls::ListItem(fmt::format(language.first, language.second));
|
|
|
|
listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [language] {
|
|
|
|
json updatedLanguage = json::object();
|
|
|
|
updatedLanguage["language"] = language.second;
|
|
|
|
std::ofstream out(LANGUAGE_JSON);
|
|
|
|
out << updatedLanguage.dump();
|
|
|
|
brls::Application::quit();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
list->addView(listItem);
|
|
|
|
}
|
2021-03-14 15:24:56 +00:00
|
|
|
}
|
|
|
|
appView->setContentView(list);
|
|
|
|
brls::PopupFrame::open("menus/tools/language"_i18n, appView, "", "");
|
|
|
|
});
|
|
|
|
language->setHeight(LISTITEM_HEIGHT);
|
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* hideTabs = new brls::ListItem("menus/tools/hide_tabs"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
hideTabs->getClickEvent()->subscribe([](brls::View* view) {
|
2021-03-14 15:24:56 +00:00
|
|
|
brls::PopupFrame::open("menus/tools/hide_tabs"_i18n, new HideTabsPage(), "", "");
|
2021-02-06 17:24:47 +00:00
|
|
|
});
|
|
|
|
hideTabs->setHeight(LISTITEM_HEIGHT);
|
2020-09-23 12:21:05 +01:00
|
|
|
|
2022-05-16 14:39:50 +01:00
|
|
|
brls::ListItem* changelog = new brls::ListItem("menus/tools/changelog"_i18n);
|
2021-10-01 18:22:52 +01:00
|
|
|
changelog->getClickEvent()->subscribe([](brls::View* view) {
|
2023-05-14 15:52:22 +01:00
|
|
|
util::openWebBrowser(CHANGELOG_URL);
|
2020-09-23 12:21:05 +01:00
|
|
|
});
|
2020-10-05 16:14:10 +01:00
|
|
|
changelog->setHeight(LISTITEM_HEIGHT);
|
2021-07-21 14:38:43 +01:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "cheats")) this->addView(cheats);
|
2022-05-16 14:39:50 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "outdatedtitles")) this->addView(outdatedTitles);
|
2021-09-11 14:48:13 +01:00
|
|
|
if (!util::getBoolValue(hideStatus, "jccolor")) this->addView(JCcolor);
|
|
|
|
if (!util::getBoolValue(hideStatus, "pccolor")) this->addView(PCcolor);
|
|
|
|
if (erista && !util::getBoolValue(hideStatus, "rebootpayload")) this->addView(rebootPayload);
|
|
|
|
if (!util::getBoolValue(hideStatus, "netsettings")) this->addView(netSettings);
|
|
|
|
if (!util::getBoolValue(hideStatus, "browser")) this->addView(browser);
|
|
|
|
if (!util::getBoolValue(hideStatus, "move")) this->addView(move);
|
|
|
|
if (!util::getBoolValue(hideStatus, "cleanup")) this->addView(cleanUp);
|
|
|
|
if (!util::getBoolValue(hideStatus, "language")) this->addView(language);
|
2021-09-28 14:03:32 +01:00
|
|
|
this->addView(hideTabs);
|
2020-09-23 12:21:05 +01:00
|
|
|
this->addView(changelog);
|
2021-01-02 23:22:45 +00:00
|
|
|
}
|