From 0dc8369bff47a92f3f5b0285e9cf33ec011a9703 Mon Sep 17 00:00:00 2001 From: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Sat, 7 Nov 2020 10:52:08 +0100 Subject: [PATCH] Woops, fixes and defines. :P --- include/common.hpp | 1 + source/screens/mainScreen.cpp | 14 ++++++++++++++ source/store/grid.cpp | 14 +++++++++----- source/store/list.cpp | 1 + source/store/store.cpp | 6 +++--- source/utils/download.cpp | 8 ++++---- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/include/common.hpp b/include/common.hpp index 6961913..94361c9 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -38,6 +38,7 @@ inline std::unique_ptr config; #define _STORE_PATH "sdmc:/3ds/Universal-Updater/stores/" #define _META_PATH "sdmc:/3ds/Universal-Updater/MetaData.json" +#define _UNISTORE_VERSION 3 inline uint32_t hRepeat, hDown, hHeld; inline touchPosition touch; diff --git a/source/screens/mainScreen.cpp b/source/screens/mainScreen.cpp index 94c08bf..c6978fb 100644 --- a/source/screens/mainScreen.cpp +++ b/source/screens/mainScreen.cpp @@ -77,6 +77,20 @@ MainScreen::MainScreen() { } else { notConnectedMsg(); } + + } else { + const UniStoreInfo info = GetInfo("sdmc:/3ds/Universal-Updater/stores/universal-db.unistore", "universal-db.unistore"); + + if (info.Version != _UNISTORE_VERSION) { + if (checkWifiStatus()) { + std::string tmp = ""; // Just a temp. + DownloadUniStore("https://db.universal-team.net/unistore/universal-db.unistore", -1, tmp, true, true); + DownloadSpriteSheet("https://db.universal-team.net/unistore/universal-db.t3x", "universal-db.t3x"); + + } else { + notConnectedMsg(); + } + } } } diff --git a/source/store/grid.cpp b/source/store/grid.cpp index 28141b2..6ebbfac 100644 --- a/source/store/grid.cpp +++ b/source/store/grid.cpp @@ -103,11 +103,13 @@ void StoreUtils::GridLogic(std::unique_ptr &store, std::vectorGetBox() > 9) { - if (store->GetEntry() + 5 < (int)entries.size()) { + if (store->GetEntry() + 5 < (int)entries.size() - 1) { store->SetEntry(store->GetEntry() + 5); - if (store->GetScreenIndx() < (((int)entries.size() / 5) - 2)) { - store->SetScreenIndx(store->GetScreenIndx() + 1); + if (entries.size() > 15) { + if (store->GetScreenIndx() < (((int)entries.size() / 5) - 2)) { + store->SetScreenIndx(store->GetScreenIndx() + 1); + } } } else { @@ -115,8 +117,10 @@ void StoreUtils::GridLogic(std::unique_ptr &store, std::vectorSetEntry(entries.size() - 1); store->SetBox(10 + (store->GetEntry() % 5)); - if (store->GetScreenIndx() < (((int)entries.size() / 5) - 2)) { - store->SetScreenIndx(store->GetScreenIndx() + 1); + if (entries.size() > 15) { + if (store->GetScreenIndx() < (((int)entries.size() / 5) - 2)) { + store->SetScreenIndx(store->GetScreenIndx() + 1); + } } } } diff --git a/source/store/list.cpp b/source/store/list.cpp index 5a918cb..0b31f02 100644 --- a/source/store/list.cpp +++ b/source/store/list.cpp @@ -103,6 +103,7 @@ void StoreUtils::ListLogic(std::unique_ptr &store, std::vectorGetEntry() - 2 > 0) store->SetEntry(store->GetEntry() - 3); + else store->SetEntry(0); } if (hRepeat & KEY_UP) { diff --git a/source/store/store.cpp b/source/store/store.cpp index 80169ce..5038e5f 100644 --- a/source/store/store.cpp +++ b/source/store/store.cpp @@ -219,9 +219,9 @@ 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"] < 3) Msg::waitMsg(Lang::get("UNISTORE_TOO_OLD")); - else if (this->storeJson["storeInfo"]["version"] > 3) Msg::waitMsg(Lang::get("UNISTORE_TOO_NEW")); - this->valid = this->storeJson["storeInfo"]["version"] == 3; + if (this->storeJson["storeInfo"]["version"] < _UNISTORE_VERSION) 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 { diff --git a/source/utils/download.cpp b/source/utils/download.cpp index a9697e6..b534edb 100644 --- a/source/utils/download.cpp +++ b/source/utils/download.cpp @@ -582,9 +582,9 @@ bool DownloadUniStore(const std::string &URL, int currentRev, std::string &fl, b nlohmann::json parsedAPI = nlohmann::json::parse(result_buf); if (parsedAPI.contains("storeInfo") && parsedAPI.contains("storeContent")) { - /* Ensure, version == 3. */ + /* Ensure, version == _UNISTORE_VERSION. */ if (parsedAPI["storeInfo"].contains("version") && parsedAPI["storeInfo"]["version"].is_number()) { - if (parsedAPI["storeInfo"]["version"] == 3) { + if (parsedAPI["storeInfo"]["version"] == _UNISTORE_VERSION) { if (currentRev > -1) { if (parsedAPI["storeInfo"].contains("revision") && parsedAPI["storeInfo"]["revision"].is_number()) { @@ -644,10 +644,10 @@ bool DownloadUniStore(const std::string &URL, int currentRev, std::string &fl, b } } - } else if (parsedAPI["storeInfo"]["version"] < 3) { + } else if (parsedAPI["storeInfo"]["version"] < _UNISTORE_VERSION) { Msg::waitMsg(Lang::get("UNISTORE_TOO_OLD")); - } else if (parsedAPI["storeInfo"]["version"] > 3) { + } else if (parsedAPI["storeInfo"]["version"] > _UNISTORE_VERSION) { Msg::waitMsg(Lang::get("UNISTORE_TOO_NEW")); }