2020-09-20 01:21:28 +01:00
|
|
|
#include "tools_tab.hpp"
|
2021-02-10 16:28:47 +00:00
|
|
|
#include "confirm_page.hpp"
|
|
|
|
#include "worker_page.hpp"
|
|
|
|
#include "cheats_page.hpp"
|
|
|
|
#include "payload_page.hpp"
|
|
|
|
#include "download_payload_page.hpp"
|
|
|
|
#include "changelog_page.hpp"
|
|
|
|
#include "JC_page.hpp"
|
|
|
|
#include "PC_page.hpp"
|
|
|
|
#include "net_page.hpp"
|
|
|
|
#include "extract.hpp"
|
|
|
|
#include "utils.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-03-16 02:43:48 +00:00
|
|
|
#include <json.hpp>
|
2021-02-10 16:28:47 +00:00
|
|
|
#include <filesystem>
|
2021-02-12 22:20:16 +00:00
|
|
|
#include <fstream>
|
2021-01-28 19:26:41 +00:00
|
|
|
|
2020-10-05 23:53:12 +01:00
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
2021-02-12 22:20:16 +00:00
|
|
|
using json = nlohmann::json;
|
|
|
|
|
2021-06-03 21:51:00 +01:00
|
|
|
namespace {
|
|
|
|
constexpr const char AppVersion[] = APP_VERSION;
|
|
|
|
}
|
|
|
|
|
2021-02-17 18:00:12 +00:00
|
|
|
ToolsTab::ToolsTab(std::string tag, bool erista) : brls::List()
|
2020-09-20 01:21:28 +01:00
|
|
|
{
|
2021-06-03 21:51:00 +01:00
|
|
|
if(!tag.empty() && tag != AppVersion){
|
2021-03-10 20:54:17 +00:00
|
|
|
updateApp = new brls::ListItem("menus/tools/update_app"_i18n + tag +")");
|
|
|
|
std::string text("menus/tools/dl_app"_i18n + std::string(APP_URL));
|
2021-02-12 22:20:16 +00:00
|
|
|
updateApp->getClickEvent()->subscribe([&, text, tag](brls::View* view) {
|
|
|
|
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(
|
|
|
|
new ConfirmPage(stagedFrame, text)
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-16 02:04:21 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [](){util::downloadArchive(APP_URL, archiveType::app);})
|
2021-02-12 22:20:16 +00:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-16 02:04:21 +00:00
|
|
|
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, [tag](){util::extractArchive(archiveType::app, tag);})
|
2021-02-12 22:20:16 +00:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2021-03-10 20:54:17 +00:00
|
|
|
new ConfirmPage(stagedFrame, "menus/common/all_done"_i18n, true)
|
2021-02-12 22:20:16 +00:00
|
|
|
);
|
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
|
|
|
updateApp->setHeight(LISTITEM_HEIGHT);
|
|
|
|
this->addView(updateApp);
|
|
|
|
}
|
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
cheats = new brls::ListItem("menus/tools/cheats"_i18n);
|
2020-09-26 15:55:24 +01:00
|
|
|
cheats->getClickEvent()->subscribe([&](brls::View* view){
|
|
|
|
brls::Application::pushView(new CheatsPage());
|
2020-09-20 01:21:28 +01:00
|
|
|
});
|
2020-10-05 16:14:10 +01:00
|
|
|
cheats->setHeight(LISTITEM_HEIGHT);
|
2020-09-26 15:55:24 +01:00
|
|
|
this->addView(cheats);
|
2020-09-20 01:21:28 +01:00
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
JCcolor = new brls::ListItem("menus/tools/joy_cons"_i18n);
|
2020-09-20 01:21:28 +01:00
|
|
|
JCcolor->getClickEvent()->subscribe([&](brls::View* view){
|
|
|
|
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
|
|
|
this->addView(JCcolor);
|
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
PCcolor = new brls::ListItem("menus/tools/pro_cons"_i18n);
|
2020-12-28 18:28:58 +00:00
|
|
|
PCcolor->getClickEvent()->subscribe([&](brls::View* view){
|
|
|
|
brls::Application::pushView(new PCPage());
|
|
|
|
});
|
|
|
|
PCcolor->setHeight(LISTITEM_HEIGHT);
|
|
|
|
this->addView(PCcolor);
|
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
downloadPayload = new brls::ListItem("menus/tools/dl_payloads"_i18n + std::string(BOOTLOADER_PL_PATH));
|
2020-09-26 15:55:24 +01:00
|
|
|
downloadPayload->getClickEvent()->subscribe([&](brls::View* view){
|
2020-09-21 19:36:46 +01:00
|
|
|
brls::Application::pushView(new DownloadPayloadPage());
|
|
|
|
});
|
2020-10-06 14:19:19 +01:00
|
|
|
downloadPayload->setHeight(LISTITEM_HEIGHT);
|
2020-09-26 15:55:24 +01:00
|
|
|
this->addView(downloadPayload);
|
2020-09-21 19:36:46 +01:00
|
|
|
|
2021-02-17 18:00:12 +00:00
|
|
|
if(erista) {
|
2021-03-10 20:54:17 +00:00
|
|
|
rebootPayload = new brls::ListItem("menus/tools/inject_payloads"_i18n);
|
2021-02-17 18:00:12 +00:00
|
|
|
rebootPayload->getClickEvent()->subscribe([&](brls::View* view){
|
|
|
|
brls::Application::pushView(new PayloadPage());
|
|
|
|
});
|
|
|
|
rebootPayload->setHeight(LISTITEM_HEIGHT);
|
|
|
|
this->addView(rebootPayload);
|
|
|
|
}
|
2020-12-27 17:11:40 +00:00
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
/* ntcp = new brls::ListItem("menus/ntcp"_i18n);
|
2020-12-27 17:11:40 +00:00
|
|
|
ntcp->getClickEvent()->subscribe([&](brls::View* view){
|
|
|
|
std::string res = syncTime();
|
|
|
|
brls::Dialog* dialog = new brls::Dialog(res);
|
|
|
|
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
|
|
|
dialog->close();
|
|
|
|
};
|
2021-03-11 01:46:22 +00:00
|
|
|
dialog->addButton("menus/common/ok"_i18n, callback);
|
2020-12-27 17:11:40 +00:00
|
|
|
dialog->setCancelable(true);
|
|
|
|
dialog->open();
|
|
|
|
|
|
|
|
});
|
|
|
|
ntcp->setHeight(LISTITEM_HEIGHT);
|
|
|
|
this->addView(ntcp); */
|
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
netSettings = new brls::ListItem("menus/tools/internet_settings"_i18n);
|
2021-01-02 23:22:45 +00: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);
|
|
|
|
this->addView(netSettings);
|
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
browser = new brls::ListItem("menus/tools/browser"_i18n);
|
2021-01-02 23:22:45 +00:00
|
|
|
browser->getClickEvent()->subscribe([&](brls::View* view){
|
|
|
|
char url[0xc00] = {0};
|
2021-02-06 17:24:47 +00:00
|
|
|
SwkbdConfig kbd;
|
|
|
|
Result rc = swkbdCreate(&kbd, 0);
|
|
|
|
if (R_SUCCEEDED(rc)) {
|
|
|
|
swkbdConfigMakePresetDefault(&kbd);
|
|
|
|
swkbdConfigSetGuideText(&kbd, "www.cheatslips.com e-mail");
|
|
|
|
swkbdConfigSetInitialText(&kbd, "https://duckduckgo.com");
|
|
|
|
swkbdShow(&kbd, url, sizeof(url));
|
|
|
|
swkbdClose(&kbd);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
strcpy(url, "https://duckduckgo.com");
|
|
|
|
}
|
2021-01-02 23:22:45 +00:00
|
|
|
std::string error = "";
|
2021-06-27 23:46:00 +01:00
|
|
|
int at = appletGetAppletType();
|
2021-01-02 23:22:45 +00:00
|
|
|
if(at == AppletType_Application) { // Running as a title
|
|
|
|
WebCommonConfig conf;
|
|
|
|
WebCommonReply out;
|
|
|
|
rc = webPageCreate(&conf, url);
|
|
|
|
if (R_FAILED(rc))
|
2021-02-06 17:24:47 +00:00
|
|
|
error += "\uE016 Error starting Browser\n\uE016 Lookup error code for more info " + rc;
|
2021-01-02 23:22:45 +00:00
|
|
|
webConfigSetJsExtension(&conf, true);
|
|
|
|
webConfigSetPageCache(&conf, true);
|
|
|
|
webConfigSetBootLoadingIcon(&conf, true);
|
|
|
|
webConfigSetWhitelist(&conf, ".*");
|
|
|
|
rc = webConfigShow(&conf, &out);
|
|
|
|
if (R_FAILED(rc))
|
2021-02-06 17:24:47 +00:00
|
|
|
error += "\uE016 Error starting Browser\n\uE016 Lookup error code for more info " + rc;
|
2021-01-02 23:22:45 +00:00
|
|
|
} else { // Running under applet
|
2021-02-16 00:46:39 +00:00
|
|
|
error += "\uE016 Running in applet mode/through a forwarder.\n\uE016 Please launch hbmenu by holding [R] on a game";
|
2021-01-02 23:22:45 +00:00
|
|
|
}
|
|
|
|
if(!error.empty()){
|
|
|
|
brls::Dialog* dialog = new brls::Dialog(error);
|
|
|
|
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
|
|
|
dialog->close();
|
|
|
|
};
|
2021-03-11 01:46:22 +00:00
|
|
|
dialog->addButton("menus/common/ok"_i18n, callback);
|
2021-01-02 23:22:45 +00:00
|
|
|
dialog->setCancelable(true);
|
|
|
|
dialog->open();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
browser->setHeight(LISTITEM_HEIGHT);
|
|
|
|
this->addView(browser);
|
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
move = new brls::ListItem("menus/tools/batch_copy"_i18n);
|
2021-02-15 00:02:34 +00:00
|
|
|
move->getClickEvent()->subscribe([&](brls::View* view){
|
2021-02-12 22:20:16 +00:00
|
|
|
chdir("/");
|
|
|
|
std::string error = "";
|
2021-05-22 17:10:34 +01:00
|
|
|
if(std::filesystem::exists(COPY_FILES_TXT)){
|
|
|
|
error = fs::copyFiles(COPY_FILES_TXT);
|
2021-02-12 22:20:16 +00: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
|
|
|
}
|
|
|
|
brls::Dialog* dialog = new brls::Dialog(error);
|
|
|
|
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
|
|
|
dialog->close();
|
|
|
|
};
|
2021-03-11 01:46:22 +00:00
|
|
|
dialog->addButton("menus/common/ok"_i18n, callback);
|
2021-02-12 22:20:16 +00:00
|
|
|
dialog->setCancelable(true);
|
|
|
|
dialog->open();
|
|
|
|
});
|
2021-02-15 00:02:34 +00:00
|
|
|
move->setHeight(LISTITEM_HEIGHT);
|
|
|
|
this->addView(move);
|
2021-02-12 22:20:16 +00:00
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
cleanUp = new brls::ListItem("menus/tools/clean_up"_i18n);
|
2020-12-27 17:11:40 +00:00
|
|
|
cleanUp->getClickEvent()->subscribe([&](brls::View* view){
|
|
|
|
std::filesystem::remove(AMS_ZIP_PATH);
|
|
|
|
std::filesystem::remove(APP_ZIP_PATH);
|
|
|
|
std::filesystem::remove(CFW_ZIP_PATH);
|
|
|
|
std::filesystem::remove(FW_ZIP_PATH);
|
|
|
|
std::filesystem::remove(CHEATS_ZIP_PATH);
|
|
|
|
std::filesystem::remove(SIGPATCHES_ZIP_PATH);
|
2021-03-16 14:56:46 +00:00
|
|
|
fs::removeDir(AMS_DIRECTORY_PATH);
|
|
|
|
fs::removeDir(SEPT_DIRECTORY_PATH);
|
|
|
|
fs::removeDir(FW_DIRECTORY_PATH);
|
2021-03-01 18:19:17 +00:00
|
|
|
brls::Dialog* dialog = new brls::Dialog("menus/common/all_done"_i18n);
|
2020-12-27 17:11:40 +00:00
|
|
|
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
|
|
|
dialog->close();
|
|
|
|
};
|
2021-03-11 01:46:22 +00:00
|
|
|
dialog->addButton("menus/common/ok"_i18n, callback);
|
2020-12-27 17:11:40 +00:00
|
|
|
dialog->setCancelable(true);
|
|
|
|
dialog->open();
|
|
|
|
});
|
|
|
|
cleanUp->setHeight(LISTITEM_HEIGHT);
|
|
|
|
this->addView(cleanUp);
|
2021-02-06 17:24:47 +00:00
|
|
|
|
2021-03-14 15:24:56 +00:00
|
|
|
language = new brls::ListItem("menus/tools/language"_i18n);
|
|
|
|
language->getClickEvent()->subscribe([&](brls::View* view){
|
|
|
|
std::vector<std::pair<std::string, std::string>> languages{
|
|
|
|
std::make_pair("menus/language/en-US"_i18n, "en-US"),
|
|
|
|
std::make_pair("menus/language/ja"_i18n, "ja"),
|
|
|
|
std::make_pair("menus/language/fr"_i18n, "fr"),
|
|
|
|
std::make_pair("menus/language/de"_i18n, "de"),
|
|
|
|
std::make_pair("menus/language/it"_i18n, "it"),
|
|
|
|
std::make_pair("menus/language/es"_i18n, "es"),
|
2021-03-19 16:12:23 +00:00
|
|
|
std::make_pair("menus/language/pl"_i18n, "pl"),
|
2021-03-14 15:24:56 +00:00
|
|
|
std::make_pair("menus/language/zh-CN"_i18n, "zh-CN"),
|
|
|
|
std::make_pair("menus/language/zh-TW"_i18n, "zh-TW"),
|
|
|
|
std::make_pair("menus/language/es-419"_i18n, "es-419"),
|
|
|
|
std::make_pair("menus/language/zh-Hant"_i18n, "zh-Hant"),
|
|
|
|
std::make_pair("menus/language/zh-Hans"_i18n, "zh-Hans")
|
|
|
|
};
|
|
|
|
brls::AppletFrame* appView = new brls::AppletFrame(true, true);
|
|
|
|
brls::List* list = new brls::List();
|
|
|
|
brls::ListItem* listItem;
|
2021-03-14 22:13:49 +00:00
|
|
|
listItem = new brls::ListItem(fmt::format("{} ({})", "menus/language/system_default"_i18n, i18n::getCurrentLocale()));
|
|
|
|
listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [this] {
|
|
|
|
std::filesystem::remove(LANGUAGE_JSON);
|
|
|
|
brls::Application::quit();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
list->addView(listItem);
|
2021-03-14 15:24:56 +00:00
|
|
|
for(auto& l : languages){
|
|
|
|
listItem = new brls::ListItem(l.first);
|
|
|
|
listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [this, l] {
|
|
|
|
json updatedLanguage = json::object();
|
|
|
|
updatedLanguage["language"] = l.second;
|
|
|
|
std::ofstream out(LANGUAGE_JSON);
|
|
|
|
out << updatedLanguage.dump();
|
|
|
|
brls::Application::quit();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
list->addView(listItem);
|
|
|
|
}
|
|
|
|
appView->setContentView(list);
|
|
|
|
brls::PopupFrame::open("menus/tools/language"_i18n, appView, "", "");
|
|
|
|
});
|
|
|
|
language->setHeight(LISTITEM_HEIGHT);
|
|
|
|
this->addView(language);
|
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
hideTabs = new brls::ListItem("menus/tools/hide_tabs"_i18n);
|
2021-02-06 17:24:47 +00: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);
|
|
|
|
this->addView(hideTabs);
|
2020-09-23 12:21:05 +01:00
|
|
|
|
2021-03-10 20:54:17 +00:00
|
|
|
changelog = new brls::ListItem("menus/tools/changelog"_i18n);
|
2020-09-23 12:21:05 +01:00
|
|
|
changelog->getClickEvent()->subscribe([&](brls::View* view){
|
2021-03-14 15:24:56 +00:00
|
|
|
brls::PopupFrame::open("menus/tools/changelog"_i18n, new ChangelogPage(), "", "");
|
2020-09-23 12:21:05 +01:00
|
|
|
});
|
2020-10-05 16:14:10 +01:00
|
|
|
changelog->setHeight(LISTITEM_HEIGHT);
|
2020-09-23 12:21:05 +01:00
|
|
|
this->addView(changelog);
|
2021-01-02 23:22:45 +00:00
|
|
|
}
|
|
|
|
|