mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2025-03-02 20:25:49 +00:00
Added ability to hide more entries through hideTabs.json https://github.com/HamletDuFromage/aio-switch-updater/issues/53 https://github.com/HamletDuFromage/aio-switch-updater/issues/113
This commit is contained in:
parent
32092f7171
commit
b41cadfa54
12 changed files with 117 additions and 123 deletions
2
Makefile
2
Makefile
|
@ -22,7 +22,7 @@ DATA := data
|
|||
INCLUDES := include lib/zipper/include /lib/borealis/library/include/borealis/extern/nlohmann
|
||||
APP_TITLE := All-in-One Switch Updater
|
||||
APP_AUTHOR := HamletDuFromage
|
||||
APP_VERSION := 2.11.2
|
||||
APP_VERSION := 2.11.3
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
|
||||
ROMFS := resources
|
||||
|
|
|
@ -9,9 +9,9 @@ class AmsTab : public brls::List
|
|||
private:
|
||||
brls::ListItem* listItem;
|
||||
brls::Label *description;
|
||||
int size;
|
||||
int size = 0;
|
||||
bool erista;
|
||||
nlohmann::ordered_json cfws;
|
||||
nlohmann::ordered_json cfws = {};
|
||||
std::string GetRepoName(const std::string& repo);
|
||||
std::set<std::string> GetLastDownloadedModules(const std::string& json_path);
|
||||
void CreateStagedFrames(const std::string& text, const std::string& url, const std::string& operation, bool erista, bool hekate = false, const std::string& text_hekate = "", const std::string& hekate_url = "");
|
||||
|
@ -20,7 +20,8 @@ class AmsTab : public brls::List
|
|||
void ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules);
|
||||
|
||||
public:
|
||||
AmsTab(const bool erista = true);
|
||||
AmsTab(const bool erista = true, const bool hideStandardEntries = false);
|
||||
brls::View* getDefaultFocus() override;
|
||||
};
|
||||
|
||||
class UnTogglableListItem : public brls::ToggleListItem
|
||||
|
|
|
@ -12,7 +12,7 @@ class ListDownloadTab : public brls::List
|
|||
brls::Label *notFound;
|
||||
brls::Label *description;
|
||||
brls::Label *cheatsLabel;
|
||||
int size;
|
||||
int size = 0;
|
||||
void createCheatSlipItem();
|
||||
void creategbatempItem();
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <borealis.hpp>
|
||||
#include <json.hpp>
|
||||
//#include "ntcp.hpp"
|
||||
|
||||
class ToolsTab : public brls::List
|
||||
|
@ -24,6 +25,6 @@ class ToolsTab : public brls::List
|
|||
brls::StagedAppletFrame* stagedFrame;
|
||||
|
||||
public:
|
||||
ToolsTab(const std::string& tag, bool erista = true);
|
||||
ToolsTab(const std::string& tag, bool erista = true, const nlohmann::json& hideStatus = {});
|
||||
|
||||
};
|
|
@ -42,4 +42,5 @@ namespace util {
|
|||
std::string getErrorMessage(long status_code);
|
||||
bool isApplet();
|
||||
std::string getContentsPath();
|
||||
bool getBoolValue(const nlohmann::json& jsonFile, const std::string& key);
|
||||
}
|
|
@ -13,46 +13,45 @@
|
|||
namespace i18n = brls::i18n;
|
||||
using namespace i18n::literals;
|
||||
|
||||
AmsTab::AmsTab(const bool erista) : brls::List()
|
||||
AmsTab::AmsTab(const bool erista, const bool hideStandardEntries) : brls::List()
|
||||
{
|
||||
this->erista = erista;
|
||||
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "menus/main/ams_text"_i18n + (CurrentCfw::running_cfw == CFW::ams ? "\n" + "menus/ams_update/current_ams"_i18n + CurrentCfw::getAmsInfo() : "") + (erista ? "\n" + "menus/ams_update/erista_rev"_i18n : "\n" + "menus/ams_update/mariko_rev"_i18n), true);
|
||||
this->addView(description);
|
||||
|
||||
download::getRequest(AMS_URL, cfws);
|
||||
|
||||
CreateDownloadItems(cfws.find("Atmosphere") != cfws.end() ? cfws["Atmosphere"] : nlohmann::ordered_json::object());
|
||||
if(!hideStandardEntries) {
|
||||
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "menus/main/ams_text"_i18n + (CurrentCfw::running_cfw == CFW::ams ? "\n" + "menus/ams_update/current_ams"_i18n + CurrentCfw::getAmsInfo() : "") + (erista ? "\n" + "menus/ams_update/erista_rev"_i18n : "\n" + "menus/ams_update/mariko_rev"_i18n), true);
|
||||
this->addView(description);
|
||||
CreateDownloadItems(cfws.find("Atmosphere") != cfws.end() ? cfws.at("Atmosphere") : nlohmann::ordered_json::object());
|
||||
|
||||
description = new brls::Label(
|
||||
brls::LabelStyle::DESCRIPTION,
|
||||
"menus/ams_update/deepsea_label"_i18n,
|
||||
true
|
||||
);
|
||||
this->addView(description);
|
||||
description = new brls::Label(
|
||||
brls::LabelStyle::DESCRIPTION,
|
||||
"menus/ams_update/deepsea_label"_i18n,
|
||||
true
|
||||
);
|
||||
this->addView(description);
|
||||
|
||||
listItem = new brls::ListItem("menus/ams_update/get_custom_deepsea"_i18n);
|
||||
listItem->setHeight(LISTITEM_HEIGHT);
|
||||
listItem->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
nlohmann::ordered_json modules;
|
||||
download::getRequest(DEEPSEA_META_JSON, modules);
|
||||
ShowCustomDeepseaBuilder(modules);
|
||||
});
|
||||
this->addView(listItem);
|
||||
listItem = new brls::ListItem("menus/ams_update/get_custom_deepsea"_i18n);
|
||||
listItem->setHeight(LISTITEM_HEIGHT);
|
||||
listItem->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
nlohmann::ordered_json modules;
|
||||
download::getRequest(DEEPSEA_META_JSON, modules);
|
||||
ShowCustomDeepseaBuilder(modules);
|
||||
});
|
||||
this->addView(listItem);
|
||||
|
||||
CreateDownloadItems(cfws.find("DeepSea") != cfws.end() ? cfws["DeepSea"] : nlohmann::ordered_json::object());
|
||||
CreateDownloadItems(cfws.find("DeepSea") != cfws.end() ? cfws.at("DeepSea") : nlohmann::ordered_json::object());
|
||||
}
|
||||
|
||||
if(cfws.size()) {
|
||||
auto custom_pack = fs::parseJsonFile(CUSTOM_PACKS_PATH);
|
||||
if (custom_pack.size() != 0) {
|
||||
description = new brls::Label(
|
||||
brls::LabelStyle::DESCRIPTION,
|
||||
fmt::format("menus/ams_update/custom_packs_label"_i18n, CUSTOM_PACKS_PATH),
|
||||
true
|
||||
);
|
||||
this->addView(description);
|
||||
auto custom_pack = fs::parseJsonFile(CUSTOM_PACKS_PATH);
|
||||
if (custom_pack.size() != 0) {
|
||||
description = new brls::Label(
|
||||
brls::LabelStyle::DESCRIPTION,
|
||||
fmt::format("menus/ams_update/custom_packs_label"_i18n, CUSTOM_PACKS_PATH),
|
||||
true
|
||||
);
|
||||
this->addView(description);
|
||||
|
||||
CreateDownloadItems(custom_pack, true);
|
||||
}
|
||||
CreateDownloadItems(cfws.size() ? custom_pack : nlohmann::ordered_json::object(), true); // TODO: better way to check for availability of the links
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +60,7 @@ void AmsTab::CreateDownloadItems(const nlohmann::ordered_json& cfw_links, bool h
|
|||
std::string operation("menus/ams_update/getting_ams"_i18n);
|
||||
std::vector<std::pair<std::string, std::string>> links;
|
||||
links = download::getLinksFromJson(cfw_links);
|
||||
this->size = links.size();
|
||||
if(this->size){
|
||||
if(links.size()){
|
||||
auto hekate_link = download::getLinks(HEKATE_URL);
|
||||
std::string hekate_url = hekate_link[0].second;
|
||||
std::string text_hekate = "menus/common/download"_i18n + hekate_link[0].first;
|
||||
|
@ -82,6 +80,7 @@ void AmsTab::CreateDownloadItems(const nlohmann::ordered_json& cfw_links, bool h
|
|||
});
|
||||
this->addView(listItem);
|
||||
}
|
||||
this->size += 1;
|
||||
}
|
||||
else{
|
||||
description = new brls::Label(
|
||||
|
@ -134,7 +133,7 @@ std::set<std::string> AmsTab::GetLastDownloadedModules(const std::string& json_p
|
|||
nlohmann::json package = fs::parseJsonFile(json_path);
|
||||
std::set<std::string> res;
|
||||
if(package.find("modules") != package.end()) {
|
||||
for (const auto& module : package["modules"]) {
|
||||
for (const auto& module : package.at("modules")) {
|
||||
res.insert(module.get<std::string>());
|
||||
}
|
||||
}
|
||||
|
@ -145,8 +144,8 @@ nlohmann::ordered_json AmsTab::SortDeepseaModules(const nlohmann::ordered_json&
|
|||
{
|
||||
nlohmann::ordered_json sorted_modules = nlohmann::ordered_json::object();
|
||||
if(modules.find("modules") != modules.end()) {
|
||||
for (const auto& module : modules["modules"].items()) {
|
||||
sorted_modules[std::string(module.value()["category"])][module.key()] = module.value();
|
||||
for (const auto& module : modules.at("modules").items()) {
|
||||
sorted_modules[std::string(module.value().at("category"))][module.key()] = module.value();
|
||||
}
|
||||
}
|
||||
return sorted_modules;
|
||||
|
@ -170,28 +169,28 @@ void AmsTab::ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules)
|
|||
for (const auto& module : category.value().items()) {
|
||||
auto module_value = module.value();
|
||||
std::string requirements = "";
|
||||
if(!module_value["requires"].empty()) {
|
||||
if(!module_value.at("requires").empty()) {
|
||||
requirements = "menus/ams_update/depends_on"_i18n;
|
||||
for (const auto& r : module.value()["requires"]) {
|
||||
for (const auto& r : module.value().at("requires")) {
|
||||
requirements += " " + r.get<std::string>() + ",";
|
||||
}
|
||||
requirements.pop_back();
|
||||
}
|
||||
if(module_value["required"]) {
|
||||
deepseaListItem = new UnTogglableListItem(module_value["displayName"], 1, requirements, "Required", "o");
|
||||
if(module_value.at("required")) {
|
||||
deepseaListItem = new UnTogglableListItem(module_value.at("displayName"), 1, requirements, "Required", "o");
|
||||
}
|
||||
else {
|
||||
deepseaListItem = new::brls::ToggleListItem(module_value["displayName"],
|
||||
deepseaListItem = new::brls::ToggleListItem(module_value.at("displayName"),
|
||||
old_modules.find(module.key()) != old_modules.end() ? 1 : 0,
|
||||
requirements,
|
||||
"menus/common/selected"_i18n,
|
||||
"menus/common/off"_i18n
|
||||
);
|
||||
}
|
||||
name_map.insert(std::pair(module_value["displayName"], module.key()));
|
||||
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] {
|
||||
brls::Dialog* dialog;
|
||||
dialog = new brls::Dialog(fmt::format("{}:\n{}", module_value["repo"], module_value["description"]));
|
||||
dialog = new brls::Dialog(fmt::format("{}:\n{}", module_value.at("repo"), module_value.at("description")));
|
||||
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
|
||||
dialog->close();
|
||||
};
|
||||
|
@ -234,6 +233,14 @@ void AmsTab::ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules)
|
|||
brls::PopupFrame::open("menus/ams_update/deepsea_builder"_i18n, appView, modules.empty() ? "menus/ams_update/cant_fetch_deepsea"_i18n : "menus/ams_update/build_your_deepsea"_i18n, "");
|
||||
}
|
||||
|
||||
brls::View* AmsTab::getDefaultFocus()
|
||||
{
|
||||
if(this->size)
|
||||
return this->brls::List::getDefaultFocus();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UnTogglableListItem::onClick()
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -187,6 +187,9 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
|
|||
verTitles.push_back("v2.11.2");
|
||||
changes.push_back("\uE016 Fixed crash when downloading cheats in applet mode.\n\uE016 Fixed progress bar percentage not showing past 10%.");
|
||||
|
||||
verTitles.push_back("v2.11.3");
|
||||
changes.push_back("\uE016 Don't download the cheat archive when already cached.\n\uE016 Added ability to hide more entries through hideTabs.json.\n\uE016 Better support for non-UTF-8 characters.");
|
||||
|
||||
for(int i = verTitles.size() -1 ; i >= 0; i--){
|
||||
listItem = new brls::ListItem(verTitles[i]);
|
||||
change = changes[i];
|
||||
|
|
|
@ -160,7 +160,7 @@ DownloadCheatsPage_CheatSlips::DownloadCheatsPage_CheatSlips(uint64_t tid, const
|
|||
nlohmann::ordered_json cheatsInfo;
|
||||
download::getRequest(CHEATSLIPS_CHEATS_URL + util::formatApplicationId(this->tid) + "/" + this->bid, cheatsInfo, headers);
|
||||
if(cheatsInfo.find("cheats") != cheatsInfo.end()) {
|
||||
for (const auto& p : cheatsInfo["cheats"].items()) {
|
||||
for (const auto& p : cheatsInfo.at("cheats").items()) {
|
||||
json cheat = p.value();
|
||||
try {
|
||||
listItem = new::brls::ToggleListItem(GetCheatsTitle(cheat), 0, "", "\uE016", "o");
|
||||
|
@ -173,11 +173,11 @@ DownloadCheatsPage_CheatSlips::DownloadCheatsPage_CheatSlips(uint64_t tid, const
|
|||
}
|
||||
listItem->registerAction("menus/cheats/cheatslips_see_more"_i18n, brls::Key::Y, [this, cheat] {
|
||||
if(cheat.find("titles") != cheat.end()) {
|
||||
ShowCheatsContent(cheat["titles"]);
|
||||
ShowCheatsContent(cheat.at("titles"));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
toggles.push_back(std::make_pair(listItem, cheat["id"]));
|
||||
toggles.push_back(std::make_pair(listItem, cheat.at("id")));
|
||||
list->addView(listItem);
|
||||
}
|
||||
if(list->getViewsCount() > 1)
|
||||
|
@ -209,18 +209,18 @@ DownloadCheatsPage_CheatSlips::DownloadCheatsPage_CheatSlips(uint64_t tid, const
|
|||
tokenFile.close();
|
||||
std::vector<std::string> headers = {"accept: application/json"};
|
||||
if(token.find("token") != token.end()) {
|
||||
headers.push_back("X-API-TOKEN: " + token["token"].get<std::string>());
|
||||
headers.push_back("X-API-TOKEN: " + token.at("token").get<std::string>());
|
||||
}
|
||||
nlohmann::ordered_json cheatsInfo;
|
||||
download::getRequest("https://www.cheatslips.com/api/v1/cheats/" + util::formatApplicationId(this->tid) + "/" + this->bid, cheatsInfo, headers);
|
||||
if(cheatsInfo.find("cheats") != cheatsInfo.end()) {
|
||||
for (const auto& p : cheatsInfo["cheats"].items()) {
|
||||
if(std::find(ids.begin(), ids.end(), p.value()["id"]) != ids.end()) {
|
||||
if(p.value()["content"].get<std::string>() == "Quota exceeded for today !"){
|
||||
for (const auto& p : cheatsInfo.at("cheats").items()) {
|
||||
if(std::find(ids.begin(), ids.end(), p.value().at("id")) != ids.end()) {
|
||||
if(p.value().at("content").get<std::string>() == "Quota exceeded for today !"){
|
||||
error = 1;
|
||||
}
|
||||
else {
|
||||
WriteCheats(p.value()["content"]);
|
||||
WriteCheats(p.value().at("content"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -286,8 +286,8 @@ DownloadCheatsPage_CheatSlips::DownloadCheatsPage_CheatSlips(uint64_t tid, const
|
|||
std::string DownloadCheatsPage_CheatSlips::GetCheatsTitle(json cheat) {
|
||||
std::string res = "";
|
||||
if(cheat.find("titles") != cheat.end()) {
|
||||
for(auto& p : cheat["titles"]){
|
||||
res += "[" + p.get<std::string>() + "]" + " - ";
|
||||
for(auto& p : cheat.at("titles")){
|
||||
res += ".at(" + p.get<std::string>() + ")" + " - ";
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
@ -323,10 +323,10 @@ DownloadCheatsPage_GbaTemp::DownloadCheatsPage_GbaTemp(uint64_t tid, const std::
|
|||
if(cheatsJson.find(this->bid) != cheatsJson.end()) {
|
||||
for (const auto& p : cheatsJson[this->bid].items()) {
|
||||
json cheat = p.value();
|
||||
listItem = new::brls::ListItem(cheat["title"]);
|
||||
listItem = new::brls::ListItem(cheat.at("title"));
|
||||
listItem->registerAction("menus/cheats/gbatemp_dl_cheatcode"_i18n, brls::Key::A, [this, cheat] {
|
||||
WriteCheats(cheat["content"]);
|
||||
brls::Dialog* dialog = new brls::Dialog(fmt::format("menus/cheats/gbatemp_dl_successful_dl"_i18n, cheat["title"]));
|
||||
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) {
|
||||
dialog->close();
|
||||
};
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include <fstream>
|
||||
#include "constants.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
|
||||
namespace i18n = brls::i18n;
|
||||
using namespace i18n::literals;
|
||||
using json = nlohmann::json;
|
||||
|
@ -21,46 +21,22 @@ HideTabsPage::HideTabsPage() : AppletFrame(true, true) {
|
|||
|
||||
json hideStatus = fs::parseJsonFile(HIDE_TABS_JSON);
|
||||
|
||||
bool status = false;
|
||||
if(hideStatus.find("about") != hideStatus.end()) {
|
||||
status = hideStatus["about"];
|
||||
}
|
||||
about = new brls::ToggleListItem("menus/main/about"_i18n, status);
|
||||
about = new brls::ToggleListItem("menus/main/about"_i18n, util::getBoolValue(hideStatus, "about"));
|
||||
list->addView(about);
|
||||
|
||||
status = false;
|
||||
if(hideStatus.find("atmosphere") != hideStatus.end()) {
|
||||
status = hideStatus["atmosphere"];
|
||||
}
|
||||
ams = new brls::ToggleListItem("menus/main/update_ams"_i18n, status);
|
||||
ams = new brls::ToggleListItem("menus/main/update_ams"_i18n, util::getBoolValue(hideStatus, "atmosphere"));
|
||||
list->addView(ams);
|
||||
|
||||
status = false;
|
||||
if(hideStatus.find("cfw") != hideStatus.end()) {
|
||||
status = hideStatus["cfw"];
|
||||
}
|
||||
cfws = new brls::ToggleListItem("menus/main/update_bootloaders"_i18n, status);
|
||||
cfws = new brls::ToggleListItem("menus/main/update_bootloaders"_i18n, util::getBoolValue(hideStatus, "cfw"));
|
||||
list->addView(cfws);
|
||||
|
||||
status = false;
|
||||
if(hideStatus.find("sigpatches") != hideStatus.end()) {
|
||||
status = hideStatus["sigpatches"];
|
||||
}
|
||||
sigpatches = new brls::ToggleListItem("menus/main/update_sigpatches"_i18n, status);
|
||||
sigpatches = new brls::ToggleListItem("menus/main/update_sigpatches"_i18n, util::getBoolValue(hideStatus, "sigpatches"));
|
||||
list->addView(sigpatches);
|
||||
|
||||
status = false;
|
||||
if(hideStatus.find("firmwares") != hideStatus.end()) {
|
||||
status = hideStatus["firmwares"];
|
||||
}
|
||||
fws = new brls::ToggleListItem("menus/main/download_firmware"_i18n, status);
|
||||
fws = new brls::ToggleListItem("menus/main/download_firmware"_i18n, util::getBoolValue(hideStatus, "firmwares"));
|
||||
list->addView(fws);
|
||||
|
||||
status = false;
|
||||
if(hideStatus.find("cheats") != hideStatus.end()) {
|
||||
status = hideStatus["cheats"];
|
||||
}
|
||||
cheats = new brls::ToggleListItem("menus/main/download_cheats"_i18n, status);
|
||||
cheats = new brls::ToggleListItem("menus/main/download_cheats"_i18n, util::getBoolValue(hideStatus, "cheats"));
|
||||
list->addView(cheats);
|
||||
|
||||
list->registerAction("menus/cheats/exclude_titles_save"_i18n, brls::Key::B, [this] {
|
||||
|
|
|
@ -33,26 +33,26 @@ MainFrame::MainFrame() : TabFrame()
|
|||
|
||||
bool erista = util::isErista();
|
||||
|
||||
if(hideStatus.find("about") == hideStatus.end() || !hideStatus["about"])
|
||||
if(!util::getBoolValue(hideStatus, "about"))
|
||||
this->addTab("menus/main/about"_i18n, new AboutTab());
|
||||
|
||||
if(hideStatus.find("atmosphere") == hideStatus.end() || !hideStatus["atmosphere"])
|
||||
this->addTab("menus/main/update_ams"_i18n, new AmsTab(erista));
|
||||
|
||||
if(hideStatus.find("cfw") == hideStatus.end() || !hideStatus["cfw"])
|
||||
if(!util::getBoolValue(hideStatus, "atmosphere"))
|
||||
this->addTab("menus/main/update_ams"_i18n, new AmsTab(erista, util::getBoolValue(hideStatus, "atmosphereentries")));
|
||||
|
||||
if(!util::getBoolValue(hideStatus, "cfw"))
|
||||
this->addTab("menus/main/update_bootloaders"_i18n, new ListDownloadTab(archiveType::cfw));
|
||||
|
||||
if(hideStatus.find("sigpatches") == hideStatus.end() || !hideStatus["sigpatches"])
|
||||
if(!util::getBoolValue(hideStatus, "sigpatches"))
|
||||
this->addTab("menus/main/update_sigpatches"_i18n, new ListDownloadTab(archiveType::sigpatches));
|
||||
|
||||
if(hideStatus.find("firmwares") == hideStatus.end() || !hideStatus["firmwares"])
|
||||
if(!util::getBoolValue(hideStatus, "firmwares"))
|
||||
this->addTab("menus/main/download_firmware"_i18n, new ListDownloadTab(archiveType::fw));
|
||||
|
||||
if(hideStatus.find("cheats") == hideStatus.end() || !hideStatus["cheats"])
|
||||
if(!util::getBoolValue(hideStatus, "cheats"))
|
||||
this->addTab("menus/main/download_cheats"_i18n, new ListDownloadTab(archiveType::cheats));
|
||||
|
||||
if(hideStatus.find("tools") == hideStatus.end() || !hideStatus["tools"])
|
||||
this->addTab("menus/main/tools"_i18n, new ToolsTab(tag, erista));
|
||||
if(!util::getBoolValue(hideStatus, "tools"))
|
||||
this->addTab("menus/main/tools"_i18n, new ToolsTab(tag, erista, hideStatus));
|
||||
|
||||
this->registerAction("" , brls::Key::B, [this] { return true; });
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "utils.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "hide_tabs_page.hpp"
|
||||
#include <json.hpp>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
|
@ -24,7 +23,7 @@ namespace {
|
|||
constexpr const char AppVersion[] = APP_VERSION;
|
||||
}
|
||||
|
||||
ToolsTab::ToolsTab(const std::string& tag, bool erista) : brls::List()
|
||||
ToolsTab::ToolsTab(const std::string& tag, bool erista, const nlohmann::json& hideStatus) : brls::List()
|
||||
{
|
||||
if(!tag.empty() && tag != AppVersion){
|
||||
updateApp = new brls::ListItem("menus/tools/update_app"_i18n + tag +")");
|
||||
|
@ -55,37 +54,31 @@ ToolsTab::ToolsTab(const std::string& tag, bool erista) : brls::List()
|
|||
brls::Application::pushView(new CheatsPage());
|
||||
});
|
||||
cheats->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(cheats);
|
||||
|
||||
JCcolor = new brls::ListItem("menus/tools/joy_cons"_i18n);
|
||||
JCcolor->getClickEvent()->subscribe([&](brls::View* view){
|
||||
brls::Application::pushView(new JCPage());
|
||||
});
|
||||
JCcolor->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(JCcolor);
|
||||
|
||||
PCcolor = new brls::ListItem("menus/tools/pro_cons"_i18n);
|
||||
PCcolor->getClickEvent()->subscribe([&](brls::View* view){
|
||||
brls::Application::pushView(new PCPage());
|
||||
});
|
||||
PCcolor->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(PCcolor);
|
||||
|
||||
downloadPayload = new brls::ListItem("menus/tools/dl_payloads"_i18n + std::string(BOOTLOADER_PL_PATH));
|
||||
downloadPayload->getClickEvent()->subscribe([&](brls::View* view){
|
||||
brls::Application::pushView(new DownloadPayloadPage());
|
||||
});
|
||||
downloadPayload->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(downloadPayload);
|
||||
|
||||
if(erista) {
|
||||
rebootPayload = new brls::ListItem("menus/tools/inject_payloads"_i18n);
|
||||
rebootPayload->getClickEvent()->subscribe([&](brls::View* view){
|
||||
brls::Application::pushView(new PayloadPage());
|
||||
});
|
||||
rebootPayload->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(rebootPayload);
|
||||
}
|
||||
rebootPayload = new brls::ListItem("menus/tools/inject_payloads"_i18n);
|
||||
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){
|
||||
|
@ -107,7 +100,6 @@ ToolsTab::ToolsTab(const std::string& tag, bool erista) : brls::List()
|
|||
brls::PopupFrame::open("menus/tools/internet_settings"_i18n, new NetPage(), "", "");
|
||||
});
|
||||
netSettings->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(netSettings);
|
||||
|
||||
browser = new brls::ListItem("menus/tools/browser"_i18n);
|
||||
browser->getClickEvent()->subscribe([&](brls::View* view){
|
||||
|
@ -144,7 +136,6 @@ ToolsTab::ToolsTab(const std::string& tag, bool erista) : brls::List()
|
|||
|
||||
});
|
||||
browser->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(browser);
|
||||
|
||||
move = new brls::ListItem("menus/tools/batch_copy"_i18n);
|
||||
move->getClickEvent()->subscribe([&](brls::View* view){
|
||||
|
@ -165,7 +156,6 @@ ToolsTab::ToolsTab(const std::string& tag, bool erista) : brls::List()
|
|||
dialog->open();
|
||||
});
|
||||
move->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(move);
|
||||
|
||||
cleanUp = new brls::ListItem("menus/tools/clean_up"_i18n);
|
||||
cleanUp->getClickEvent()->subscribe([&](brls::View* view){
|
||||
|
@ -187,7 +177,6 @@ ToolsTab::ToolsTab(const std::string& tag, bool erista) : brls::List()
|
|||
dialog->open();
|
||||
});
|
||||
cleanUp->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(cleanUp);
|
||||
|
||||
language = new brls::ListItem("menus/tools/language"_i18n);
|
||||
language->getClickEvent()->subscribe([&](brls::View* view){
|
||||
|
@ -231,20 +220,30 @@ ToolsTab::ToolsTab(const std::string& tag, bool erista) : brls::List()
|
|||
brls::PopupFrame::open("menus/tools/language"_i18n, appView, "", "");
|
||||
});
|
||||
language->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(language);
|
||||
|
||||
hideTabs = new brls::ListItem("menus/tools/hide_tabs"_i18n);
|
||||
hideTabs->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
brls::PopupFrame::open("menus/tools/hide_tabs"_i18n, new HideTabsPage(), "", "");
|
||||
});
|
||||
hideTabs->setHeight(LISTITEM_HEIGHT);
|
||||
this->addView(hideTabs);
|
||||
|
||||
changelog = new brls::ListItem("menus/tools/changelog"_i18n);
|
||||
changelog->getClickEvent()->subscribe([&](brls::View* view){
|
||||
brls::PopupFrame::open("menus/tools/changelog"_i18n, new ChangelogPage(), "", "");
|
||||
});
|
||||
changelog->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
if(!util::getBoolValue(hideStatus, "cheats")) this->addView(cheats);
|
||||
if(!util::getBoolValue(hideStatus, "jccolor")) this->addView(JCcolor);
|
||||
if(!util::getBoolValue(hideStatus, "pccolor")) this->addView(PCcolor);
|
||||
if(!util::getBoolValue(hideStatus, "downloadpayload")) this->addView(downloadPayload);
|
||||
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);
|
||||
if(!util::getBoolValue(hideStatus, "hidetabs")) this->addView(hideTabs);
|
||||
this->addView(changelog);
|
||||
}
|
||||
|
||||
|
|
|
@ -330,4 +330,10 @@ std::string getContentsPath() {
|
|||
return path;
|
||||
}
|
||||
|
||||
bool getBoolValue(const nlohmann::json& jsonFile, const std::string& key) {
|
||||
/* try { return jsonFile.at(key); }
|
||||
catch (nlohmann::json::out_of_range& e) { return false; } */
|
||||
return (jsonFile.find(key) != jsonFile.end()) ? jsonFile.at(key).get<bool>() : false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue