From 6163891c63bbd821407bcd2bf80518a84d0d455f Mon Sep 17 00:00:00 2001 From: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Fri, 19 Jun 2020 15:52:20 +0200 Subject: [PATCH] Do search & reset to dropdown menu. --- include/screens/unistore_v2.hpp | 4 +- romfs/lang/en/app.json | 5 +- source/screens/unistore.cpp | 6 +- source/screens/unistore_v2.cpp | 98 +++++++++++++++++++++------------ 4 files changed, 73 insertions(+), 40 deletions(-) diff --git a/include/screens/unistore_v2.hpp b/include/screens/unistore_v2.hpp index 493382d..bcb5bef 100644 --- a/include/screens/unistore_v2.hpp +++ b/include/screens/unistore_v2.hpp @@ -106,7 +106,9 @@ private: const std::vector dropPos = { {5, 30, 140, 25}, // Theme. - {5, 70, 140, 25} // Style. + {5, 70, 140, 25}, // Style. + {5, 110, 140, 25},// Search. + {5, 150, 140, 25} // Reset. }; const std::vector sortingPos = { diff --git a/romfs/lang/en/app.json b/romfs/lang/en/app.json index 4721b47..f6511c4 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -195,5 +195,8 @@ "AUTHOR_BTN": "Author", "LAST_UPDATED_BTN": "Last updated", "ENTER_SEARCH": "Enter what you like to search.", - "NO_RESULTS_FOUND": "No results found!" + "NO_RESULTS_FOUND": "No results found!", + "SEARCH": "Search Entry", + "INVALID_INPUT": "Invalid input!", + "RESET": "Reset" } diff --git a/source/screens/unistore.cpp b/source/screens/unistore.cpp index 74a6ad8..b003664 100644 --- a/source/screens/unistore.cpp +++ b/source/screens/unistore.cpp @@ -754,7 +754,7 @@ void UniStore::SearchLogic(u32 hDown, u32 hHeld, touchPosition touch) { } else if (Selection == 2) { ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", Config::StorePath + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB"); } else if (Selection == 3) { - ScriptHelper::downloadFile("https://github.com/Universal-Team/db/raw/master/unistore/universal-db.unistore", Config::StorePath + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB"); + ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", Config::StorePath + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB"); } } @@ -766,8 +766,8 @@ void UniStore::SearchLogic(u32 hDown, u32 hHeld, touchPosition touch) { mode = 4; } else if (hDown & KEY_TOUCH && touching(touch, URLBtn[2])) { ScriptHelper::downloadFile("https://tinydb.eiphax.tech/api/tinydb.unistore", Config::StorePath + "TinyDB.unistore", Lang::get("DOWNLOADING") + "TinyDB"); - } else if (hDown & KEY_TOUCH & touching(touch, URLBtn[3])) { - ScriptHelper::downloadFile("https://github.com/Universal-Team/db/raw/master/unistore/universal-db.unistore", Config::StorePath + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB"); + } else if (hDown & KEY_TOUCH && touching(touch, URLBtn[3])) { + ScriptHelper::downloadFile("https://db.universal-team.net/unistore/universal-db.unistore", Config::StorePath + "Universal-DB.unistore", Lang::get("DOWNLOADING") + "Universal DB"); } } diff --git a/source/screens/unistore_v2.cpp b/source/screens/unistore_v2.cpp index 034f911..7fa369b 100644 --- a/source/screens/unistore_v2.cpp +++ b/source/screens/unistore_v2.cpp @@ -233,9 +233,9 @@ void UniStoreV2::DropDownMenu(void) const { // DropDown Menu. if (this->isDropDown) { // Draw Operation Box. - Gui::Draw_Rect(5, 25, 140, 60, this->darkMode ? this->barColorDark : this->barColorLight); + Gui::Draw_Rect(5, 25, 140, 140, this->darkMode ? this->barColorDark : this->barColorLight); - for (int i = 0; i < 2; i++) { + for (int i = 0; i < 4; i++) { Gui::Draw_Rect(dropPos[i].x, dropPos[i].y, dropPos[i].w, dropPos[i].h, this->darkMode ? this->boxColorDark : this->boxColorLight); } @@ -244,10 +244,14 @@ void UniStoreV2::DropDownMenu(void) const { // Draw Dropdown Icons. //GFX::DrawSpriteBlend(sprites_theme_idx, this->dropPos[0].x, this->dropPos[0].y); // Theme Icon instead. //GFX::DrawSpriteBlend(sprites_style_idx, this->dropPos[1].x, this->dropPos[1].y); // Style Icon instead. + GFX::DrawSpriteBlend(sprites_search_idx, this->dropPos[2].x, this->dropPos[2].y); + //GFX::DrawSpriteBlend(sprites_search_idx, this->dropPos[3].x, this->dropPos[3].y); // Reset Icon instead. // Dropdown Text. Gui::DrawString(this->dropPos[0].x+30, this->dropPos[0].y+5, 0.4f, this->returnTextColor(), Lang::get("CHANGE_THEME"), 100); Gui::DrawString(this->dropPos[1].x+30, this->dropPos[1].y+5, 0.4f, this->returnTextColor(), Lang::get("CHANGE_STYLE"), 100); + Gui::DrawString(this->dropPos[2].x+30, this->dropPos[2].y+5, 0.4f, this->returnTextColor(), Lang::get("SEARCH"), 100); + Gui::DrawString(this->dropPos[3].x+30, this->dropPos[3].y+5, 0.4f, this->returnTextColor(), Lang::get("RESET"), 100); } } } @@ -379,6 +383,8 @@ void UniStoreV2::DropLogic(u32 hDown, u32 hHeld, touchPosition touch) { } if (hDown & KEY_A) { + std::string temp; + int amount; switch(this->dropSelection) { case 0: if (this->darkMode) this->darkMode = false; @@ -388,7 +394,34 @@ void UniStoreV2::DropLogic(u32 hDown, u32 hHeld, touchPosition touch) { if (this->mode == 0) this->mode = 1; else this->mode = 0; break; - } + case 2: + temp = Input::getStringLong(Lang::get("ENTER_SEARCH")); + if (temp != "") { + if (this->mode == 0) { + this->selectedBox = 0; + this->storePage = 0; + } else if (this->mode == 1) { + this->selectedBoxList = 0; + this->storePageList = 0; + } + amount = this->sortedStore->searchForEntries(temp); + if (amount == 0) Msg::DisplayWarnMsg(Lang::get("NO_RESULTS_FOUND")); + } else { + Msg::DisplayWarnMsg(Lang::get("INVALID_INPUT")); + } + break; + case 3: + if (this->mode == 0) { + this->selectedBox = 0; + this->storePage = 0; + this->sortedStore->reset(); + } else if (this->mode == 1) { + this->selectedBoxList = 0; + this->storePageList = 0; + this->sortedStore->reset(); + } + break; + } this->isDropDown = false; } @@ -405,6 +438,33 @@ void UniStoreV2::DropLogic(u32 hDown, u32 hHeld, touchPosition touch) { if (this->mode == 0) this->mode = 1; else this->mode = 0; this->isDropDown = false; + } else if (touching(touch, this->dropPos[2])) { + std::string temp = Input::getStringLong(Lang::get("ENTER_SEARCH")); + if (temp != "") { + if (this->mode == 0) { + this->selectedBox = 0; + this->storePage = 0; + } else if (this->mode == 1) { + this->selectedBoxList = 0; + this->storePageList = 0; + } + int amount = this->sortedStore->searchForEntries(temp); + if (amount == 0) Msg::DisplayWarnMsg(Lang::get("NO_RESULTS_FOUND")); + } else { + Msg::DisplayWarnMsg(Lang::get("INVALID_INPUT")); + } + this->isDropDown = false; + } else if (touching(touch, this->dropPos[3])) { + if (this->mode == 0) { + this->selectedBox = 0; + this->storePage = 0; + this->sortedStore->reset(); + } else if (this->mode == 1) { + this->selectedBoxList = 0; + this->storePageList = 0; + this->sortedStore->reset(); + } + this->isDropDown = false; } } } @@ -468,22 +528,6 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) { } } - if (hDown & KEY_X) { - std::string temp = Input::getStringLong(Lang::get("ENTER_SEARCH")); - if (temp != "") { - this->selectedBox = 0; - this->storePage = 0; - int amount = this->sortedStore->searchForEntries(temp); - if (amount == 0) Msg::DisplayWarnMsg(Lang::get("NO_RESULTS_FOUND")); - } - } - - if (hDown & KEY_Y) { - this->selectedBox = 0; - this->storePage = 0; - this->sortedStore->reset(); - } - if (hDown & KEY_L) { if (this->storePage > 0) { this->storePage--; @@ -573,22 +617,6 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) { } } - if (hDown & KEY_X) { - std::string temp = Input::getStringLong(Lang::get("ENTER_SEARCH")); - if (temp != "") { - this->selectedBoxList = 0; - this->storePageList = 0; - int amount = this->sortedStore->searchForEntries(temp); - if (amount == 0) Msg::DisplayWarnMsg(Lang::get("NO_RESULTS_FOUND")); - } - } - - if (hDown & KEY_Y) { - this->selectedBoxList = 0; - this->storePageList = 0; - this->sortedStore->reset(); - } - } else if (this->mode == 2) { if (hDown & KEY_TOUCH) { if (this->objects.size() > 0) {