diff --git a/assets/gfx/sprites.t3s b/assets/gfx/sprites.t3s index 0c691ac..65ca72c 100644 --- a/assets/gfx/sprites.t3s +++ b/assets/gfx/sprites.t3s @@ -11,6 +11,7 @@ sprites/noIcon.png sprites/qr_code.png sprites/search.png sprites/settings.png +sprites/shortcut.png sprites/sort.png sprites/sort_checked.png sprites/sort_unchecked.png diff --git a/assets/gfx/sprites/shortcut.png b/assets/gfx/sprites/shortcut.png new file mode 100644 index 0000000..864a299 Binary files /dev/null and b/assets/gfx/sprites/shortcut.png differ diff --git a/include/common.hpp b/include/common.hpp index 8a4f01c..395d0e1 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -36,7 +36,7 @@ #define _STORE_PATH "sdmc:/3ds/Universal-Updater/stores/" #define _META_PATH "sdmc:/3ds/Universal-Updater/MetaData.json" -#define _UNISTORE_VERSION 3 +#define _UNISTORE_VERSION 4 inline std::unique_ptr config; inline uint32_t hRepeat, hDown, hHeld; diff --git a/include/screens/mainScreen.hpp b/include/screens/mainScreen.hpp index cc88ed2..e1e094e 100644 --- a/include/screens/mainScreen.hpp +++ b/include/screens/mainScreen.hpp @@ -51,7 +51,7 @@ private: std::unique_ptr store = nullptr; std::unique_ptr meta = nullptr; std::vector> entries; - std::vector dwnldList; + std::vector dwnldList, dwnldSizes; bool initialized = false, fetchDown = false, showMarks = false, showSettings = false, ascending = false, updateFilter = false; int storeMode = 0, marks = 0, markIndex = 0, sPage = 0, lMode = 0, sSelection = 0, lastMode = 0, smallDelay = 0, sPos = 0; SortType sorttype = SortType::LAST_UPDATED; diff --git a/include/store/store.hpp b/include/store/store.hpp index e7f4ba6..0d0fdea 100644 --- a/include/store/store.hpp +++ b/include/store/store.hpp @@ -54,6 +54,7 @@ public: std::string GetLastUpdatedEntry(int index) const; std::string GetLicenseEntry(int index) const; C2D_Image GetIconEntry(int index) const; + std::string GetFileSizes(int index, const std::string &entry) const; std::vector GetDownloadList(int index) const; diff --git a/include/store/storeEntry.hpp b/include/store/storeEntry.hpp index 48f22f9..f716b94 100644 --- a/include/store/storeEntry.hpp +++ b/include/store/storeEntry.hpp @@ -52,6 +52,7 @@ public: std::vector GetCategoryFull() const { return this->FullCategory; }; std::vector GetConsoleFull() const { return this->FullConsole; }; + std::vector GetSizes() const { return this->Sizes; }; bool GetUpdateAvl() const { return this->UpdateAvailable; }; void SetUpdateAvl(bool v) { this->UpdateAvailable = v; }; @@ -65,7 +66,7 @@ private: std::string Title, Author, Description, Category, Version, Console, LastUpdated, License, MarkString; C2D_Image Icon; int SheetIndex, EntryIndex, Marks; - std::vector FullCategory, FullConsole; + std::vector FullCategory, FullConsole, Sizes; bool UpdateAvailable; }; diff --git a/include/store/storeUtils.hpp b/include/store/storeUtils.hpp index f53a108..ac66b7a 100644 --- a/include/store/storeUtils.hpp +++ b/include/store/storeUtils.hpp @@ -56,7 +56,7 @@ namespace StoreUtils { void SideMenuHandle(int ¤tMenu, bool &fetch, int &lastMenu); /* Download Entries. */ - void DrawDownList(const std::unique_ptr &store, const std::vector &entries, bool fetch); + void DrawDownList(const std::unique_ptr &store, const std::vector &entries, bool fetch, const std::unique_ptr &entry, const std::vector &sizes); void DownloadHandle(const std::unique_ptr &store, const std::unique_ptr &entry, const std::vector &entries, int ¤tMenu, std::unique_ptr &meta, const int &lastMode, int &smallDelay); /* Search + Favorite Menu. */ diff --git a/romfs/lang/en/app.json b/romfs/lang/en/app.json index 20c0030..68308b7 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -90,6 +90,7 @@ "SETTINGS": "Settings", "SHEET_SLASH": "Seems like a '/' is included, which is not supported.\nPlease change 'sheet' to filename only.", "SHORTCUT_CREATED": "Shortcut created!", + "SIZE": "Size", "SORT_BY": "Sort By", "SORTING": "Sorting", "START_SELECT": "Press START to select the current folder", diff --git a/source/overlays/storeSelect.cpp b/source/overlays/storeSelect.cpp index ede803d..1f5aa00 100644 --- a/source/overlays/storeSelect.cpp +++ b/source/overlays/storeSelect.cpp @@ -316,7 +316,7 @@ void Overlays::SelectStore(std::unique_ptr &store, std::vector 3) Msg::waitMsg(Lang::get("UNISTORE_TOO_NEW")); + else if (info[selection].Version > _UNISTORE_VERSION) Msg::waitMsg(Lang::get("UNISTORE_TOO_NEW")); else { store = std::make_unique(_STORE_PATH + info[selection].FileName, info[selection].FileName); StoreUtils::ResetAll(store, meta, entries); @@ -338,7 +338,7 @@ void Overlays::SelectStore(std::unique_ptr &store, std::vector 3) Msg::waitMsg(Lang::get("UNISTORE_TOO_NEW")); + else if (info[i + sPos].Version > _UNISTORE_VERSION) Msg::waitMsg(Lang::get("UNISTORE_TOO_NEW")); else { store = std::make_unique(_STORE_PATH + info[i + sPos].FileName, info[i + sPos].FileName); StoreUtils::ResetAll(store, meta, entries); diff --git a/source/qr/qrcode.cpp b/source/qr/qrcode.cpp index 6e8f934..d850e7e 100644 --- a/source/qr/qrcode.cpp +++ b/source/qr/qrcode.cpp @@ -89,8 +89,8 @@ void QRCode::buffToImage() { for (u32 x = 0; x < 400; x++) { for (u32 y = 0; y < 240; y++) { - const u32 dstPos = ((((y >> 3) * (512 >> 3) + (x >> 3)) << 6) + - ((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) | ((y & 2) << 2) | ((x & 4) << 2) | ((y & 4) << 3))) * 2; + const u32 dstPos = ((((y >> 3) * (512 >> 3) + (x >> 3)) << 6) + + ((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) | ((y & 2) << 2) | ((x & 4) << 2) | ((y & 4) << 3))) * 2; const u32 srcPos = (y * 400 + x) * 2; memcpy(((u8 *)this->image.tex->data) + dstPos, ((u8 *)this->cameraBuffer.data()) + srcPos, 2); diff --git a/source/screens/mainScreen.cpp b/source/screens/mainScreen.cpp index 6a612d2..b101f2c 100644 --- a/source/screens/mainScreen.cpp +++ b/source/screens/mainScreen.cpp @@ -54,7 +54,7 @@ MainScreen::MainScreen() { /* check version and file here. */ const UniStoreInfo info = GetInfo((std::string(_STORE_PATH) + config->lastStore()), config->lastStore()); - if (info.Version != 3) { + if (info.Version != 3 || info.Version != _UNISTORE_VERSION) { config->lastStore("universal-db.unistore"); } @@ -81,7 +81,8 @@ MainScreen::MainScreen() { } else { const UniStoreInfo info = GetInfo("sdmc:/3ds/Universal-Updater/stores/universal-db.unistore", "universal-db.unistore"); - if (info.Version != _UNISTORE_VERSION) { + if (info.Version != 3 && info.Version != _UNISTORE_VERSION) { + Msg::waitMsg("Not passing the check!"); if (checkWifiStatus()) { std::string tmp = ""; // Just a temp. DownloadUniStore("https://db.universal-team.net/unistore/universal-db.unistore", -1, tmp, true, true); @@ -111,34 +112,35 @@ void MainScreen::Draw(void) const { else Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("INVALID_UNISTORE"), 370, 0, font); config->list() ? StoreUtils::DrawList(this->store, this->entries) : StoreUtils::DrawGrid(this->store, this->entries); - if (fadeAlpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(0, 0, 0, fadeAlpha)); - GFX::DrawBottom(); + /* Download-ception. */ + if (this->storeMode == 1) { + StoreUtils::DrawDownList(this->store, this->dwnldList, this->fetchDown, this->entries[this->store->GetEntry()], this->dwnldSizes); - switch(this->storeMode) { - case 0: - /* Entry Info. */ - if (this->store && this->store->GetValid() && this->entries.size() > 0) StoreUtils::DrawEntryInfo(this->store, this->entries[this->store->GetEntry()]); - break; + } else { + if (fadeAlpha > 0) Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(0, 0, 0, fadeAlpha)); + GFX::DrawBottom(); - case 1: - /* Download List. */ - StoreUtils::DrawDownList(this->store, this->dwnldList, this->fetchDown); - break; + switch(this->storeMode) { + case 0: + /* Entry Info. */ + if (this->store && this->store->GetValid() && this->entries.size() > 0) StoreUtils::DrawEntryInfo(this->store, this->entries[this->store->GetEntry()]); + break; - case 2: - /* Search + Favorites. */ - StoreUtils::DrawSearchMenu(this->searchIncludes, this->searchResult, this->marks, this->updateFilter); - break; + case 2: + /* Search + Favorites. */ + StoreUtils::DrawSearchMenu(this->searchIncludes, this->searchResult, this->marks, this->updateFilter); + break; - case 3: - /* Sorting. */ - StoreUtils::DrawSorting(this->ascending, this->sorttype); - break; + case 3: + /* Sorting. */ + StoreUtils::DrawSorting(this->ascending, this->sorttype); + break; - case 4: - /* Settings. */ - StoreUtils::DrawSettings(this->sPage, this->sSelection, this->sPos); - break; + case 4: + /* Settings. */ + StoreUtils::DrawSettings(this->sPage, this->sSelection, this->sPos); + break; + } } StoreUtils::DrawSideMenu(this->storeMode); @@ -162,6 +164,7 @@ void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) { /* Fetch Download list. */ if (this->fetchDown) { this->dwnldList.clear(); + this->dwnldSizes.clear(); if (this->store && this->store->GetValid()) { this->store->SetDownloadIndex(0); // Reset to 0. @@ -169,6 +172,7 @@ void MainScreen::Logic(u32 hDown, u32 hHeld, touchPosition touch) { if ((int)this->entries.size() > this->store->GetEntry()) { this->dwnldList = this->store->GetDownloadList(this->entries[this->store->GetEntry()]->GetEntryIndex()); + this->dwnldSizes = this->entries[this->store->GetEntry()]->GetSizes(); } } diff --git a/source/store/downList.cpp b/source/store/downList.cpp index da29184..3f519e2 100644 --- a/source/store/downList.cpp +++ b/source/store/downList.cpp @@ -41,7 +41,9 @@ static const std::vector downloadBoxes = { { 54, 122, 262, 22 }, { 54, 152, 262, 22 }, { 54, 182, 262, 22 }, - { 54, 212, 262, 22 } + { 54, 212, 262, 22 }, + + { 50, 216, 24, 24 } }; /* @@ -89,19 +91,44 @@ static void CreateShortcut(const std::string &entryName, int index, const std::s const std::unique_ptr &store: Const Reference to the Store class. const std::vector &entries: Const Reference to the download list as a vector of strings. bool fetch: if fetching or not. + const std::unique_ptr &entry: Const Reference to the StoreEntry. + const std::vector &sizes: Const Reference to the download sizes as a vector of strings. */ -void StoreUtils::DrawDownList(const std::unique_ptr &store, const std::vector &entries, bool fetch) { - if (store && !fetch) { - Gui::Draw_Rect(48, 0, 272, 25, ENTRY_BAR_COLOR); - Gui::Draw_Rect(48, 25, 272, 1, ENTRY_BAR_OUTL_COLOR); - Gui::DrawStringCentered(25, 2, 0.6, TEXT_COLOR, Lang::get("AVAILABLE_DOWNLOADS"), 265, 0, font); +void StoreUtils::DrawDownList(const std::unique_ptr &store, const std::vector &entries, bool fetch, const std::unique_ptr &entry, const std::vector &sizes) { + /* For the Top Screen. */ + if (store && store->GetValid() && !fetch && entry) { + if (entries.size() > 0) { + Gui::Draw_Rect(0, 174, 400, 66, BOX_INSIDE_COLOR); + const C2D_Image tempImg = entry->GetIcon(); + const uint8_t offsetW = (48 - tempImg.subtex->width) / 2; // Center W. + const uint8_t offsetH = (48 - tempImg.subtex->height) / 2; // Center H. + C2D_DrawImageAt(tempImg, 9 + offsetW, 174 + 9 + offsetH, 0.5); + + Gui::DrawString(70, 174 + 15, 0.45f, TEXT_COLOR, entries[store->GetDownloadIndex()], 310, 0, font); + + if (!sizes.empty()) { + if (sizes[store->GetDownloadIndex()] != "") { + Gui::DrawString(70, 174 + 30, 0.45f, TEXT_COLOR, Lang::get("SIZE") + ": " + sizes[store->GetDownloadIndex()], 310, 0, font); + } + } + } + } + + GFX::DrawBottom(); + Gui::Draw_Rect(48, 0, 272, 25, ENTRY_BAR_COLOR); + Gui::Draw_Rect(48, 25, 272, 1, ENTRY_BAR_OUTL_COLOR); + Gui::DrawStringCentered(25, 2, 0.6, TEXT_COLOR, Lang::get("AVAILABLE_DOWNLOADS"), 265, 0, font); + + if (store && store->GetValid() && !fetch && entry) { if (entries.size() > 0) { for (int i = 0; i < DOWNLOAD_ENTRIES && i < (int)entries.size(); i++) { if (store->GetDownloadIndex() == i + store->GetDownloadSIndex()) GFX::DrawBox(downloadBoxes[i].x, downloadBoxes[i].y, downloadBoxes[i].w, downloadBoxes[i].h, false); Gui::DrawStringCentered(54 - 160 + (262 / 2), downloadBoxes[i].y + 4, 0.45f, TEXT_COLOR, entries[(i + store->GetDownloadSIndex())], 260, 0, font); } + GFX::DrawSprite(sprites_shortcut_idx, downloadBoxes[6].x, downloadBoxes[6].y); + } else { // If no downloads available.. Gui::DrawStringCentered(54 - 160 + (262 / 2), downloadBoxes[0].y + 4, 0.5f, TEXT_COLOR, Lang::get("NO_DOWNLOADS_AVAILABLE"), 255, 0, font); } @@ -130,8 +157,10 @@ void StoreUtils::DownloadHandle(const std::unique_ptr &store, const std:: smallDelay--; } - if ((hDown & KEY_Y) || (hDown & KEY_START)) { + if ((hDown & KEY_Y) || (hDown & KEY_START) || (hDown & KEY_TOUCH && touching(touch, downloadBoxes[6]))) { if (is3DSX) { // Only allow if 3DSX. + if (entries.size() <= 0) return; // Smaller than 0 -> No No. + if (Msg::promptMsg(Lang::get("CREATE_SHORTCUT"))) { CreateShortcut(entry->GetTitle(), store->GetDownloadIndex(), store->GetFileName(), entry->GetAuthor()); Msg::waitMsg(Lang::get("SHORTCUT_CREATED")); diff --git a/source/store/store.cpp b/source/store/store.cpp index 7eeb50e..08dd2b9 100644 --- a/source/store/store.cpp +++ b/source/store/store.cpp @@ -228,9 +228,11 @@ void Store::LoadFromFile(const std::string &file) { /* Check, if valid. */ if (this->storeJson.contains("storeInfo") && this->storeJson.contains("storeContent")) { if (this->storeJson["storeInfo"].contains("version") && this->storeJson["storeInfo"]["version"].is_number()) { - if (this->storeJson["storeInfo"]["version"] < _UNISTORE_VERSION) Msg::waitMsg(Lang::get("UNISTORE_TOO_OLD")); + if (this->storeJson["storeInfo"]["version"] < 3) Msg::waitMsg(Lang::get("UNISTORE_TOO_OLD")); else if (this->storeJson["storeInfo"]["version"] > _UNISTORE_VERSION) Msg::waitMsg(Lang::get("UNISTORE_TOO_NEW")); - this->valid = this->storeJson["storeInfo"]["version"] == _UNISTORE_VERSION; + else if (this->storeJson["storeInfo"]["version"] == 3 || this->storeJson["storeInfo"]["version"] == _UNISTORE_VERSION) { + this->valid = this->storeJson["storeInfo"]["version"] = true; + } } } else { @@ -473,4 +475,18 @@ std::vector Store::GetDownloadList(int index) const { } return temp; +} + +std::string Store::GetFileSizes(int index, const std::string &entry) const { + if (!this->valid) return ""; + + if (index > (int)this->storeJson["storeContent"].size() - 1) return ""; + + if (this->storeJson["storeContent"][index].contains(entry) && this->storeJson["storeContent"][index][entry].type() == nlohmann::json::value_t::object) { + if (this->storeJson["storeContent"][index][entry].contains("size") && this->storeJson["storeContent"][index][entry]["size"].is_string()) { + return this->storeJson["storeContent"][index][entry]["size"]; + } + } + + return ""; } \ No newline at end of file diff --git a/source/store/storeEntry.cpp b/source/store/storeEntry.cpp index 16f922b..542934c 100644 --- a/source/store/storeEntry.cpp +++ b/source/store/storeEntry.cpp @@ -55,4 +55,12 @@ StoreEntry::StoreEntry(const std::unique_ptr &store, const std::unique_pt this->UpdateAvailable = meta->UpdateAvailable(store->GetUniStoreTitle(), this->Title, store->GetLastUpdatedEntry(index)); this->Marks = meta->GetMarks(store->GetUniStoreTitle(), this->Title); + + const std::vector entries = store->GetDownloadList(index); + + if (!entries.empty()) { + for (int i = 0; i < (int)entries.size(); i++) { + this->Sizes.push_back( store->GetFileSizes(index, entries[i]) ); + } + } } \ No newline at end of file diff --git a/source/utils/download.cpp b/source/utils/download.cpp index b534edb..f639f4a 100644 --- a/source/utils/download.cpp +++ b/source/utils/download.cpp @@ -584,7 +584,7 @@ bool DownloadUniStore(const std::string &URL, int currentRev, std::string &fl, b if (parsedAPI.contains("storeInfo") && parsedAPI.contains("storeContent")) { /* Ensure, version == _UNISTORE_VERSION. */ if (parsedAPI["storeInfo"].contains("version") && parsedAPI["storeInfo"]["version"].is_number()) { - if (parsedAPI["storeInfo"]["version"] == _UNISTORE_VERSION) { + if (parsedAPI["storeInfo"]["version"] == 3 || parsedAPI["storeInfo"]["version"] == 4) { if (currentRev > -1) { if (parsedAPI["storeInfo"].contains("revision") && parsedAPI["storeInfo"]["revision"].is_number()) { @@ -644,7 +644,7 @@ bool DownloadUniStore(const std::string &URL, int currentRev, std::string &fl, b } } - } else if (parsedAPI["storeInfo"]["version"] < _UNISTORE_VERSION) { + } else if (parsedAPI["storeInfo"]["version"] < 3) { Msg::waitMsg(Lang::get("UNISTORE_TOO_OLD")); } else if (parsedAPI["storeInfo"]["version"] > _UNISTORE_VERSION) { diff --git a/source/utils/scriptUtils.cpp b/source/utils/scriptUtils.cpp index 3eb3047..bd7eb26 100644 --- a/source/utils/scriptUtils.cpp +++ b/source/utils/scriptUtils.cpp @@ -276,12 +276,29 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const if ((int)storeJson["storeContent"].size() < selection) { Msg::waitMsg(Lang::get("SYNTAX_ERROR")); return SYNTAX_ERROR; }; if (!storeJson["storeContent"][selection].contains(entry)) { Msg::waitMsg(Lang::get("SYNTAX_ERROR")); return SYNTAX_ERROR; }; - for(int i = 0; i < (int)storeJson["storeContent"][selection][entry].size(); i++) { + nlohmann::json Script = nullptr; + + /* Detect if array or new object thing. Else return Syntax error. :P */ + if (storeJson["storeContent"][selection][entry].type() == nlohmann::json::value_t::array) { + Script = storeJson["storeContent"][selection][entry]; + + } else if (storeJson["storeContent"][selection][entry].type() == nlohmann::json::value_t::object) { + if (storeJson["storeContent"][selection][entry].contains("script") && storeJson["storeContent"][selection][entry]["script"].is_array()) { + Script = storeJson["storeContent"][selection][entry]["script"]; + + } else { + Msg::waitMsg(Lang::get("SYNTAX_ERROR")); + return SYNTAX_ERROR; + } + } + + + for(int i = 0; i < (int)Script.size(); i++) { if (ret == NONE) { std::string type = ""; - if (storeJson["storeContent"][selection][entry][i].contains("type") && storeJson["storeContent"][selection][entry][i]["type"].is_string()) { - type = storeJson["storeContent"][selection][entry][i]["type"]; + if (Script[i].contains("type") && Script[i]["type"].is_string()) { + type = Script[i]["type"]; } else { ret = SYNTAX_ERROR; @@ -292,13 +309,13 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const std::string file = "", message = ""; - if (storeJson["storeContent"][selection][entry][i].contains("file") && storeJson["storeContent"][selection][entry][i]["file"].is_string()) { - file = storeJson["storeContent"][selection][entry][i]["file"]; + if (Script[i].contains("file") && Script[i]["file"].is_string()) { + file = Script[i]["file"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("message") && storeJson["storeContent"][selection][entry][i]["message"].is_string()) { - message = storeJson["storeContent"][selection][entry][i]["message"]; + if (Script[i].contains("message") && Script[i]["message"].is_string()) { + message = Script[i]["message"]; } if (!missing) ret = ScriptUtils::removeFile(file, message); @@ -308,18 +325,18 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const bool missing = false; std::string file = "", output = "", message = ""; - if (storeJson["storeContent"][selection][entry][i].contains("file") && storeJson["storeContent"][selection][entry][i]["file"].is_string()) { - file = storeJson["storeContent"][selection][entry][i]["file"]; + if (Script[i].contains("file") && Script[i]["file"].is_string()) { + file = Script[i]["file"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("output") && storeJson["storeContent"][selection][entry][i]["output"].is_string()) { - output = storeJson["storeContent"][selection][entry][i]["output"]; + if (Script[i].contains("output") && Script[i]["output"].is_string()) { + output = Script[i]["output"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("message") && storeJson["storeContent"][selection][entry][i]["message"].is_string()) { - message = storeJson["storeContent"][selection][entry][i]["message"]; + if (Script[i].contains("message") && Script[i]["message"].is_string()) { + message = Script[i]["message"]; } if (!missing) ret = ScriptUtils::downloadFile(file, output, message); @@ -329,26 +346,26 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const bool missing = false, includePrereleases = false; std::string repo = "", file = "", output = "", message = ""; - if (storeJson["storeContent"][selection][entry][i].contains("repo") && storeJson["storeContent"][selection][entry][i]["repo"].is_string()) { - repo = storeJson["storeContent"][selection][entry][i]["repo"]; + if (Script[i].contains("repo") && Script[i]["repo"].is_string()) { + repo = Script[i]["repo"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("file") && storeJson["storeContent"][selection][entry][i]["file"].is_string()) { - file = storeJson["storeContent"][selection][entry][i]["file"]; + if (Script[i].contains("file") && Script[i]["file"].is_string()) { + file = Script[i]["file"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("output") && storeJson["storeContent"][selection][entry][i]["output"].is_string()) { - output = storeJson["storeContent"][selection][entry][i]["output"]; + if (Script[i].contains("output") && Script[i]["output"].is_string()) { + output = Script[i]["output"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("includePrereleases") && storeJson["storeContent"][selection][entry][i]["includePrereleases"].is_boolean()) - includePrereleases = storeJson["storeContent"][selection][entry][i]["includePrereleases"]; + if (Script[i].contains("includePrereleases") && Script[i]["includePrereleases"].is_boolean()) + includePrereleases = Script[i]["includePrereleases"]; - if (storeJson["storeContent"][selection][entry][i].contains("message") && storeJson["storeContent"][selection][entry][i]["message"].is_string()) { - message = storeJson["storeContent"][selection][entry][i]["message"]; + if (Script[i].contains("message") && Script[i]["message"].is_string()) { + message = Script[i]["message"]; } if (!missing) ret = ScriptUtils::downloadRelease(repo, file, output, includePrereleases, message); @@ -358,23 +375,23 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const bool missing = false; std::string file = "", input = "", output = "", message = ""; - if (storeJson["storeContent"][selection][entry][i].contains("file") && storeJson["storeContent"][selection][entry][i]["file"].is_string()) { - file = storeJson["storeContent"][selection][entry][i]["file"]; + if (Script[i].contains("file") && Script[i]["file"].is_string()) { + file = Script[i]["file"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("input") && storeJson["storeContent"][selection][entry][i]["input"].is_string()) { - input = storeJson["storeContent"][selection][entry][i]["input"]; + if (Script[i].contains("input") && Script[i]["input"].is_string()) { + input = Script[i]["input"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("output") && storeJson["storeContent"][selection][entry][i]["output"].is_string()) { - output = storeJson["storeContent"][selection][entry][i]["output"]; + if (Script[i].contains("output") && Script[i]["output"].is_string()) { + output = Script[i]["output"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("message") && storeJson["storeContent"][selection][entry][i]["message"].is_string()) { - message = storeJson["storeContent"][selection][entry][i]["message"]; + if (Script[i].contains("message") && Script[i]["message"].is_string()) { + message = Script[i]["message"]; } if (!missing) ScriptUtils::extractFile(file, input, output, message); @@ -384,17 +401,17 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const bool missing = false, updateSelf = false; std::string file = "", message = ""; - if (storeJson["storeContent"][selection][entry][i].contains("file") && storeJson["storeContent"][selection][entry][i]["file"].is_string()) { - file = storeJson["storeContent"][selection][entry][i]["file"]; + if (Script[i].contains("file") && Script[i]["file"].is_string()) { + file = Script[i]["file"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("updateSelf") && storeJson["storeContent"][selection][entry][i]["updateSelf"].is_boolean()) { - updateSelf = storeJson["storeContent"][selection][entry][i]["updateSelf"]; + if (Script[i].contains("updateSelf") && Script[i]["updateSelf"].is_boolean()) { + updateSelf = Script[i]["updateSelf"]; } - if (storeJson["storeContent"][selection][entry][i].contains("message") && storeJson["storeContent"][selection][entry][i]["message"].is_string()) { - message = storeJson["storeContent"][selection][entry][i]["message"]; + if (Script[i].contains("message") && Script[i]["message"].is_string()) { + message = Script[i]["message"]; } if (!missing) ScriptUtils::installFile(file, updateSelf, message); @@ -404,8 +421,8 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const bool missing = false; std::string directory = "", message = ""; - if (storeJson["storeContent"][selection][entry][i].contains("directory") && storeJson["storeContent"][selection][entry][i]["directory"].is_string()) { - directory = storeJson["storeContent"][selection][entry][i]["directory"]; + if (Script[i].contains("directory") && Script[i]["directory"].is_string()) { + directory = Script[i]["directory"]; } else missing = true; @@ -416,8 +433,8 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const bool missing = false; std::string directory = "", message = "", promptmsg = ""; - if (storeJson["storeContent"][selection][entry][i].contains("directory") && storeJson["storeContent"][selection][entry][i]["directory"].is_string()) { - directory = storeJson["storeContent"][selection][entry][i]["directory"]; + if (Script[i].contains("directory") && Script[i]["directory"].is_string()) { + directory = Script[i]["directory"]; } else missing = true; @@ -435,12 +452,12 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const std::string Message = ""; int skipCount = -1; - if (storeJson["storeContent"][selection][entry][i].contains("message") && storeJson["storeContent"][selection][entry][i]["message"].is_string()) { - Message = storeJson["storeContent"][selection][entry][i]["message"]; + if (Script[i].contains("message") && Script[i]["message"].is_string()) { + Message = Script[i]["message"]; } - if (storeJson["storeContent"][selection][entry][i].contains("count") && storeJson["storeContent"][selection][entry][i]["count"].is_number()) { - skipCount = storeJson["storeContent"][selection][entry][i]["count"]; + if (Script[i].contains("count") && Script[i]["count"].is_number()) { + skipCount = Script[i]["count"]; } ret = ScriptUtils::prompt(Message); @@ -457,18 +474,18 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const std::string Message = "", source = "", destination = ""; bool missing = false; - if (storeJson["storeContent"][selection][entry][i].contains("source") && storeJson["storeContent"][selection][entry][i]["source"].is_string()) { - source = storeJson["storeContent"][selection][entry][i]["source"]; + if (Script[i].contains("source") && Script[i]["source"].is_string()) { + source = Script[i]["source"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("destination") && storeJson["storeContent"][selection][entry][i]["destination"].is_string()) { - destination = storeJson["storeContent"][selection][entry][i]["destination"]; + if (Script[i].contains("destination") && Script[i]["destination"].is_string()) { + destination = Script[i]["destination"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("message") && storeJson["storeContent"][selection][entry][i]["message"].is_string()) { - Message = storeJson["storeContent"][selection][entry][i]["message"]; + if (Script[i].contains("message") && Script[i]["message"].is_string()) { + Message = Script[i]["message"]; } if (!missing) ret = ScriptUtils::copyFile(source, destination, Message); @@ -478,18 +495,18 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const std::string Message = "", oldFile = "", newFile = ""; bool missing = false; - if (storeJson["storeContent"][selection][entry][i].contains("old") && storeJson["storeContent"][selection][entry][i]["old"].is_string()) { - oldFile = storeJson["storeContent"][selection][entry][i]["old"]; + if (Script[i].contains("old") && Script[i]["old"].is_string()) { + oldFile = Script[i]["old"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("new") && storeJson["storeContent"][selection][entry][i]["new"].is_string()) { - newFile = storeJson["storeContent"][selection][entry][i]["new"]; + if (Script[i].contains("new") && Script[i]["new"].is_string()) { + newFile = Script[i]["new"]; } else missing = true; - if (storeJson["storeContent"][selection][entry][i].contains("message") && storeJson["storeContent"][selection][entry][i]["message"].is_string()) { - Message = storeJson["storeContent"][selection][entry][i]["message"]; + if (Script[i].contains("message") && Script[i]["message"].is_string()) { + Message = Script[i]["message"]; } if (!missing) ret = ScriptUtils::renameFile(oldFile, newFile, Message); @@ -498,8 +515,8 @@ Result ScriptUtils::runFunctions(nlohmann::json storeJson, int selection, const } else if (type == "skip") { int skipCount = -1; - if (storeJson["storeContent"][selection][entry][i].contains("count") && storeJson["storeContent"][selection][entry][i]["count"].is_number()) { - skipCount = storeJson["storeContent"][selection][entry][i]["count"]; + if (Script[i].contains("count") && Script[i]["count"].is_number()) { + skipCount = Script[i]["count"]; } if (skipCount > 0) {