From 29547e2993728c04ede7caaaa4392d599d7905c4 Mon Sep 17 00:00:00 2001 From: flb Date: Sun, 3 Oct 2021 19:54:09 +0200 Subject: [PATCH] revert breaking changes --- include/confirm_page.hpp | 2 +- source/JC_page.cpp | 2 +- source/PC_page.cpp | 2 +- source/ams_tab.cpp | 10 +++++----- source/app_page.cpp | 8 ++++---- source/changelog_page.cpp | 4 ++-- source/cheats_page.cpp | 2 +- source/confirm_page.cpp | 2 +- source/download_cheats_page.cpp | 6 +++--- source/download_payload_page.cpp | 2 +- source/list_download_tab.cpp | 8 ++++---- source/net_page.cpp | 4 ++-- source/payload_page.cpp | 30 +++++++++++------------------- source/tools_tab.cpp | 4 ++-- 14 files changed, 39 insertions(+), 47 deletions(-) diff --git a/include/confirm_page.hpp b/include/confirm_page.hpp index 3cf218b..cdd55cf 100644 --- a/include/confirm_page.hpp +++ b/include/confirm_page.hpp @@ -14,7 +14,7 @@ private: bool erista = true; public: - ConfirmPage(brls::StagedAppletFrame* frame, std::string text, bool done = false, bool reboot = false, bool erista = true); + ConfirmPage(brls::StagedAppletFrame* frame, const std::string& text, bool done = false, bool reboot = false, bool erista = true); ~ConfirmPage(); void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; diff --git a/source/JC_page.cpp b/source/JC_page.cpp index e64bbb7..cfde231 100644 --- a/source/JC_page.cpp +++ b/source/JC_page.cpp @@ -35,7 +35,7 @@ JCPage::JCPage() : AppletFrame(true, true) for (int i = profiles.size() - 1; i >= 0; i--) { std::vector 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( diff --git a/source/PC_page.cpp b/source/PC_page.cpp index c482bd1..96ae20c 100644 --- a/source/PC_page.cpp +++ b/source/PC_page.cpp @@ -34,7 +34,7 @@ PCPage::PCPage() : AppletFrame(true, true) for (int i = profiles.size() - 1; i >= 0; i--) { std::vector 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( diff --git a/source/ams_tab.cpp b/source/ams_tab.cpp index e504829..c2f124e 100644 --- a/source/ams_tab.cpp +++ b/source/ams_tab.cpp @@ -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, [&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 desired_modules; for (const auto& list : lists) { for (size_t i = 0; i < list->getViewsCount(); i++) { @@ -213,10 +213,10 @@ void AmsTab::ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules) for (const auto& e : desired_modules) request_url += e + ";"; - CreateStagedFrames("menus/common/download"_i18n + "Custom DeepSea package" + "menus/common/from"_i18n + request_url, + this->CreateStagedFrames("menus/common/download"_i18n + "Custom DeepSea package" + "menus/common/from"_i18n + request_url, request_url, "menus/ams_update/get_custom_deepsea"_i18n, - erista); + this->erista); return true; }); appView->registerAction("", brls::Key::PLUS, [this] { return true; }); diff --git a/source/app_page.cpp b/source/app_page.cpp index e33a3b7..11a3749 100644 --- a/source/app_page.cpp +++ b/source/app_page.cpp @@ -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,7 +277,7 @@ 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([tid, &name](brls::View* view) { show_cheats::ShowCheatFiles(tid, name); }); + 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) { diff --git a/source/changelog_page.cpp b/source/changelog_page.cpp index 028d776..59be911 100644 --- a/source/changelog_page.cpp +++ b/source/changelog_page.cpp @@ -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([&version, &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, "", ""); diff --git a/source/cheats_page.cpp b/source/cheats_page.cpp index 8447cf8..96142d7 100644 --- a/source/cheats_page.cpp +++ b/source/cheats_page.cpp @@ -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: diff --git a/source/confirm_page.cpp b/source/confirm_page.cpp index e304dde..2c941be 100644 --- a/source/confirm_page.cpp +++ b/source/confirm_page.cpp @@ -10,7 +10,7 @@ namespace i18n = brls::i18n; using namespace i18n::literals; -ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, std::string text, bool done, bool reboot, bool erista) : done(done), reboot(reboot), erista(erista) +ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, const std::string& text, bool done, bool reboot, bool erista) : done(done), reboot(reboot), erista(erista) { this->button = (new brls::Button(brls::ButtonStyle::REGULAR))->setLabel(done ? "menus/common/back"_i18n : "menus/common/continue"_i18n); this->button->setParent(this); diff --git a/source/download_cheats_page.cpp b/source/download_cheats_page.cpp index 68c1a36..ca5f807 100644 --- a/source/download_cheats_page.cpp +++ b/source/download_cheats_page.cpp @@ -96,7 +96,7 @@ 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, &name] { + this->registerAction("menus/cheats/show_existing"_i18n, brls::Key::X, [this, name] { show_cheats::ShowCheatSheet(this->tid, this->bid, name); return true; }); @@ -191,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")); } @@ -344,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) { diff --git a/source/download_payload_page.cpp b/source/download_payload_page.cpp index a35abac..4befc71 100644 --- a/source/download_payload_page.cpp +++ b/source/download_payload_page.cpp @@ -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); diff --git a/source/list_download_tab.cpp b/source/list_download_tab.cpp index e526244..33a62b6 100644 --- a/source/list_download_tab.cpp +++ b/source/list_download_tab.cpp @@ -54,12 +54,12 @@ void ListDownloadTab::createList(contentType type) this->size = links.size(); if (this->size) { for (const auto& link : links) { - std::string title = link.first; - std::string url = link.second; - std::string text("menus/common/download"_i18n + link.first + "menus/common/from"_i18n + url); + const std::string title = link.first; + const std::string url = link.second; + const 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, &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)); diff --git a/source/net_page.cpp b/source/net_page.cpp index 0a5c697..e65afae 100644 --- a/source/net_page.cpp +++ b/source/net_page.cpp @@ -118,9 +118,9 @@ NetPage::NetPage() : AppletFrame(true, true) listItem = new brls::ListItem(values["name"]); else listItem = new brls::ListItem("Unnamed"); - listItem->getClickEvent()->subscribe([this, &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 = [this, &dialog, &values](brls::View* view) { + brls::GenericEvent::Callback callbackOk = [this, dialog, values](brls::View* view) { nifmInitialize(NifmServiceType_Admin); NifmNetworkProfileData profile; nifmGetCurrentNetworkProfile(&profile); diff --git a/source/payload_page.cpp b/source/payload_page.cpp index 4c941ad..d1a4e47 100644 --- a/source/payload_page.cpp +++ b/source/payload_page.cpp @@ -20,20 +20,16 @@ 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, [&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) + "'."; - } - else { - res1 += "Failed."; - } - brls::Dialog* dialog = new brls::Dialog(res1); + listItem->registerAction("menus/payloads/set_reboot_payload"_i18n, brls::Key::X, [payload_path] { + std::string res = fs::copyFile(payload_path, REBOOT_PAYLOAD_PATH) + ? "menus/payloads/copy_success"_i18n + payload_path + "menus/payloads/to"_i18n + std::string(REBOOT_PAYLOAD_PATH) + "'." + : "Failed."; + brls::Dialog* dialog = new brls::Dialog(res); brls::GenericEvent::Callback callback = [dialog](brls::View* view) { dialog->close(); }; @@ -43,15 +39,11 @@ PayloadPage::PayloadPage() : AppletFrame(true, true) return true; }); } - 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) + "'."; - } - else { - res2 += "Failed."; - } - brls::Dialog* dialog = new brls::Dialog(res2); + listItem->registerAction("menus/payloads/set_update_bin"_i18n, brls::Key::Y, [payload] { + std::string res = fs::copyFile(payload, UPDATE_BIN_PATH) + ? "menus/payloads/copy_success"_i18n + payload + "menus/payloads/to"_i18n + std::string(UPDATE_BIN_PATH) + "'." + : "Failed."; + brls::Dialog* dialog = new brls::Dialog(res); brls::GenericEvent::Callback callback = [dialog](brls::View* view) { dialog->close(); }; diff --git a/source/tools_tab.cpp b/source/tools_tab.cpp index 54c037d..57c393a 100644 --- a/source/tools_tab.cpp +++ b/source/tools_tab.cpp @@ -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( @@ -202,7 +202,7 @@ ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payload list->addView(listItem); for (auto& language : languages) { listItem = new brls::ListItem(language.first); - listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [&language] { + listItem->registerAction("menus/tools/language"_i18n, brls::Key::A, [language] { json updatedLanguage = json::object(); updatedLanguage["language"] = language.second; std::ofstream out(LANGUAGE_JSON);