See desc for more.

- Download Entry can now be an object for having "size".

- Show little box on the top on download list to display the entry, icon + size.

- Add Shortcut icon on download list.
This commit is contained in:
StackZ
2020-11-24 23:32:26 +01:00
parent 0ac9d6f448
commit 2e2acf819e
16 changed files with 181 additions and 103 deletions
+1
View File
@@ -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
Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

+1 -1
View File
@@ -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> config;
inline uint32_t hRepeat, hDown, hHeld;
+1 -1
View File
@@ -51,7 +51,7 @@ private:
std::unique_ptr<Store> store = nullptr;
std::unique_ptr<Meta> meta = nullptr;
std::vector<std::unique_ptr<StoreEntry>> entries;
std::vector<std::string> dwnldList;
std::vector<std::string> 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;
+1
View File
@@ -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<std::string> GetDownloadList(int index) const;
+2 -1
View File
@@ -52,6 +52,7 @@ public:
std::vector<std::string> GetCategoryFull() const { return this->FullCategory; };
std::vector<std::string> GetConsoleFull() const { return this->FullConsole; };
std::vector<std::string> 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<std::string> FullCategory, FullConsole;
std::vector<std::string> FullCategory, FullConsole, Sizes;
bool UpdateAvailable;
};
+1 -1
View File
@@ -56,7 +56,7 @@ namespace StoreUtils {
void SideMenuHandle(int &currentMenu, bool &fetch, int &lastMenu);
/* Download Entries. */
void DrawDownList(const std::unique_ptr<Store> &store, const std::vector<std::string> &entries, bool fetch);
void DrawDownList(const std::unique_ptr<Store> &store, const std::vector<std::string> &entries, bool fetch, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &sizes);
void DownloadHandle(const std::unique_ptr<Store> &store, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &entries, int &currentMenu, std::unique_ptr<Meta> &meta, const int &lastMode, int &smallDelay);
/* Search + Favorite Menu. */
+1
View File
@@ -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",
+2 -2
View File
@@ -316,7 +316,7 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
/* Load selected one. */
if (info[selection].Version == -1) Msg::waitMsg(Lang::get("UNISTORE_INVALID_ERROR"));
else if (info[selection].Version < 3) Msg::waitMsg(Lang::get("UNISTORE_TOO_OLD"));
else if (info[selection].Version > 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>(_STORE_PATH + info[selection].FileName, info[selection].FileName);
StoreUtils::ResetAll(store, meta, entries);
@@ -338,7 +338,7 @@ void Overlays::SelectStore(std::unique_ptr<Store> &store, std::vector<std::uniqu
if (!(info[i + sPos].File.find("/") != std::string::npos)) {
if (info[i + sPos].Version == -1) Msg::waitMsg(Lang::get("UNISTORE_INVALID_ERROR"));
else if (info[i + sPos].Version < 3) Msg::waitMsg(Lang::get("UNISTORE_TOO_OLD"));
else if (info[i + sPos].Version > 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>(_STORE_PATH + info[i + sPos].FileName, info[i + sPos].FileName);
StoreUtils::ResetAll(store, meta, entries);
+2 -2
View File
@@ -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);
+29 -25
View File
@@ -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();
}
}
+36 -7
View File
@@ -41,7 +41,9 @@ static const std::vector<Structs::ButtonPos> 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> &store: Const Reference to the Store class.
const std::vector<std::string> &entries: Const Reference to the download list as a vector of strings.
bool fetch: if fetching or not.
const std::unique_ptr<StoreEntry> &entry: Const Reference to the StoreEntry.
const std::vector<std::string> &sizes: Const Reference to the download sizes as a vector of strings.
*/
void StoreUtils::DrawDownList(const std::unique_ptr<Store> &store, const std::vector<std::string> &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> &store, const std::vector<std::string> &entries, bool fetch, const std::unique_ptr<StoreEntry> &entry, const std::vector<std::string> &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> &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"));
+18 -2
View File
@@ -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<std::string> 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 "";
}
+8
View File
@@ -55,4 +55,12 @@ StoreEntry::StoreEntry(const std::unique_ptr<Store> &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<std::string> 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]) );
}
}
}
+2 -2
View File
@@ -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) {
+76 -59
View File
@@ -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) {