mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-12-26 17:56:04 +00:00
show cheatsheet for the right BID in download cheats page, code clean up
This commit is contained in:
parent
4304dff045
commit
86d0a2fddb
14 changed files with 95 additions and 74 deletions
2
.vscode/c_cpp_properties.json
vendored
2
.vscode/c_cpp_properties.json
vendored
|
@ -16,7 +16,7 @@
|
|||
],
|
||||
"compilerPath": "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"cppStandard": "c++20",
|
||||
"intelliSenseMode": "gcc-x64"
|
||||
}
|
||||
],
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
namespace show_cheats {
|
||||
|
||||
void ShowCheatFiles(uint64_t tid, const std::string& name);
|
||||
bool CreateCheatList(const std::filesystem::path& path, brls::TabFrame** appView);
|
||||
void ShowCheatSheet(u64 tid, const std::string& bid, const std::string& name);
|
||||
bool CreateCheatList(const std::filesystem::path& path, brls::List** cheatsList);
|
||||
void NoCheatsFoundPopup();
|
||||
|
||||
} // namespace show_cheats
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ JCPage::JCPage() : AppletFrame(true, true)
|
|||
list->addView(label);
|
||||
|
||||
backup = new brls::ListItem("menus/joy_con/backup"_i18n);
|
||||
backup->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
backup->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||
stagedFrame->setTitle("menus/joy_con/label"_i18n);
|
||||
stagedFrame->addStage(
|
||||
|
@ -35,7 +35,7 @@ JCPage::JCPage() : AppletFrame(true, true)
|
|||
for (int i = profiles.size() - 1; i >= 0; i--) {
|
||||
std::vector<int> value = profiles[i].second;
|
||||
listItem = new brls::ListItem(profiles[i].first);
|
||||
listItem->getClickEvent()->subscribe([&, value](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([&value](brls::View* view) {
|
||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||
stagedFrame->setTitle("menus/joy_con/label"_i18n);
|
||||
stagedFrame->addStage(
|
||||
|
|
|
@ -16,7 +16,7 @@ PCPage::PCPage() : AppletFrame(true, true)
|
|||
list->addView(label);
|
||||
|
||||
backup = new brls::ListItem("menus/joy_con/backup"_i18n);
|
||||
backup->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
backup->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||
stagedFrame->setTitle("menus/pro_con/label"_i18n);
|
||||
stagedFrame->addStage(
|
||||
|
@ -34,7 +34,7 @@ PCPage::PCPage() : AppletFrame(true, true)
|
|||
for (int i = profiles.size() - 1; i >= 0; i--) {
|
||||
std::vector<int> value = profiles[i].second;
|
||||
listItem = new brls::ListItem(profiles[i].first);
|
||||
listItem->getClickEvent()->subscribe([&, value](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([&value](brls::View* view) {
|
||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||
stagedFrame->setTitle("menus/pro_con/label"_i18n);
|
||||
stagedFrame->addStage(
|
||||
|
|
|
@ -34,10 +34,10 @@ AmsTab::AmsTab(const nlohmann::json& nxlinks, const bool erista, const bool hide
|
|||
|
||||
listItem = new brls::ListItem("menus/ams_update/get_custom_deepsea"_i18n);
|
||||
listItem->setHeight(LISTITEM_HEIGHT);
|
||||
listItem->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([this](brls::View* view) {
|
||||
nlohmann::ordered_json modules;
|
||||
download::getRequest(DEEPSEA_META_JSON, modules);
|
||||
ShowCustomDeepseaBuilder(modules);
|
||||
this->ShowCustomDeepseaBuilder(modules);
|
||||
});
|
||||
this->addView(listItem);
|
||||
|
||||
|
@ -71,7 +71,7 @@ void AmsTab::CreateDownloadItems(const nlohmann::ordered_json& cfw_links, bool h
|
|||
std::string text("menus/common/download"_i18n + link.first + "menus/common/from"_i18n + url);
|
||||
listItem = new brls::ListItem(link.first);
|
||||
listItem->setHeight(LISTITEM_HEIGHT);
|
||||
listItem->getClickEvent()->subscribe([&, this, text, text_hekate, url, hekate_url, operation, hekate](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([this, &text, &text_hekate, &url, &hekate_url, &operation, hekate](brls::View* view) {
|
||||
if (!erista && !std::filesystem::exists(MARIKO_PAYLOAD_PATH)) {
|
||||
brls::Application::crash("menus/errors/mariko_payload_missing"_i18n);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void AmsTab::ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules)
|
|||
"menus/common/off"_i18n);
|
||||
}
|
||||
name_map.insert(std::pair(module_value.at("displayName"), module.key()));
|
||||
deepseaListItem->registerAction("menus/ams_update/show_module_description"_i18n, brls::Key::Y, [this, module_value] {
|
||||
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) {
|
||||
|
@ -197,7 +197,7 @@ void AmsTab::ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules)
|
|||
appView->addTab(category.key(), list);
|
||||
}
|
||||
|
||||
appView->registerAction("menus/ams_update/download_deepsea_package"_i18n, brls::Key::X, [this, lists, name_map] {
|
||||
appView->registerAction("menus/ams_update/download_deepsea_package"_i18n, brls::Key::X, [this, &lists, &name_map] {
|
||||
std::set<std::string> desired_modules;
|
||||
for (const auto& list : lists) {
|
||||
for (size_t i = 0; i < list->getViewsCount(); i++) {
|
||||
|
|
|
@ -84,7 +84,7 @@ void AppPage::CreateDownloadAllButton()
|
|||
}
|
||||
text += url;
|
||||
download = new brls::ListItem("menus/cheats/dl_latest"_i18n);
|
||||
download->getClickEvent()->subscribe([&, url, text](brls::View* view) {
|
||||
download->getClickEvent()->subscribe([&url, &text](brls::View* view) {
|
||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||
stagedFrame->setTitle("menus/cheats/getting_cheats"_i18n);
|
||||
stagedFrame->addStage(
|
||||
|
@ -167,7 +167,7 @@ void AppPage_CheatSlips::CreateLabel()
|
|||
|
||||
void AppPage_CheatSlips::DeclareGameListItem(const std::string& name, u64 tid, NsApplicationControlData** controlData)
|
||||
{
|
||||
listItem->getClickEvent()->subscribe([&, tid, name](brls::View* view) { brls::Application::pushView(new DownloadCheatsPage_CheatSlips(tid, name)); });
|
||||
listItem->getClickEvent()->subscribe([tid, &name](brls::View* view) { brls::Application::pushView(new DownloadCheatsPage_CheatSlips(tid, name)); });
|
||||
AppPage::DeclareGameListItem(name, tid, controlData);
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ void AppPage_Gbatemp::CreateLabel()
|
|||
|
||||
void AppPage_Gbatemp::DeclareGameListItem(const std::string& name, u64 tid, NsApplicationControlData** controlData)
|
||||
{
|
||||
listItem->getClickEvent()->subscribe([&, tid, name](brls::View* view) { brls::Application::pushView(new DownloadCheatsPage_GbaTemp(tid, name)); });
|
||||
listItem->getClickEvent()->subscribe([tid, &name](brls::View* view) { brls::Application::pushView(new DownloadCheatsPage_GbaTemp(tid, name)); });
|
||||
AppPage::DeclareGameListItem(name, tid, controlData);
|
||||
}
|
||||
|
||||
|
@ -277,8 +277,8 @@ void AppPage_DownloadedCheats::DeclareGameListItem(const std::string& name, u64
|
|||
{
|
||||
auto tid_str = util::formatApplicationId(tid);
|
||||
if (titles.find(tid_str) != titles.end()) {
|
||||
listItem->getClickEvent()->subscribe([this, tid, name](brls::View* view) { show_cheats::ShowCheatFiles(tid, name); });
|
||||
listItem->registerAction("menus/cheats/delete_cheats"_i18n, brls::Key::Y, [this, tid_str] {
|
||||
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();
|
||||
|
|
|
@ -214,7 +214,7 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
|
|||
for (int i = verTitles.size() - 1; i >= 0; i--) {
|
||||
listItem = new brls::ListItem(verTitles[i]);
|
||||
change = changes[i];
|
||||
listItem->getClickEvent()->subscribe([&, change](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([&change](brls::View* view) {
|
||||
brls::Dialog* dialog = new brls::Dialog(change);
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
|
@ -231,7 +231,7 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
|
|||
void ChangelogPage::ShowChangelogContent(const std::string version, const std::string content)
|
||||
{
|
||||
listItem = new brls::ListItem(version);
|
||||
listItem->getClickEvent()->subscribe([&, content](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([&version, &content](brls::View* view) {
|
||||
brls::AppletFrame* appView = new brls::AppletFrame(true, true);
|
||||
|
||||
brls::PopupFrame::open(version, appView, "", "");
|
||||
|
|
|
@ -18,20 +18,20 @@ CheatsPage::CheatsPage() : AppletFrame(true, true)
|
|||
list = new brls::List();
|
||||
|
||||
view = new brls::ListItem("menus/cheats/view"_i18n);
|
||||
view->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
view->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::Application::pushView(new AppPage_DownloadedCheats());
|
||||
});
|
||||
list->addView(view);
|
||||
|
||||
exclude = new brls::ListItem("menus/cheats/exclude"_i18n);
|
||||
exclude->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
exclude->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::Application::pushView(new AppPage_Exclude());
|
||||
});
|
||||
list->addView(exclude);
|
||||
|
||||
deleteCheats = new brls::ListItem("menus/cheats/delete_existing"_i18n);
|
||||
deleteCheats->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
stagedFrame = new brls::StagedAppletFrame();
|
||||
deleteCheats->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||
stagedFrame->setTitle("menus/cheats/delete_all"_i18n);
|
||||
stagedFrame->addStage(
|
||||
new WorkerPage(stagedFrame, "menus/cheats/deleting"_i18n, []() { extract::removeCheats(); }));
|
||||
|
@ -44,7 +44,7 @@ CheatsPage::CheatsPage() : AppletFrame(true, true)
|
|||
std::string cheatsVer = util::downloadFileToString(CHEATS_URL_VERSION);
|
||||
if (cheatsVer != "") {
|
||||
dlAll = new brls::ListItem("menus/cheats/dl_all"_i18n);
|
||||
dlAll->getClickEvent()->subscribe([&, cheatsVer](brls::View* view) {
|
||||
dlAll->getClickEvent()->subscribe([&cheatsVer](brls::View* view) {
|
||||
std::string url;
|
||||
switch (CurrentCfw::running_cfw) {
|
||||
case CFW::sxos:
|
||||
|
|
|
@ -16,6 +16,20 @@ using json = nlohmann::json;
|
|||
|
||||
namespace show_cheats {
|
||||
|
||||
void ShowCheatSheet(u64 tid, const std::string& bid, const std::string& name)
|
||||
{
|
||||
std::string path = fmt::format("{}{}/cheats/{}.txt", util::getContentsPath(), util::formatApplicationId(tid), bid);
|
||||
brls::AppletFrame* appView = new brls::AppletFrame(true, true);
|
||||
brls::List* cheatsList = new brls::List();
|
||||
if (std::filesystem::exists(path) && CreateCheatList(path, &cheatsList)) {
|
||||
appView->setContentView(cheatsList);
|
||||
brls::PopupFrame::open(name, appView, "");
|
||||
}
|
||||
else {
|
||||
NoCheatsFoundPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void ShowCheatFiles(u64 tid, const std::string& name)
|
||||
{
|
||||
std::string path = util::getContentsPath();
|
||||
|
@ -25,29 +39,37 @@ namespace show_cheats {
|
|||
bool is_populated = false;
|
||||
if (std::filesystem::exists(path)) {
|
||||
for (const auto& cheatFile : std::filesystem::directory_iterator(path)) {
|
||||
is_populated |= CreateCheatList(cheatFile.path(), &appView);
|
||||
brls::List* cheatsList = new brls::List();
|
||||
is_populated |= CreateCheatList(cheatFile.path(), &cheatsList);
|
||||
if (is_populated) {
|
||||
appView->addTab(util::upperCase(cheatFile.path().stem()), cheatsList);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_populated) {
|
||||
brls::PopupFrame::open(name, appView, "");
|
||||
}
|
||||
else {
|
||||
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();
|
||||
NoCheatsFoundPopup();
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateCheatList(const std::filesystem::path& path, brls::TabFrame** appView)
|
||||
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;
|
||||
brls::List* cheatsList = new brls::List();
|
||||
if (extract::isBID(path.filename().stem())) {
|
||||
cheatsList->addView(new brls::Label(brls::LabelStyle::DESCRIPTION, fmt::format("menus/cheats/cheatfile_label"_i18n, path.filename().string()), true));
|
||||
(*cheatsList)->addView(new brls::Label(brls::LabelStyle::DESCRIPTION, fmt::format("menus/cheats/cheatfile_label"_i18n, path.filename().string()), true));
|
||||
|
||||
std::string str;
|
||||
std::regex cheats_expr(R"(\[.+\]|\{.+\})");
|
||||
|
@ -56,16 +78,13 @@ namespace show_cheats {
|
|||
while (std::getline(in, str)) {
|
||||
if (str.size() > 0) {
|
||||
if (std::regex_search(str, cheats_expr)) {
|
||||
cheatsList->addView(new brls::ListItem(str));
|
||||
(*cheatsList)->addView(new brls::ListItem(str));
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res) {
|
||||
(*appView)->addTab(util::upperCase(path.filename().stem()), cheatsList);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
} // namespace show_cheats
|
||||
|
@ -77,8 +96,8 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid, const std::string& name) :
|
|||
GetBuildID();
|
||||
this->setTitle(name);
|
||||
this->setFooterText("v" + std::to_string(this->version / 0x10000));
|
||||
this->registerAction("menus/cheats/show_existing"_i18n, brls::Key::X, [this, tid, name] {
|
||||
show_cheats::ShowCheatFiles(tid, name);
|
||||
this->registerAction("menus/cheats/show_existing"_i18n, brls::Key::X, [this, &name] {
|
||||
show_cheats::ShowCheatSheet(this->tid, this->bid, name);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -172,7 +191,7 @@ DownloadCheatsPage_CheatSlips::DownloadCheatsPage_CheatSlips(uint64_t tid, const
|
|||
//Something else went wrong
|
||||
continue;
|
||||
}
|
||||
listItem->registerAction("menus/cheats/cheatslips_see_more"_i18n, brls::Key::Y, [this, cheat] {
|
||||
listItem->registerAction("menus/cheats/cheatslips_see_more"_i18n, brls::Key::Y, [this, &cheat] {
|
||||
if (cheat.find("titles") != cheat.end()) {
|
||||
ShowCheatsContent(cheat.at("titles"));
|
||||
}
|
||||
|
@ -325,7 +344,7 @@ DownloadCheatsPage_GbaTemp::DownloadCheatsPage_GbaTemp(uint64_t tid, const std::
|
|||
for (const auto& p : cheatsJson[this->bid].items()) {
|
||||
json cheat = p.value();
|
||||
listItem = new ::brls::ListItem(cheat.at("title"));
|
||||
listItem->registerAction("menus/cheats/gbatemp_dl_cheatcode"_i18n, brls::Key::A, [this, cheat] {
|
||||
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) {
|
||||
|
|
|
@ -25,7 +25,7 @@ DownloadPayloadPage::DownloadPayloadPage(const nlohmann::ordered_json& payloads)
|
|||
std::string path = std::string(BOOTLOADER_PL_PATH) + link.first;
|
||||
std::string text("menus/common/download"_i18n + link.first + "menus/common/from"_i18n + url);
|
||||
listItem = new brls::ListItem(link.first);
|
||||
listItem->getClickEvent()->subscribe([&, text, url, path](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([&text, &url, &path](brls::View* view) {
|
||||
fs::createTree(BOOTLOADER_PL_PATH);
|
||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||
stagedFrame->setTitle("menus/tools/getting_payload"_i18n);
|
||||
|
@ -48,7 +48,7 @@ DownloadPayloadPage::DownloadPayloadPage(const nlohmann::ordered_json& payloads)
|
|||
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
|
||||
list->addView(notFound);
|
||||
brls::ListItem* back = new brls::ListItem("menus/common/back"_i18n);
|
||||
back->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
back->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::Application::popView();
|
||||
});
|
||||
list->addView(back);
|
||||
|
|
|
@ -59,7 +59,7 @@ void ListDownloadTab::createList(contentType type)
|
|||
std::string text("menus/common/download"_i18n + link.first + "menus/common/from"_i18n + url);
|
||||
listItem = new brls::ListItem(link.first);
|
||||
listItem->setHeight(LISTITEM_HEIGHT);
|
||||
listItem->getClickEvent()->subscribe([&, text, url, title, type](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([this, &text, &url, &title, &type](brls::View* view) {
|
||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||
stagedFrame->setTitle(fmt::format("menus/main/getting"_i18n, contentTypeNames[(int)type].data()));
|
||||
stagedFrame->addStage(new ConfirmPage(stagedFrame, text));
|
||||
|
@ -157,7 +157,7 @@ void ListDownloadTab::createCheatSlipItem()
|
|||
this->size += 1;
|
||||
cheatslipsItem = new brls::ListItem("menus/cheats/get_cheatslips"_i18n);
|
||||
cheatslipsItem->setHeight(LISTITEM_HEIGHT);
|
||||
cheatslipsItem->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
cheatslipsItem->getClickEvent()->subscribe([](brls::View* view) {
|
||||
if (std::filesystem::exists(TOKEN_PATH)) {
|
||||
brls::Application::pushView(new AppPage_CheatSlips());
|
||||
return true;
|
||||
|
@ -165,8 +165,8 @@ void ListDownloadTab::createCheatSlipItem()
|
|||
else {
|
||||
std::string usr, pwd;
|
||||
//Result rc = swkbdCreate(&kbd, 0);
|
||||
brls::Swkbd::openForText([&](std::string text) { usr = text; }, "cheatslips.com e-mail", "", 64, "", 0, "Submit", "cheatslips.com e-mail");
|
||||
brls::Swkbd::openForText([&](std::string text) { pwd = text; }, "cheatslips.com password", "", 64, "", 0, "Submit", "cheatslips.com password", true);
|
||||
brls::Swkbd::openForText([&usr](std::string text) { usr = text; }, "cheatslips.com e-mail", "", 64, "", 0, "Submit", "cheatslips.com e-mail");
|
||||
brls::Swkbd::openForText([&pwd](std::string text) { pwd = text; }, "cheatslips.com password", "", 64, "", 0, "Submit", "cheatslips.com password", true);
|
||||
std::string body = "{\"email\":\"" + std::string(usr) + "\",\"password\":\"" + std::string(pwd) + "\"}";
|
||||
nlohmann::ordered_json token;
|
||||
download::getRequest(CHEATSLIPS_TOKEN_URL, token,
|
||||
|
@ -201,7 +201,7 @@ void ListDownloadTab::creategbatempItem()
|
|||
this->size += 1;
|
||||
gbatempItem = new brls::ListItem("menus/cheats/get_gbatemp"_i18n);
|
||||
gbatempItem->setHeight(LISTITEM_HEIGHT);
|
||||
gbatempItem->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
gbatempItem->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::Application::pushView(new AppPage_Gbatemp());
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -35,7 +35,7 @@ NetPage::NetPage() : AppletFrame(true, true)
|
|||
label = new brls::Label(brls::LabelStyle::DESCRIPTION, labelText, true);
|
||||
list->addView(label);
|
||||
cancel = new brls::ListItem("menus/common/go_back"_i18n);
|
||||
cancel->getClickEvent()->subscribe([&](brls::View* view) { brls::Application::pushView(new MainFrame()); });
|
||||
cancel->getClickEvent()->subscribe([](brls::View* view) { brls::Application::pushView(new MainFrame()); });
|
||||
list->addView(cancel);
|
||||
}
|
||||
else {
|
||||
|
@ -118,9 +118,9 @@ NetPage::NetPage() : AppletFrame(true, true)
|
|||
listItem = new brls::ListItem(values["name"]);
|
||||
else
|
||||
listItem = new brls::ListItem("Unnamed");
|
||||
listItem->getClickEvent()->subscribe([&, values](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([this, &values](brls::View* view) {
|
||||
brls::Dialog* dialog = new brls::Dialog(values.dump(0).substr(1, values.dump(0).size() - 2));
|
||||
brls::GenericEvent::Callback callbackOk = [&, dialog, values](brls::View* view) {
|
||||
brls::GenericEvent::Callback callbackOk = [this, &dialog, &values](brls::View* view) {
|
||||
nifmInitialize(NifmServiceType_Admin);
|
||||
NifmNetworkProfileData profile;
|
||||
nifmGetCurrentNetworkProfile(&profile);
|
||||
|
|
|
@ -20,12 +20,12 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
|
|||
for (const auto& payload : payloads) {
|
||||
std::string payload_path = payload;
|
||||
listItem = new brls::ListItem(payload_path);
|
||||
listItem->getClickEvent()->subscribe([&, payload](brls::View* view) {
|
||||
listItem->getClickEvent()->subscribe([&payload](brls::View* view) {
|
||||
util::rebootToPayload(payload);
|
||||
brls::Application::popView();
|
||||
});
|
||||
if (CurrentCfw::running_cfw == CFW::ams) {
|
||||
listItem->registerAction("menus/payloads/set_reboot_payload"_i18n, brls::Key::X, [this, payload_path] {
|
||||
listItem->registerAction("menus/payloads/set_reboot_payload"_i18n, brls::Key::X, [&payload_path] {
|
||||
std::string res1;
|
||||
if (fs::copyFile(payload_path, REBOOT_PAYLOAD_PATH)) {
|
||||
res1 += "menus/payloads/copy_success"_i18n + payload_path + "menus/payloads/to"_i18n + std::string(REBOOT_PAYLOAD_PATH) + "'.";
|
||||
|
@ -43,7 +43,7 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
|
|||
return true;
|
||||
});
|
||||
}
|
||||
listItem->registerAction("menus/payloads/set_update_bin"_i18n, brls::Key::Y, [this, payload] {
|
||||
listItem->registerAction("menus/payloads/set_update_bin"_i18n, brls::Key::Y, [&payload] {
|
||||
std::string res2;
|
||||
if (fs::copyFile(payload, UPDATE_BIN_PATH)) {
|
||||
res2 += "menus/payloads/copy_success"_i18n + payload + "menus/payloads/to"_i18n + std::string(UPDATE_BIN_PATH) + "'.";
|
||||
|
|
|
@ -30,7 +30,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
if (!tag.empty() && tag != AppVersion) {
|
||||
updateApp = new brls::ListItem("menus/tools/update_app"_i18n + tag + ")");
|
||||
std::string text("menus/tools/dl_app"_i18n + std::string(APP_URL));
|
||||
updateApp->getClickEvent()->subscribe([&, text, tag](brls::View* view) {
|
||||
updateApp->getClickEvent()->subscribe([&text, &tag](brls::View* view) {
|
||||
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
||||
stagedFrame->setTitle("menus/common/updating"_i18n);
|
||||
stagedFrame->addStage(
|
||||
|
@ -48,19 +48,19 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
}
|
||||
|
||||
cheats = new brls::ListItem("menus/tools/cheats"_i18n);
|
||||
cheats->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
cheats->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::Application::pushView(new CheatsPage());
|
||||
});
|
||||
cheats->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
JCcolor = new brls::ListItem("menus/tools/joy_cons"_i18n);
|
||||
JCcolor->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
JCcolor->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::Application::pushView(new JCPage());
|
||||
});
|
||||
JCcolor->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
PCcolor = new brls::ListItem("menus/tools/pro_cons"_i18n);
|
||||
PCcolor->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
PCcolor->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::Application::pushView(new PCPage());
|
||||
});
|
||||
PCcolor->setHeight(LISTITEM_HEIGHT);
|
||||
|
@ -72,13 +72,13 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
downloadPayload->setHeight(LISTITEM_HEIGHT); */
|
||||
|
||||
rebootPayload = new brls::ListItem("menus/tools/inject_payloads"_i18n);
|
||||
rebootPayload->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
rebootPayload->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::Application::pushView(new PayloadPage());
|
||||
});
|
||||
rebootPayload->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
/* ntcp = new brls::ListItem("menus/ntcp"_i18n);
|
||||
ntcp->getClickEvent()->subscribe([&](brls::View* view){
|
||||
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) {
|
||||
|
@ -93,15 +93,15 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
this->addView(ntcp); */
|
||||
|
||||
netSettings = new brls::ListItem("menus/tools/internet_settings"_i18n);
|
||||
netSettings->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
netSettings->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::PopupFrame::open("menus/tools/internet_settings"_i18n, new NetPage(), "", "");
|
||||
});
|
||||
netSettings->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
browser = new brls::ListItem("menus/tools/browser"_i18n);
|
||||
browser->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
browser->getClickEvent()->subscribe([](brls::View* view) {
|
||||
std::string url;
|
||||
if (brls::Swkbd::openForText([&](std::string text) { url = text; }, "cheatslips.com e-mail", "", 64, "https://duckduckgo.com", 0, "Submit", "https://website.tld")) {
|
||||
if (brls::Swkbd::openForText([&url](std::string text) { url = text; }, "cheatslips.com e-mail", "", 64, "https://duckduckgo.com", 0, "Submit", "https://website.tld")) {
|
||||
std::string error = "";
|
||||
int at = appletGetAppletType();
|
||||
if (at == AppletType_Application) { // Running as a title
|
||||
|
@ -135,7 +135,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
browser->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
move = new brls::ListItem("menus/tools/batch_copy"_i18n);
|
||||
move->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
move->getClickEvent()->subscribe([](brls::View* view) {
|
||||
chdir("/");
|
||||
std::string error = "";
|
||||
if (std::filesystem::exists(COPY_FILES_TXT)) {
|
||||
|
@ -155,7 +155,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
move->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
cleanUp = new brls::ListItem("menus/tools/clean_up"_i18n);
|
||||
cleanUp->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
cleanUp->getClickEvent()->subscribe([](brls::View* view) {
|
||||
std::filesystem::remove(AMS_ZIP_PATH);
|
||||
std::filesystem::remove(APP_ZIP_PATH);
|
||||
std::filesystem::remove(CFW_ZIP_PATH);
|
||||
|
@ -176,7 +176,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
cleanUp->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
language = new brls::ListItem("menus/tools/language"_i18n);
|
||||
language->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
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"),
|
||||
|
@ -194,17 +194,17 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
brls::List* list = new brls::List();
|
||||
brls::ListItem* listItem;
|
||||
listItem = new brls::ListItem(fmt::format("{} ({})", "menus/language/system_default"_i18n, i18n::getCurrentLocale()));
|
||||
listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [this] {
|
||||
listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [] {
|
||||
std::filesystem::remove(LANGUAGE_JSON);
|
||||
brls::Application::quit();
|
||||
return true;
|
||||
});
|
||||
list->addView(listItem);
|
||||
for (auto& l : languages) {
|
||||
listItem = new brls::ListItem(l.first);
|
||||
listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [this, l] {
|
||||
for (auto& language : languages) {
|
||||
listItem = new brls::ListItem(language.first);
|
||||
listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [&language] {
|
||||
json updatedLanguage = json::object();
|
||||
updatedLanguage["language"] = l.second;
|
||||
updatedLanguage["language"] = language.second;
|
||||
std::ofstream out(LANGUAGE_JSON);
|
||||
out << updatedLanguage.dump();
|
||||
brls::Application::quit();
|
||||
|
@ -218,13 +218,13 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload
|
|||
language->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
hideTabs = new brls::ListItem("menus/tools/hide_tabs"_i18n);
|
||||
hideTabs->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
hideTabs->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::PopupFrame::open("menus/tools/hide_tabs"_i18n, new HideTabsPage(), "", "");
|
||||
});
|
||||
hideTabs->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
changelog = new brls::ListItem("menus/tools/changelog"_i18n);
|
||||
changelog->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
changelog->getClickEvent()->subscribe([](brls::View* view) {
|
||||
brls::PopupFrame::open("menus/tools/changelog"_i18n, new ChangelogPage(), "", "");
|
||||
});
|
||||
changelog->setHeight(LISTITEM_HEIGHT);
|
||||
|
|
Loading…
Reference in a new issue