diff --git a/include/keyboard.hpp b/include/keyboard.hpp index e6bec44..67c9225 100644 --- a/include/keyboard.hpp +++ b/include/keyboard.hpp @@ -27,10 +27,11 @@ #ifndef _UNIVERSAL_UPDATER_KEYBOARD_HPP #define _UNIVERSAL_UPDATER_KEYBOARD_HPP +#include "storeEntry.hpp" #include namespace Input { - std::string setkbdString(const uint &maxLength, const std::string &Text); + std::string setkbdString(uint maxLength, const std::string &Text, const std::vector> &entries); }; #endif \ No newline at end of file diff --git a/include/overlays/overlay.hpp b/include/overlays/overlay.hpp index de7e734..2e1ff12 100644 --- a/include/overlays/overlay.hpp +++ b/include/overlays/overlay.hpp @@ -34,9 +34,9 @@ namespace Overlays { void SelectStore(std::unique_ptr &store, std::vector> &entries, std::unique_ptr &meta); - void SelectLanguage(); + void SelectLanguage(const std::unique_ptr &store); void ShowCredits(); - std::string SelectDir(const std::string &oldDir, const std::string &msg); + std::string SelectDir(const std::string &oldDir, const std::string &msg, const std::unique_ptr &store); }; #endif \ No newline at end of file diff --git a/include/store/store.hpp b/include/store/store.hpp index 618e11c..ad3e819 100644 --- a/include/store/store.hpp +++ b/include/store/store.hpp @@ -76,10 +76,16 @@ public: nlohmann::json &GetJson() { return this->storeJson; }; bool GetValid() const { return this->valid; }; + + /* Both of these things are used for custom BG support. */ + C2D_Image GetStoreImg() const { return this->storeBG; }; + bool customBG() const { return this->hasCustomBG; }; private: + void SetC2DBGImage(); nlohmann::json storeJson = nullptr; std::vector sheets; - bool valid = false; + C2D_Image storeBG = { nullptr }; + bool valid = false, hasSheet = false, hasCustomBG = false; int screenIndex = 0, entry = 0, box = 0, downEntry = 0, downIndex = 0; }; diff --git a/include/utils/config.hpp b/include/utils/config.hpp index f0a9f08..4f460b2 100644 --- a/include/utils/config.hpp +++ b/include/utils/config.hpp @@ -71,6 +71,10 @@ public: /* U-U Update check on startup. */ bool updatecheck() const { return this->v_updateCheck; }; void updatecheck(bool v) { this->v_updateCheck = v; if (!this->changesMade) this->changesMade = true; }; + + /* U-U Update check on startup. */ + bool usebg() const { return this->v_showBg; }; + void usebg(bool v) { this->v_showBg = v; if (!this->changesMade) this->changesMade = true; }; private: /* Mainly helper. */ bool getBool(const std::string &key); @@ -85,7 +89,7 @@ private: std::string v_language = "en", v_lastStore = "universal-db-beta.unistore", v_3dsxPath = "sdmc:/3ds", v_ndsPath = "sdmc:", v_archivePath = "sdmc:"; - bool v_list = false, v_autoUpdate = true, v_metadata = true, v_updateCheck = true; + bool v_list = false, v_autoUpdate = true, v_metadata = true, v_updateCheck = true, v_showBg = false; }; #endif diff --git a/romfs/lang/en/app.json b/romfs/lang/en/app.json index a998f34..c9eb87e 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -1,17 +1,17 @@ { "ASCENDING": "Ascending", "AUTHOR": "Author", - "AUTO_UPDATE_SETTINGS": "Auto-update Settings", + "AUTO_UPDATE_SETTINGS": "Auto-Update Settings", "AUTO_UPDATE_SETTINGS_BTN": "Auto-update settings...", "AUTO_UPDATE_UNISTORE": "Auto-update UniStores", "AUTO_UPDATE_UNISTORE_DESC": "With this, the last used UniStore will be updated automatically when launching Universal-Updater.", "AUTO_UPDATE_UU": "Auto-update Universal-Updater", "AUTO_UPDATE_UU_DESC": "When enabled, Universal-Updater will check for updates every time it's opened.", + "AVAILABLE_DOWNLOADS": "Available Downloads", "BOOT_TITLE": "Would you like to boot this title?", "CATEGORY": "Category", "CHANGE_3DSX_PATH": "Change 3DSX path", "CHANGE_ARCHIVE_PATH": "Change archive path", - "CHANGE_DIRECTORIES": "Change directories...", "CHANGE_NDS_PATH": "Change NDS path", "CHECK_UNISTORE_UPDATES": "Checking for UniStore updates...", "CHECK_UU_UPDATES": "Checking for Universal-Updater updates...", @@ -28,6 +28,8 @@ "DELETE_UNNEEDED_FILE": "Deleting unneeded file...", "DESCENDING": "Descending", "DIRECTION": "Direction", + "DIRECTORY_SETTINGS": "Directory Settings", + "DIRECTORY_SETTINGS_BTN": "Directory settings...", "DISABLE_AUTOUPDATE_UNISTORE": "Disable auto-update UniStore on boot", "DISABLE_UPDATE_CHECK": "Disable self-updating", "DONE": "Done!", @@ -52,6 +54,8 @@ "FILTER_TO": "Filter to:", "GITHUB": "Full credits can be found on GitHub", "GRID": "Grid", + "GUI_SETTINGS": "GUI Settings", + "GUI_SETTINGS_BTN": "GUI settings...", "INCLUDE_IN_RESULTS": "Include in results:", "INSTALL_UNIVERSAL_UPDATER": "Installing Universal-Updater...", "INVALID_UNISTORE": "Invalid UniStore", @@ -69,16 +73,21 @@ "NO_LICENSE": "No License", "NOT_IMPLEMENTED": "Not Implemented Yet", "REVISION": "Revision", + "SEARCH_FILTERS": "Search and Filters", "SELECT_DIR": "Select a directory", "SELECT_LANG": "Choose the language", "SELECT_UNISTORE": "Select UniStore", "SELECT_UNISTORE_2": "Select a UniStore", + "SETTINGS": "Settings", "SHEET_SLASH": "Seems like a '/' is included, which is not supported.\nPlease change 'sheet' to filename only.", "SORT_BY": "Sort By", + "SORTING": "Sorting", "START_SELECT": "Press START to select the current folder", "SYNTAX_ERROR": "Syntax Error!", "TITLE": "Title", "TOP_STYLE": "Top Style", + "UNISTORE_BG": "Use UniStore BG", + "UNISTORE_BG_DESC": "When enabled, the UniStore's provided BG will be shown instead of the solid BG color for the top screen.", "UNISTORE_INVALID_ERROR": "This UniStore is invalid and cannot be\nloaded with Universal-Updater.\nMaybe check if there are any Syntax errors?", "UNISTORE_TOO_NEW": "Your version of Universal-Updater is\ntoo old to use this UniStore.\nPlease update to the latest version.", "UNISTORE_TOO_OLD": "This UniStore is outdated and cannot be used\nwith this version of Universal-Updater.\nPlease ask the creator to update it.", diff --git a/source/gui/gfx.cpp b/source/gui/gfx.cpp index 8a709a4..09d87eb 100644 --- a/source/gui/gfx.cpp +++ b/source/gui/gfx.cpp @@ -33,7 +33,7 @@ void GFX::DrawTop(void) { Gui::ScreenDraw(Top); Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR); - Gui::Draw_Rect(0, 25, 400, 215, BG_COLOR); + Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR); Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR); } diff --git a/source/keyboard.cpp b/source/keyboard.cpp index 486f7d0..ea234cf 100644 --- a/source/keyboard.cpp +++ b/source/keyboard.cpp @@ -28,22 +28,42 @@ #include "keyboard.hpp" #include "screenCommon.hpp" +static std::vector words; + /* Return a string of the keyboard. - const uint &maxLength: Const Reference to the max length. + uint maxLength: The max length. const std::string &Text: Const Reference to the Text. + const std::vector> &entries: Const Reference of all entries for the words to suggest. */ -std::string Input::setkbdString(const uint &maxLength, const std::string &Text) { +std::string Input::setkbdString(uint maxLength, const std::string &Text, const std::vector> &entries) { C3D_FrameEnd(0); // Needed, so the system will not freeze. SwkbdState state; swkbdInit(&state, SWKBD_TYPE_NORMAL, 2, maxLength); - char temp[maxLength] = { 0 }; + char temp[maxLength + 1] = { 0 }; swkbdSetHintText(&state, Text.c_str()); swkbdSetValidation(&state, SWKBD_NOTBLANK_NOTEMPTY, SWKBD_FILTER_PROFANITY, 0); + + if (entries.size()) { + words.clear(); + words.resize(entries.size()); + + for (uint i = 0; i < entries.size(); i++) { + /* Checking for not nullptr. */ + if (entries[i]) swkbdSetDictWord(&words[i], StringUtils::lower_case(entries[i]->GetTitle()).c_str(), entries[i]->GetTitle().c_str()); + else swkbdSetDictWord(&words[i], "", ""); + } + + if (words.size() > 0) { + swkbdSetDictionary(&state, words.data(), entries.size()); + swkbdSetFeatures(&state, SWKBD_PREDICTIVE_INPUT); + } + } + SwkbdButton ret = swkbdInputText(&state, temp, maxLength); - temp[maxLength - 1] = '\0'; + temp[maxLength] = '\0'; return (ret == SWKBD_BUTTON_CONFIRM ? temp : ""); } \ No newline at end of file diff --git a/source/overlays/credits.cpp b/source/overlays/credits.cpp index 4fcb4ed..691fda7 100644 --- a/source/overlays/credits.cpp +++ b/source/overlays/credits.cpp @@ -53,7 +53,7 @@ void Overlays::ShowCredits() { Gui::Draw_Rect(0, 215, 400, 25, BAR_COLOR); Gui::Draw_Rect(0, 214, 400, 1, BAR_OUTL_COLOR); - Gui::DrawStringCentered(0, 217, 0.6f, TEXT_COLOR, Lang::get("CURRENT_VERSION") + std::string(V_STRING), 390); + Gui::DrawStringCentered(0, 218, 0.6f, TEXT_COLOR, Lang::get("CURRENT_VERSION") + std::string(V_STRING), 390); GFX::DrawBottom(); GFX::DrawSprite(sprites_universal_core_idx, 0, 26); diff --git a/source/overlays/dirSelect.cpp b/source/overlays/dirSelect.cpp index 83e119b..1e0d471 100644 --- a/source/overlays/dirSelect.cpp +++ b/source/overlays/dirSelect.cpp @@ -42,7 +42,7 @@ static const std::vector mainButtons = { /* Select a Directory. */ -std::string Overlays::SelectDir(const std::string &oldDir, const std::string &msg) { +std::string Overlays::SelectDir(const std::string &oldDir, const std::string &msg, const std::unique_ptr &store) { std::string currentPath = oldDir; bool dirChanged = true; int selection = 0, sPos = 0; @@ -68,7 +68,16 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms C2D_TargetClear(Top, TRANSPARENT); C2D_TargetClear(Bottom, TRANSPARENT); - GFX::DrawTop(); + if (store && config->usebg() && store->customBG()) { + Gui::ScreenDraw(Top); + Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR); + Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR); + C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr); + + } else { + GFX::DrawTop(); + } + Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, msg, 380); Gui::Draw_Rect(0, 215, 400, 25, BAR_COLOR); @@ -142,7 +151,7 @@ std::string Overlays::SelectDir(const std::string &oldDir, const std::string &ms } if (hidKeysDown() & KEY_TOUCH) { - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 7; i++) { if (touching(touch, mainButtons[i])) { if (i + sPos < (int)dirContents.size()) { if (dirContents[i + sPos].isDirectory) { diff --git a/source/overlays/langSelect.cpp b/source/overlays/langSelect.cpp index 5479da2..2987648 100644 --- a/source/overlays/langSelect.cpp +++ b/source/overlays/langSelect.cpp @@ -51,7 +51,7 @@ static const std::vector mainButtons = { Can be skipped with `B`. */ -void Overlays::SelectLanguage() { +void Overlays::SelectLanguage(const std::unique_ptr &store) { bool doOut = false; int selection = 0, sPos = 0; @@ -61,7 +61,16 @@ void Overlays::SelectLanguage() { C2D_TargetClear(Top, TRANSPARENT); C2D_TargetClear(Bottom, TRANSPARENT); - GFX::DrawTop(); + if (store && config->usebg() && store->customBG()) { + Gui::ScreenDraw(Top); + Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR); + Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR); + C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr); + + } else { + GFX::DrawTop(); + } + Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("SELECT_LANG")); GFX::DrawBottom(); diff --git a/source/overlays/storeSelect.cpp b/source/overlays/storeSelect.cpp index b6f3df6..6207e48 100644 --- a/source/overlays/storeSelect.cpp +++ b/source/overlays/storeSelect.cpp @@ -104,7 +104,7 @@ static bool DownloadStore(bool Cam = true) { bool doSheet = false; std::string file = ""; - const std::string URL = Cam ? QR_Scanner::GetQRURL() : Input::setkbdString(150, Lang::get("ENTER_URL")); + const std::string URL = Cam ? QR_Scanner::GetQRURL() : Input::setkbdString(150, Lang::get("ENTER_URL"), { }); if (URL != "") doSheet = DownloadUniStore(URL, -1, file, true); if (doSheet) { @@ -178,7 +178,16 @@ void Overlays::SelectStore(std::unique_ptr &store, std::vectorusebg() && store->customBG()) { + Gui::ScreenDraw(Top); + Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR); + Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR); + C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr); + + } else { + GFX::DrawTop(); + } + Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("SELECT_UNISTORE_2"), 390); if (info.size() > 0) { diff --git a/source/screens/mainScreen.cpp b/source/screens/mainScreen.cpp index 761e557..46f195c 100644 --- a/source/screens/mainScreen.cpp +++ b/source/screens/mainScreen.cpp @@ -84,7 +84,10 @@ MainScreen::MainScreen() { MainScreen Main Draw. */ void MainScreen::Draw(void) const { - GFX::DrawTop(); + Gui::ScreenDraw(Top); + Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR); + Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTL_COLOR); + if (this->store && this->store->GetValid()) Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, this->store->GetUniStoreTitle(), 370); else Gui::DrawStringCentered(0, 1, 0.7f, TEXT_COLOR, Lang::get("INVALID_UNISTORE"), 370); config->list() ? StoreUtils::DrawList(this->store, this->entries) : StoreUtils::DrawGrid(this->store, this->entries); diff --git a/source/store/downList.cpp b/source/store/downList.cpp index 7aa4619..b02d76e 100644 --- a/source/store/downList.cpp +++ b/source/store/downList.cpp @@ -28,17 +28,16 @@ #include "storeUtils.hpp" #include "structs.hpp" -#define DOWNLOAD_ENTRIES 8 +#define DOWNLOAD_ENTRIES 7 extern bool touching(touchPosition touch, Structs::ButtonPos button); static const std::vector downloadBoxes = { - { 54, 4, 262, 22 }, - { 54, 34, 262, 22 }, - { 54, 64, 262, 22 }, - { 54, 94, 262, 22 }, - { 54, 124, 262, 22 }, - { 54, 154, 262, 22 }, - { 54, 184, 262, 22 }, - { 54, 214, 262, 22 } + { 54, 32, 262, 22 }, + { 54, 62, 262, 22 }, + { 54, 92, 262, 22 }, + { 54, 122, 262, 22 }, + { 54, 152, 262, 22 }, + { 54, 182, 262, 22 }, + { 54, 212, 262, 22 } }; /* @@ -50,6 +49,10 @@ static const std::vector downloadBoxes = { */ void StoreUtils::DrawDownList(const std::unique_ptr &store, const std::vector &entries, const 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); + 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); @@ -57,7 +60,7 @@ void StoreUtils::DrawDownList(const std::unique_ptr &store, const std::ve } } else { // If no downloads available.. - Gui::DrawStringCentered(25, downloadBoxes[0].y + 4, 0.5f, TEXT_COLOR, Lang::get("NO_DOWNLOADS_AVAILABLE"), 255); + Gui::DrawStringCentered(54 - 160 + (262 / 2), downloadBoxes[0].y + 4, 0.5f, TEXT_COLOR, Lang::get("NO_DOWNLOADS_AVAILABLE"), 255); } } } diff --git a/source/store/grid.cpp b/source/store/grid.cpp index 1ab02c9..7506863 100644 --- a/source/store/grid.cpp +++ b/source/store/grid.cpp @@ -55,6 +55,14 @@ static const std::vector GridBoxes = { */ void StoreUtils::DrawGrid(const std::unique_ptr &store, const std::vector> &entries) { if (store) { // Ensure, store is not a nullptr. + + if (config->usebg() && store->customBG()) { + C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr); + + } else { + Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR); + } + for (int i = 0, i2 = 0 + (store->GetScreenIndx() * 5); i2 < 15 + (store->GetScreenIndx() * 5) && i2 < (int)entries.size(); i2++, i++) { /* Boxes. */ diff --git a/source/store/list.cpp b/source/store/list.cpp index f50f7f0..453f4da 100644 --- a/source/store/list.cpp +++ b/source/store/list.cpp @@ -41,6 +41,14 @@ static const std::vector StoreBoxesList = { */ void StoreUtils::DrawList(const std::unique_ptr &store, const std::vector> &entries) { if (store) { // Ensure, store is not a nullptr. + + if (config->usebg() && store->customBG()) { + C2D_DrawImageAt(store->GetStoreImg(), 0, 26, 0.5f, nullptr); + + } else { + Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR); + } + if (entries.size() > 0) { for (int i = 0; i < 3 && i < (int)entries.size(); i++) { diff --git a/source/store/searchMenu.cpp b/source/store/searchMenu.cpp index 6ea8001..f9c2b00 100644 --- a/source/store/searchMenu.cpp +++ b/source/store/searchMenu.cpp @@ -30,21 +30,21 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button); static const std::vector SearchMenu = { - { 55, 5, 258, 30 }, // Search bar. + { 55, 45, 258, 30 }, // Search bar. /* Includes. */ - { 85, 84, 10, 10 }, - { 85, 100, 10, 10 }, - { 167, 84, 10, 10 }, - { 167, 100, 10, 10 }, + { 85, 109, 50, 10 }, + { 85, 125, 50, 10 }, + { 167, 109, 50, 10 }, + { 167, 125, 50, 10 }, /* Filters. */ - { 82, 170, 30, 30 }, - { 117, 170, 30, 30 }, - { 152, 170, 30, 30 }, - { 187, 170, 30, 30 }, - { 222, 170, 30, 30 }, - { 257, 170, 30, 30 } + { 82, 195, 30, 30 }, + { 117, 195, 30, 30 }, + { 152, 195, 30, 30 }, + { 187, 195, 30, 30 }, + { 222, 195, 30, 30 }, + { 257, 195, 30, 30 } }; /* @@ -56,17 +56,21 @@ static const std::vector SearchMenu = { const bool &updateFilter: Const Reference to the update filter. */ void StoreUtils::DrawSearchMenu(const std::vector &searchIncludes, const std::string &searchResult, const int &marks, const bool &updateFilter) { - Gui::Draw_Rect(54, 4, 260, SearchMenu[0].h + 2, SEARCH_BAR_OUTL_COLOR); + 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("SEARCH_FILTERS"), 265); + + Gui::Draw_Rect(54, 44, 260, SearchMenu[0].h + 2, SEARCH_BAR_OUTL_COLOR); Gui::Draw_Rect(SearchMenu[0].x, SearchMenu[0].y, SearchMenu[0].w, SearchMenu[0].h, SEARCH_BAR_COLOR); - Gui::DrawStringCentered(28, 10, 0.6, TEXT_COLOR, searchResult, 265); + Gui::DrawStringCentered(28, 50, 0.6, TEXT_COLOR, searchResult, 265); /* Checkboxes. */ for (int i = 0; i < 4; i++) { GFX::DrawCheckbox(SearchMenu[i + 1].x, SearchMenu[i + 1].y, searchIncludes[i]); } - Gui::DrawString(84, 60, 0.5, TEXT_COLOR, Lang::get("INCLUDE_IN_RESULTS"), 265); + Gui::DrawString(84, 85, 0.5, TEXT_COLOR, Lang::get("INCLUDE_IN_RESULTS"), 265); Gui::DrawString(SearchMenu[1].x + 18, SearchMenu[1].y + 1, 0.4, TEXT_COLOR, Lang::get("TITLE"), 90); Gui::DrawString(SearchMenu[2].x + 18, SearchMenu[2].y + 1, 0.4, TEXT_COLOR, Lang::get("AUTHOR"), 90); @@ -75,7 +79,7 @@ void StoreUtils::DrawSearchMenu(const std::vector &searchIncludes, const s Gui::DrawString(SearchMenu[4].x + 18, SearchMenu[4].y + 1, 0.4, TEXT_COLOR, Lang::get("CONSOLE"), 90); /* Filters. */ - Gui::DrawString(84, 150, 0.5f, TEXT_COLOR, Lang::get("FILTER_TO"), 265); + Gui::DrawString(84, 175, 0.5f, TEXT_COLOR, Lang::get("FILTER_TO"), 265); Gui::Draw_Rect(SearchMenu[5].x, SearchMenu[5].y, SearchMenu[5].w, SearchMenu[5].h, (marks & favoriteMarks::STAR ? SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); @@ -139,8 +143,14 @@ void StoreUtils::SearchHandle(u32 hDown, u32 hHeld, touchPosition touch, std::un /* Search bar. */ if (!didTouch) { if (touching(touch, SearchMenu[0])) { - searchResult = Input::setkbdString(20, Lang::get("ENTER_SEARCH")); - didTouch = true; + if (store) { + searchResult = Input::setkbdString(20, Lang::get("ENTER_SEARCH"), {}); + didTouch = true; + + } else { + searchResult = Input::setkbdString(20, Lang::get("ENTER_SEARCH"), {}); + didTouch = true; + } } } diff --git a/source/store/settings.cpp b/source/store/settings.cpp index fa1a338..21ada80 100644 --- a/source/store/settings.cpp +++ b/source/store/settings.cpp @@ -30,13 +30,13 @@ extern bool exiting; extern bool touching(touchPosition touch, Structs::ButtonPos button); static const std::vector mainButtons = { - { 54, 4, 262, 22 }, - { 54, 34, 262, 22 }, - { 54, 64, 262, 22 }, - { 54, 94, 262, 22 }, - { 54, 124, 262, 22 }, - { 54, 154, 262, 22 }, - { 54, 184, 262, 22 } + { 54, 32, 262, 22 }, + { 54, 62, 262, 22 }, + { 54, 92, 262, 22 }, + { 54, 122, 262, 22 }, + { 54, 152, 262, 22 }, + { 54, 182, 262, 22 }, + { 54, 212, 262, 22 } }; static const std::vector toggleAbles = { @@ -45,8 +45,10 @@ static const std::vector toggleAbles = { { 288, 140, 24, 24 } }; +static const Structs::ButtonPos back = { 52, 0, 24, 24 }; // Back arrow for directory. -static const std::vector mainStrings = { "LANGUAGE", "SELECT_UNISTORE", "AUTO_UPDATE_SETTINGS_BTN", "CHANGE_DIRECTORIES", "CREDITS", "EXIT_APP" }; + +static const std::vector mainStrings = { "LANGUAGE", "SELECT_UNISTORE", "AUTO_UPDATE_SETTINGS_BTN", "GUI_SETTINGS_BTN", "DIRECTORY_SETTINGS_BTN", "CREDITS", "EXIT_APP" }; static const std::vector dirStrings = { "CHANGE_3DSX_PATH", "CHANGE_NDS_PATH", "CHANGE_ARCHIVE_PATH" }; /* @@ -55,7 +57,11 @@ static const std::vector dirStrings = { "CHANGE_3DSX_PATH", "CHANGE const int &selection: Const Reference to the Settings Selection. */ static void DrawSettingsMain(const int &selection) { - for (int i = 0; i < 6; i++) { + 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("SETTINGS"), 265); + + for (int i = 0; i < 7; i++) { if (i == selection) GFX::DrawBox(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, false); Gui::DrawStringCentered(30, mainButtons[i].y + 4, 0.45f, TEXT_COLOR, Lang::get(mainStrings[i]), 255); } @@ -67,6 +73,11 @@ static void DrawSettingsMain(const int &selection) { const int &selection: Const Reference to the Settings Selection. */ static void DrawSettingsDir(const int &selection) { + Gui::Draw_Rect(48, 0, 272, 25, ENTRY_BAR_COLOR); + Gui::Draw_Rect(48, 25, 272, 1, ENTRY_BAR_OUTL_COLOR); + GFX::DrawSprite(sprites_arrow_idx, back.x, back.y); + Gui::DrawStringCentered(32, 2, 0.6, TEXT_COLOR, Lang::get("DIRECTORY_SETTINGS"), 240); + for (int i = 0; i < 3; i++) { if (i == selection) GFX::DrawBox(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, false); Gui::DrawStringCentered(30, mainButtons[i].y + 4, 0.45f, TEXT_COLOR, Lang::get(dirStrings[i]), 255); @@ -76,7 +87,7 @@ static void DrawSettingsDir(const int &selection) { /* Draw Auto-Update Settings page. */ -static void DrawAutoUpdate() { +static void DrawAutoUpdate(const int &selection) { Gui::Draw_Rect(48, 0, 272, 36, ENTRY_BAR_COLOR); Gui::Draw_Rect(48, 36, 272, 1, ENTRY_BAR_OUTL_COLOR); GFX::DrawSprite(sprites_arrow_idx, 52, 6); @@ -84,17 +95,30 @@ static void DrawAutoUpdate() { Gui::DrawStringCentered(32, 7, 0.6, TEXT_COLOR, Lang::get("AUTO_UPDATE_SETTINGS"), 240); /* Toggle Boxes. */ - GFX::DrawBox(48, 64, 273, 24, false); + Gui::Draw_Rect(48, 64, 273, 24, (selection == 0 ? SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); Gui::DrawString(55, 68, 0.5f, TEXT_COLOR, Lang::get("AUTO_UPDATE_UNISTORE"), 210); GFX::DrawToggle(288, 64, config->autoupdate()); Gui::DrawString(55, 95, 0.4f, TEXT_COLOR, Lang::get("AUTO_UPDATE_UNISTORE_DESC"), 265, 0, nullptr, C2D_WordWrap); - GFX::DrawBox(48, 140, 273, 24, false); + Gui::Draw_Rect(48, 140, 273, 24, (selection == 1 ? SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); Gui::DrawString(55, 144, 0.5f, TEXT_COLOR, Lang::get("AUTO_UPDATE_UU"), 210); GFX::DrawToggle(288, 140, config->updatecheck()); Gui::DrawString(55, 171, 0.4f, TEXT_COLOR, Lang::get("AUTO_UPDATE_UU_DESC"), 265, 0, nullptr, C2D_WordWrap); } +static void DrawGUISettings(const int &selection) { + Gui::Draw_Rect(48, 0, 272, 36, ENTRY_BAR_COLOR); + Gui::Draw_Rect(48, 36, 272, 1, ENTRY_BAR_OUTL_COLOR); + GFX::DrawSprite(sprites_arrow_idx, 52, 6); + + Gui::DrawStringCentered(32, 7, 0.6, TEXT_COLOR, Lang::get("GUI_SETTINGS"), 240); + + Gui::Draw_Rect(48, 64, 273, 24, (selection == 0 ? SIDEBAR_UNSELECTED_COLOR : BOX_INSIDE_COLOR)); + Gui::DrawString(55, 68, 0.5f, TEXT_COLOR, Lang::get("UNISTORE_BG"), 210); + GFX::DrawToggle(288, 64, config->usebg()); + Gui::DrawString(55, 95, 0.4f, TEXT_COLOR, Lang::get("UNISTORE_BG_DESC"), 265, 0, nullptr, C2D_WordWrap); +} + /* Settings Main Handle. @@ -124,7 +148,7 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p } if (hRepeat & KEY_DOWN) { - if (selection < 5) selection++; + if (selection < 6) selection++; else selection = 0; } @@ -145,7 +169,7 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p if (hDown & KEY_TOUCH) { if (touching(touch, mainButtons[0])) { - Overlays::SelectLanguage(); + Overlays::SelectLanguage(store); } else if (touching(touch, mainButtons[1])) { Overlays::SelectStore(store, entries, meta); @@ -155,13 +179,17 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p page = 2; } else if (touching(touch, mainButtons[3])) { + selection = 0; + page = 3; + + } else if (touching(touch, mainButtons[4])) { selection = 0; page = 1; - } else if (touching(touch, mainButtons[4])) { + } else if (touching(touch, mainButtons[5])) { Overlays::ShowCredits(); - } else if (touching(touch, mainButtons[5])) { + } else if (touching(touch, mainButtons[6])) { exiting = true; } } @@ -169,7 +197,7 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p if (hDown & KEY_A) { switch(selection) { case 0: - Overlays::SelectLanguage(); + Overlays::SelectLanguage(store); break; case 1: @@ -183,14 +211,19 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p case 3: selection = 0; - page = 1; + page = 3; break; case 4: - Overlays::ShowCredits(); + selection = 0; + page = 1; break; case 5: + Overlays::ShowCredits(); + break; + + case 6: exiting = true; break; } @@ -210,10 +243,10 @@ static void SettingsHandleMain(u32 hDown, u32 hHeld, touchPosition touch, int &p int &page: Reference to the page. int &selection: Reference to the Selection. */ -static void SettingsHandleDir(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection) { +static void SettingsHandleDir(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection, const std::unique_ptr &store) { if (hDown & KEY_B) { page = 0; - selection = 3; + selection = 4; } if (hRepeat & KEY_DOWN) { @@ -237,16 +270,20 @@ static void SettingsHandleDir(u32 hDown, u32 hHeld, touchPosition touch, int &pa } if (hDown & KEY_TOUCH) { - if (touching(touch, mainButtons[0])) { - const std::string path = Overlays::SelectDir(config->_3dsxPath(), Lang::get("SELECT_DIR")); + if (touching(touch, back)) { + page = 0; + selection = 4; + + } else if (touching(touch, mainButtons[0])) { + const std::string path = Overlays::SelectDir(config->_3dsxPath(), Lang::get("SELECT_DIR"), store); if (path != "") config->_3dsxPath(path); } else if (touching(touch, mainButtons[1])) { - const std::string path = Overlays::SelectDir(config->ndsPath(), Lang::get("SELECT_DIR")); + const std::string path = Overlays::SelectDir(config->ndsPath(), Lang::get("SELECT_DIR"), store); if (path != "") config->ndsPath(path); } else if (touching(touch, mainButtons[2])) { - const std::string path = Overlays::SelectDir(config->archPath(), Lang::get("SELECT_DIR")); + const std::string path = Overlays::SelectDir(config->archPath(), Lang::get("SELECT_DIR"), store); if (path != "") config->archPath(path); } } @@ -256,29 +293,37 @@ static void SettingsHandleDir(u32 hDown, u32 hHeld, touchPosition touch, int &pa switch(selection) { case 0: - path = Overlays::SelectDir(config->_3dsxPath(), Lang::get("SELECT_DIR")); + path = Overlays::SelectDir(config->_3dsxPath(), Lang::get("SELECT_DIR"), store); if (path != "") config->_3dsxPath(path); break; case 1: - path = Overlays::SelectDir(config->ndsPath(), Lang::get("SELECT_DIR")); + path = Overlays::SelectDir(config->ndsPath(), Lang::get("SELECT_DIR"), store); if (path != "") config->ndsPath(path); break; case 2: - path = Overlays::SelectDir(config->archPath(), Lang::get("SELECT_DIR")); + path = Overlays::SelectDir(config->archPath(), Lang::get("SELECT_DIR"), store); if (path != "") config->archPath(path); break; } } } -static void SettingsToggleLogic(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection) { +static void AutoUpdateLogic(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection) { if (hDown & KEY_B) { page = 0; selection = 2; } + if (hRepeat & KEY_DOWN) { + if (selection < 1) selection++; + } + + if (hRepeat & KEY_UP) { + if (selection > 0) selection--; + } + if (hDown & KEY_TOUCH) { if (touching(touch, toggleAbles[0])) { page = 0; @@ -291,6 +336,43 @@ static void SettingsToggleLogic(u32 hDown, u32 hHeld, touchPosition touch, int & config->updatecheck(!config->updatecheck()); } } + + if (hDown & KEY_A) { + switch(selection) { + case 0: + config->autoupdate(!config->autoupdate()); + break; + + case 1: + config->updatecheck(!config->updatecheck()); + break; + } + } +} + +static void GUISettingsLogic(u32 hDown, u32 hHeld, touchPosition touch, int &page, int &selection, const std::unique_ptr &store) { + if (hDown & KEY_B) { + page = 0; + selection = 3; + } + + if (hDown & KEY_TOUCH) { + if (touching(touch, toggleAbles[0])) { + page = 0; + selection = 3; + + } else if (touching(touch, toggleAbles[1])) { + config->usebg(!config->usebg()); + } + } + + if (hDown & KEY_A) { + switch(selection) { + case 0: + config->usebg(!config->usebg()); + break; + } + } } /* @@ -310,7 +392,11 @@ void StoreUtils::DrawSettings(const int &page, const int &selection) { break; case 2: - DrawAutoUpdate(); + DrawAutoUpdate(selection); + break; + + case 3: + DrawGUISettings(selection); break; } } @@ -336,11 +422,15 @@ void StoreUtils::SettingsHandle(u32 hDown, u32 hHeld, touchPosition touch, int & break; case 1: - SettingsHandleDir(hDown, hHeld, touch, page, selection); + SettingsHandleDir(hDown, hHeld, touch, page, selection, store); break; case 2: - SettingsToggleLogic(hDown, hHeld, touch, page, selection); + AutoUpdateLogic(hDown, hHeld, touch, page, selection); + break; + + case 3: + GUISettingsLogic(hDown, hHeld, touch, page, selection, store); break; } } \ No newline at end of file diff --git a/source/store/sortMenu.cpp b/source/store/sortMenu.cpp index e613811..871e482 100644 --- a/source/store/sortMenu.cpp +++ b/source/store/sortMenu.cpp @@ -31,15 +31,15 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button); static const std::vector buttons = { - { 75, 50, 100, 16 }, - { 75, 70, 100, 16 }, - { 75, 90, 100, 16 }, + { 75, 60, 100, 16 }, + { 75, 80, 100, 16 }, + { 75, 100, 100, 16 }, - { 205, 50, 100, 16 }, - { 205, 70, 100, 16 }, + { 205, 60, 100, 16 }, + { 205, 80, 100, 16 }, - { 75, 160, 100, 16 }, - { 75, 180, 100, 16 } + { 75, 170, 100, 16 }, + { 75, 190, 100, 16 } }; static void DrawCheck(int pos, bool v) { @@ -73,6 +73,10 @@ static const uint8_t GetType(const SortType &st) { const SortType &st: Const Reference to the SortType variable. */ void StoreUtils::DrawSorting(const bool &asc, const SortType &st) { + 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("SORTING"), 265); + /* Sort By. */ Gui::DrawString(buttons[0].x + 5, buttons[0].y - 20, 0.6f, TEXT_COLOR, Lang::get("SORT_BY"), 90); for (int i = 0; i < 3; i++) { diff --git a/source/store/store.cpp b/source/store/store.cpp index 3da4d9a..78a166d 100644 --- a/source/store/store.cpp +++ b/source/store/store.cpp @@ -40,7 +40,10 @@ static bool firstStart = true; const std::string &file: The UniStore file. */ -Store::Store(const std::string &file) { this->update(file); }; +Store::Store(const std::string &file) { + this->update(file); + this->SetC2DBGImage(); +}; /* Update an UniStore,, including SpriteSheet, if revision increased. @@ -409,6 +412,37 @@ C2D_Image Store::GetIconEntry(const int &index) const { return C2D_SpriteSheetGetImage(sprites, sprites_noIcon_idx); } +/* + Set's the custom BG to the storeBG variable. +*/ +void Store::SetC2DBGImage() { + if (!this->valid) return; + if (this->sheets.empty()) return; + int index = -1, sheetIndex = -1; + + if (this->storeJson["storeInfo"].contains("bg_index") && this->storeJson["storeInfo"]["bg_index"].is_number()) { + index = this->storeJson["storeInfo"]["bg_index"]; + } + + if (this->storeJson["storeInfo"].contains("bg_sheet") && this->storeJson["storeInfo"]["bg_sheet"].is_number()) { + sheetIndex = this->storeJson["storeInfo"]["bg_sheet"]; + } + + if (index == -1 || sheetIndex == -1) return; + + if (sheetIndex > (int)this->sheets.size()) return; + if (!this->sheets[sheetIndex]) return; + + if (index > (int)C2D_SpriteSheetCount(this->sheets[sheetIndex])-1) return; + + C2D_Image temp = C2D_SpriteSheetGetImage(this->sheets[sheetIndex], index); + + if (temp.subtex->width == 400 && temp.subtex->height == 214) { + this->hasCustomBG = true; + this->storeBG = temp; // Must be 400x214. + } +} + /* Return the download list of an entry. diff --git a/source/utils/config.cpp b/source/utils/config.cpp index 0412caa..e41dcf9 100644 --- a/source/utils/config.cpp +++ b/source/utils/config.cpp @@ -122,6 +122,7 @@ Config::Config() { if (this->json.contains("Archive_Path")) this->archPath(this->getString("Archive_Path")); if (this->json.contains("MetaData")) this->metadata(this->getBool("MetaData")); if (this->json.contains("UpdateCheck")) this->updatecheck(this->getBool("UpdateCheck")); + if (this->json.contains("UseBG")) this->usebg(this->getBool("UseBG")); this->changesMade = false; // No changes made yet. } @@ -142,6 +143,7 @@ void Config::save() { this->setString("Archive_Path", this->archPath()); this->setBool("MetaData", this->metadata()); this->setBool("UpdateCheck", this->updatecheck()); + this->setBool("UseBG", this->usebg()); /* Write changes to file. */ const std::string dump = this->json.dump(1, '\t');