From 0fd52987b7a9eff104dc5386e4d33bd638b9b3da Mon Sep 17 00:00:00 2001 From: flb Date: Fri, 9 Jul 2021 01:14:07 +0200 Subject: [PATCH] added support for support packs --- Makefile | 2 +- customPacks.json | 4 ++++ include/ams_tab.hpp | 2 +- include/constants.hpp | 2 ++ resources/i18n/en-US/menus.json | 3 ++- source/ams_tab.cpp | 20 ++++++++++++++++---- source/changelog_page.cpp | 3 +++ 7 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 customPacks.json diff --git a/Makefile b/Makefile index 7a45181..8bc8474 100644 --- a/Makefile +++ b/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.9.0 +APP_VERSION := 2.10.0 TARGET := $(notdir $(CURDIR)) ROMFS := resources diff --git a/customPacks.json b/customPacks.json new file mode 100644 index 0000000..a138a50 --- /dev/null +++ b/customPacks.json @@ -0,0 +1,4 @@ +{ + "Name of pack": "link_to_zip", + "Name of anther pack": "link_to_zip" +} \ No newline at end of file diff --git a/include/ams_tab.hpp b/include/ams_tab.hpp index c810189..a3c305a 100644 --- a/include/ams_tab.hpp +++ b/include/ams_tab.hpp @@ -15,7 +15,7 @@ class AmsTab : public brls::List std::string GetRepoName(const std::string& repo); std::set 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 = ""); - void CreateDownloadItems(const std::string& key, bool hekate = true); + void CreateDownloadItems(const nlohmann::ordered_json& cfw_links, bool hekate = true); nlohmann::ordered_json SortDeepseaModules(const nlohmann::ordered_json& modules); void ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules); diff --git a/include/constants.hpp b/include/constants.hpp index c702402..41f90aa 100644 --- a/include/constants.hpp +++ b/include/constants.hpp @@ -38,6 +38,8 @@ constexpr const char DEEPSEA_META_JSON[] = "https://builder.teamneptune.net/met constexpr const char DEEPSEA_BUILD_URL[] = "https://builder.teamneptune.net/build/"; constexpr const char DEEPSEA_PACKAGE_PATH[] = "/config/deepsea/customPackage.json"; +constexpr const char CUSTOM_PACKS_PATH[] = "/config/aio-switch-updater/customPacks.json"; + constexpr const char CHEATS_RELEASE_URL[] = "https://github.com/HamletDuFromage/switch-cheats-db/releases/tag/v1.0"; constexpr const char CHEATS_URL_TITLES[] = "https://github.com/HamletDuFromage/switch-cheats-db/releases/download/v1.0/titles.zip"; constexpr const char CHEATS_URL_CONTENTS[] ="https://github.com/HamletDuFromage/switch-cheats-db/releases/download/v1.0/contents.zip"; diff --git a/resources/i18n/en-US/menus.json b/resources/i18n/en-US/menus.json index c99351f..fc0424a 100644 --- a/resources/i18n/en-US/menus.json +++ b/resources/i18n/en-US/menus.json @@ -179,7 +179,8 @@ "download_deepsea_package": "Compile and download", "cant_fetch_deepsea": "Couldn't fetch packages. Open a Github issue if this persists.", "build_your_deepsea": "Build your own custom DeepSea package by selecting packages", - "getting_ams": "Getting Atmosphère" + "getting_ams": "Getting Atmosphère", + "custom_packs_label": "Here are packs listed in the {} file. Be aware that those are not endorsed by aio-switch-updater so make sure you trust their source." }, "net": { "title": "Internet settings" diff --git a/source/ams_tab.cpp b/source/ams_tab.cpp index 6d0e21b..6286c03 100644 --- a/source/ams_tab.cpp +++ b/source/ams_tab.cpp @@ -20,7 +20,7 @@ AmsTab::AmsTab(const bool erista) : brls::List() download::getRequest(AMS_URL, cfws); - CreateDownloadItems("Atmosphere"); + CreateDownloadItems(cfws["Atmosphere"]); description = new brls::Label( brls::LabelStyle::DESCRIPTION, @@ -38,14 +38,26 @@ AmsTab::AmsTab(const bool erista) : brls::List() }); this->addView(listItem); - CreateDownloadItems("DeepSea", false); + CreateDownloadItems(cfws["DeepSea"], false); + + 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); + } } -void AmsTab::CreateDownloadItems(const std::string& key, bool hekate) +void AmsTab::CreateDownloadItems(const nlohmann::ordered_json& cfw_links, bool hekate) { std::string operation("menus/ams_update/getting_ams"_i18n); std::vector> links; - links = download::getLinksFromJson(cfws[key]); + links = download::getLinksFromJson(cfw_links); this->size = links.size(); if(this->size){ auto hekate_link = download::getLinks(HEKATE_URL); diff --git a/source/changelog_page.cpp b/source/changelog_page.cpp index 7514c49..3555b6b 100644 --- a/source/changelog_page.cpp +++ b/source/changelog_page.cpp @@ -172,6 +172,9 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true) verTitles.push_back("v2.9.0"); changes.push_back("\uE016 Added support for Team-Neptune's custom pack builder."); + verTitles.push_back("v2.9.0"); + changes.push_back("\uE016 Added support custom packs through a json files."); + for(int i = verTitles.size() -1 ; i >= 0; i--){ listItem = new brls::ListItem(verTitles[i]); change = changes[i];