diff --git a/include/utils/fileBrowse.hpp b/include/utils/fileBrowse.hpp index 3812316..a716146 100644 --- a/include/utils/fileBrowse.hpp +++ b/include/utils/fileBrowse.hpp @@ -45,6 +45,7 @@ struct UniStoreInfo { std::string Title; std::string Author; std::string URL; + std::string File; // Used to check, if File does NOT contain a slash or so. std::string FileName; std::string Description; int Version; diff --git a/source/overlays/langSelect.cpp b/source/overlays/langSelect.cpp index 4bd12a2..654ded7 100644 --- a/source/overlays/langSelect.cpp +++ b/source/overlays/langSelect.cpp @@ -33,7 +33,7 @@ extern bool checkWifiStatus(); extern bool touching(touchPosition touch, Structs::ButtonPos button); static const std::vector languages = { "Bruh", "Dansk", "Deutsch", "English", "Español", "Français", "Italiano", "Lietuvių", "Polski", "Português", "Русский", "日本語" }; -static const std::string langsTemp[] = { "br", "da", "de", "en", "es", "fr", "it", "lt", "pl", "pt", "ru", "jp "}; +static const std::string langsTemp[] = { "br", "da", "de", "en", "es", "fr", "it", "lt", "pl", "pt", "ru", "jp"}; static const std::vector mainButtons = { { 10, 4, 300, 22 }, diff --git a/source/overlays/storeSelect.cpp b/source/overlays/storeSelect.cpp index 8aeb249..866ee5d 100644 --- a/source/overlays/storeSelect.cpp +++ b/source/overlays/storeSelect.cpp @@ -247,31 +247,43 @@ void Overlays::SelectStore(std::unique_ptr &store, std::vector 3) Msg::waitMsg(Lang::get("UNISTORE_TOO_NEW")); - else { - store = std::make_unique(_STORE_PATH + info[selection].FileName); - StoreUtils::ResetAll(store, meta, entries); - config->lastStore(info[selection].FileName); - StoreUtils::SortEntries(false, SortType::LAST_UPDATED, entries); - doOut = true; + if (info[selection].File != "") { // Ensure to check for this. + if (!(info[selection].File.find("/") != std::string::npos)) { + /* 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 { + store = std::make_unique(_STORE_PATH + info[selection].FileName); + StoreUtils::ResetAll(store, meta, entries); + config->lastStore(info[selection].FileName); + StoreUtils::SortEntries(false, SortType::LAST_UPDATED, entries); + doOut = true; + } + + } else { + Msg::waitMsg(Lang::get("FILE_SLASH")); + } } } if (hidKeysDown() & KEY_TOUCH) { for (int i = 0; i < 7; i++) { if (touching(touch, mainButtons[i])) { - if (i + sPos < (int)info.size()) { - 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 { - store = std::make_unique(_STORE_PATH + info[i + sPos].FileName); - StoreUtils::ResetAll(store, meta, entries); - config->lastStore(info[i + sPos].FileName); - doOut = true; + if (i + sPos < (int)info.size() && info[i + sPos].File != "") { // Ensure to check for this. + 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 { + store = std::make_unique(_STORE_PATH + info[i + sPos].FileName); + StoreUtils::ResetAll(store, meta, entries); + config->lastStore(info[i + sPos].FileName); + doOut = true; + } + + } else { + Msg::waitMsg(Lang::get("FILE_SLASH")); } } } diff --git a/source/utils/fileBrowse.cpp b/source/utils/fileBrowse.cpp index bb86b54..fc5b1cf 100644 --- a/source/utils/fileBrowse.cpp +++ b/source/utils/fileBrowse.cpp @@ -110,7 +110,7 @@ std::vector getContents(const std::string &name, const std::vector< const std::string &fieName: Const Reference to the filename, without path. */ UniStoreInfo GetInfo(const std::string &file, const std::string &fileName) { - UniStoreInfo Temp = { "", "", "", fileName, "", -1, -1, -1 }; // Title, Author, URL, FileName, Desc, Version, Revision, Entries. + UniStoreInfo Temp = { "", "", "", "", fileName, "", -1, -1, -1 }; // Title, Author, URL, File (to check if no slash exist), FileName, Desc, Version, Revision, Entries. nlohmann::json JSON = nullptr; FILE *temp = fopen(file.c_str(), "r"); @@ -123,6 +123,10 @@ UniStoreInfo GetInfo(const std::string &file, const std::string &fileName) { Temp.Title = JSON["storeInfo"]["title"]; } + if (JSON["storeInfo"].contains("file") && JSON["storeInfo"]["file"].is_string()) { + Temp.File = JSON["storeInfo"]["file"]; + } + if (JSON["storeInfo"].contains("author") && JSON["storeInfo"]["author"].is_string()) { Temp.Author = JSON["storeInfo"]["author"]; }