1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-25 02:52:05 +00:00

Support for Team Neptune's pack builder

This commit is contained in:
flb 2021-07-07 16:59:52 +02:00
parent 5d7b6c7227
commit 9ea2a52be7
6 changed files with 101 additions and 2 deletions

View file

@ -22,7 +22,7 @@ DATA := data
INCLUDES := include lib/zipper/include /lib/borealis/library/include/borealis/extern/nlohmann INCLUDES := include lib/zipper/include /lib/borealis/library/include/borealis/extern/nlohmann
APP_TITLE := All-in-One Switch Updater APP_TITLE := All-in-One Switch Updater
APP_AUTHOR := HamletDuFromage APP_AUTHOR := HamletDuFromage
APP_VERSION := 2.8.0 APP_VERSION := 2.9.0
TARGET := $(notdir $(CURDIR)) TARGET := $(notdir $(CURDIR))
ROMFS := resources ROMFS := resources

View file

@ -17,6 +17,7 @@ class AmsTab : public brls::List
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 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 std::string& key, bool hekate = true);
nlohmann::ordered_json SortDeepseaModules(const nlohmann::ordered_json& modules); nlohmann::ordered_json SortDeepseaModules(const nlohmann::ordered_json& modules);
void ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules);
public: public:
AmsTab(const bool erista = true); AmsTab(const bool erista = true);

View file

@ -34,6 +34,10 @@ constexpr const char HEKATE_URL[] = "https://raw.githubusercontent.com/H
constexpr const char PAYLOAD_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/payloads.json"; constexpr const char PAYLOAD_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/payloads.json";
constexpr const char DEEPSEA_META_JSON[] = "https://builder.teamneptune.net/meta.json";
constexpr const char DEEPSEA_BUILD_URL[] = "https://builder.teamneptune.net/build/";
constexpr const char DEEPSEA_PACKAGE_PATH[] = "/config/deepsea/customPackage.json";
constexpr const char CHEATS_RELEASE_URL[] = "https://github.com/HamletDuFromage/switch-cheats-db/releases/tag/v1.0"; 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_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"; constexpr const char CHEATS_URL_CONTENTS[] ="https://github.com/HamletDuFromage/switch-cheats-db/releases/download/v1.0/contents.zip";

View file

@ -29,6 +29,15 @@ AmsTab::AmsTab(const bool erista) : brls::List()
); );
this->addView(description); 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);
CreateDownloadItems("DeepSea", false); CreateDownloadItems("DeepSea", false);
} }
@ -123,6 +132,88 @@ nlohmann::ordered_json AmsTab::SortDeepseaModules(const nlohmann::ordered_json&
return sorted_modules; return sorted_modules;
} }
void AmsTab::ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules)
{
modules = SortDeepseaModules(modules);
std::map<std::string, std::string> name_map;
brls::TabFrame* appView = new brls::TabFrame();
appView->setIcon("romfs:/deepsea_icon.png");
std::vector<brls::List*> lists;
std::set<std::string> old_modules = GetLastDownloadedModules(DEEPSEA_PACKAGE_PATH);
brls::ToggleListItem* deepseaListItem;
for (const auto& category : modules.items()) {
brls::List* list = new brls::List();
for (const auto& module : category.value().items()) {
auto module_value = module.value();
std::string requirements = "";
if(!module_value["requires"].empty()) {
requirements = "menus/ams_update/depends_on"_i18n;
for (const auto& r : module.value()["requires"]) {
requirements += " " + r.get<std::string>() + ",";
}
requirements.pop_back();
}
if(module_value["required"]) {
deepseaListItem = new UnTogglableListItem(module_value["displayName"], 1, requirements, "Required", "o");
}
else {
deepseaListItem = new::brls::ToggleListItem(module_value["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()));
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"]));
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/common/ok"_i18n, callback);
dialog->setCancelable(true);
dialog->open();
return true;
});
list->addView(deepseaListItem);
}
lists.push_back(list);
appView->addTab(category.key(), list);
}
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++) {
if(brls::ToggleListItem* item = dynamic_cast<brls::ToggleListItem*>(list->getChild(i))) {
if (item->getToggleState()) {
desired_modules.insert(name_map.at(item->getLabel()));
}
}
}
}
std::string request_url = DEEPSEA_BUILD_URL;
for(const auto& e : desired_modules)
request_url += e +";";
CreateStagedFrames("menus/common/download"_i18n + "Custom DeepSea package" + "menus/common/from"_i18n + request_url,
request_url,
"menus/ams_update/get_custom_deepsea"_i18n,
erista
);
return true;
});
appView->registerAction("", brls::Key::PLUS, [this] { return true; });
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, "");
}
bool UnTogglableListItem::onClick() bool UnTogglableListItem::onClick()
{ {
return true; return true;

View file

@ -169,6 +169,9 @@ ChangelogPage::ChangelogPage() : AppletFrame(true, true)
verTitles.push_back("v2.8.0"); verTitles.push_back("v2.8.0");
changes.push_back("\uE016 Restored and improved \"View installed cheats\" menu. You can now browse the content of your cheatsheets from the app."); changes.push_back("\uE016 Restored and improved \"View installed cheats\" menu. You can now browse the content of your cheatsheets from the app.");
verTitles.push_back("v2.9.0");
changes.push_back("\uE016 Added support for Team-Neptune's custom pack builder.");
for(int i = verTitles.size() -1 ; i >= 0; i--){ for(int i = verTitles.size() -1 ; i >= 0; i--){
listItem = new brls::ListItem(verTitles[i]); listItem = new brls::ListItem(verTitles[i]);
change = changes[i]; change = changes[i];

View file

@ -41,7 +41,7 @@ ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, std::string text, bool
this->label->setHorizontalAlign(NVG_ALIGN_CENTER); this->label->setHorizontalAlign(NVG_ALIGN_CENTER);
this->label->setParent(this); this->label->setParent(this);
if(this->done) if(this->done || this->reboot)
this->registerAction("", brls::Key::B, [this] { return true; }); this->registerAction("", brls::Key::B, [this] { return true; });
} }