Do search & reset to dropdown menu.

This commit is contained in:
StackZ 2020-06-19 15:52:20 +02:00
commit 6163891c63
4 changed files with 73 additions and 40 deletions

View file

@ -106,7 +106,9 @@ private:
const std::vector<Structs::ButtonPos> 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<Structs::ButtonPos> sortingPos = {

View file

@ -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"
}

View file

@ -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");
}
}

View file

@ -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) {