From 34bcfd113b79967add56b6a4bbb77b866623758e Mon Sep 17 00:00:00 2001 From: SuperSaiyajinStackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Mon, 23 Dec 2019 00:01:41 +0100 Subject: [PATCH] ScriptBrowse: Press Y to download all Scripts. TinyDB: Downloads under 30 MB will download to RAM. --- source/screens/scriptBrowse.cpp | 19 +++++++++++++++++++ source/screens/tinyDB.cpp | 8 ++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/source/screens/scriptBrowse.cpp b/source/screens/scriptBrowse.cpp index 935b848..166846f 100644 --- a/source/screens/scriptBrowse.cpp +++ b/source/screens/scriptBrowse.cpp @@ -301,4 +301,23 @@ void ScriptBrowse::Logic(u32 hDown, u32 hHeld, touchPosition touch) { screenPosList = selection - ENTRIES_PER_LIST + 1; } } + + if (hDown & KEY_Y) { + if (infoJson.size() != 0) { + for (int i = 0; i < (int)infoJson.size(); i++) { + int current = i+1; + int total = infoJson.size(); + std::string fileName = Lang::get("DOWNLOADING") + std::string(infoJson[i]["title"]); + std::string titleFix = infoJson[i]["title"]; + for (int l = 0; l < (int)titleFix.size(); l++) { + if (titleFix[l] == '/') { + titleFix[l] = '-'; + } + } + DisplayMsg(fileName + " " + std::to_string(current) + " / " + std::to_string(total)); + downloadToFile(infoJson[i]["url"], Config::ScriptPath + titleFix + ".json", true); + infoJson[i]["curRevision"] = infoJson[i]["revision"]; + } + } + } } \ No newline at end of file diff --git a/source/screens/tinyDB.cpp b/source/screens/tinyDB.cpp index ba149f9..6c79de4 100644 --- a/source/screens/tinyDB.cpp +++ b/source/screens/tinyDB.cpp @@ -256,14 +256,18 @@ void TinyDB::execute() { if(!missing) ScriptHelper::removeFile(file, message); } else if(type == "downloadFile") { - bool missing = false; + bool missing = false, downloadToRAM = false; std::string file, output, message; if(tinyDBJson.at(selectedOption).at("script").at(i).contains("file")) file = tinyDBJson.at(selectedOption).at("script").at(i).at("file"); else missing = true; if(tinyDBJson.at(selectedOption).at("script").at(i).contains("output")) output = tinyDBJson.at(selectedOption).at("script").at(i).at("output"); else missing = true; if(tinyDBJson.at(selectedOption).at("script").at(i).contains("message")) message = tinyDBJson.at(selectedOption).at("script").at(i).at("message"); - if(!missing) ScriptHelper::downloadFile(file, output, false, message); + + if (int64_t(tinyDBJson[selectedOption]["info"]["fileSize"]) < 30000000) { + downloadToRAM = true; + } + if(!missing) ScriptHelper::downloadFile(file, output, downloadToRAM, message); } else if(type == "installCia") { bool missing = false;