Do some stuff.

- Display Background for DropDownMenu.
- Fix copy paste dropdown touch mistake.
- Display 15 Entries on the grid.
- If possible, keep selector on the same position on page switch.
This commit is contained in:
StackZ
2020-06-19 14:47:11 +02:00
parent e03cf47b67
commit a5ea3087b1
3 changed files with 51 additions and 49 deletions
+17 -11
View File
@@ -67,23 +67,29 @@ private:
void DropDownMenu(void) const; void DropDownMenu(void) const;
const std::vector<Structs::ButtonPos> StoreBoxesGrid = { const std::vector<Structs::ButtonPos> StoreBoxesGrid = {
{20, 30, 100, 50}, {25, 35, 50, 50},
{150, 30, 100, 50}, {100, 35, 50, 50},
{280, 30, 100, 50}, {175, 35, 50, 50},
{250, 35, 50, 50},
{325, 35, 50, 50},
{20, 95, 100, 50}, {25, 95, 50, 50},
{150, 95, 100, 50}, {100, 95, 50, 50},
{280, 95, 100, 50}, {175, 95, 50, 50},
{250, 95, 50, 50},
{325, 95, 50, 50},
{20, 160, 100, 50}, {25, 155, 50, 50},
{150, 160, 100, 50}, {100, 155, 50, 50},
{280, 160, 100, 50} {175, 155, 50, 50},
{250, 155, 50, 50},
{325, 155, 50, 50}
}; };
const std::vector<Structs::ButtonPos> StoreBoxesList = { const std::vector<Structs::ButtonPos> StoreBoxesList = {
{20, 30, 360, 50}, {20, 35, 360, 50},
{20, 95, 360, 50}, {20, 95, 360, 50},
{20, 160, 360, 50} {20, 155, 360, 50}
}; };
const std::vector<Structs::ButtonPos> downloadBoxes = { const std::vector<Structs::ButtonPos> downloadBoxes = {
+28 -20
View File
@@ -34,7 +34,7 @@
extern u32 getColor(std::string colorString); extern u32 getColor(std::string colorString);
extern bool touching(touchPosition touch, Structs::ButtonPos button); extern bool touching(touchPosition touch, Structs::ButtonPos button);
#define STORE_ENTRIES 9 #define STORE_ENTRIES 15
#define STORE_ENTRIES_LIST 3 #define STORE_ENTRIES_LIST 3
#define DOWNLOAD_ENTRIES 5 #define DOWNLOAD_ENTRIES 5
extern bool didAutoboot; extern bool didAutoboot;
@@ -126,9 +126,9 @@ void UniStoreV2::drawBox(float xPos, float yPos, float width, float height, bool
void UniStoreV2::DrawGrid(void) const { void UniStoreV2::DrawGrid(void) const {
for (int i = 0, i2 = 0 + (this->storePage * STORE_ENTRIES); i2 < STORE_ENTRIES + (this->storePage * STORE_ENTRIES) && i2 < this->sortedStore->getSize(); i2++, i++) { for (int i = 0, i2 = 0 + (this->storePage * STORE_ENTRIES); i2 < STORE_ENTRIES + (this->storePage * STORE_ENTRIES) && i2 < this->sortedStore->getSize(); i2++, i++) {
if (i == this->selectedBox) { if (i == this->selectedBox) {
this->drawBox(this->StoreBoxesGrid[i].x, this->StoreBoxesGrid[i].y, 100, 50, true); this->drawBox(this->StoreBoxesGrid[i].x, this->StoreBoxesGrid[i].y, 50, 50, true);
} else { } else {
this->drawBox(this->StoreBoxesGrid[i].x, this->StoreBoxesGrid[i].y, 100, 50, false); this->drawBox(this->StoreBoxesGrid[i].x, this->StoreBoxesGrid[i].y, 50, 50, false);
} }
if (this->sheetLoaded) { if (this->sheetLoaded) {
@@ -138,7 +138,7 @@ void UniStoreV2::DrawGrid(void) const {
if (temp.subtex->width < 49 && temp.subtex->height < 49) { if (temp.subtex->width < 49 && temp.subtex->height < 49) {
int offset = (48 - temp.subtex->width) / 2; int offset = (48 - temp.subtex->width) / 2;
int offset2 = (48 - temp.subtex->height) / 2; int offset2 = (48 - temp.subtex->height) / 2;
Gui::DrawSprite(this->sheet, this->sortedStore->returnIconIndex(i + (this->storePage * STORE_ENTRIES)), this->StoreBoxesGrid[i].x+26 + offset, this->StoreBoxesGrid[i].y+1 + offset2); Gui::DrawSprite(this->sheet, this->sortedStore->returnIconIndex(i + (this->storePage * STORE_ENTRIES)), this->StoreBoxesGrid[i].x+1 + offset, this->StoreBoxesGrid[i].y+1 + offset2);
} else { } else {
GFX::DrawSprite(sprites_noIcon_idx, this->StoreBoxesList[i].x+1, this->StoreBoxesList[i].y+1); GFX::DrawSprite(sprites_noIcon_idx, this->StoreBoxesList[i].x+1, this->StoreBoxesList[i].y+1);
} }
@@ -233,8 +233,10 @@ void UniStoreV2::DropDownMenu(void) const {
// DropDown Menu. // DropDown Menu.
if (this->isDropDown) { if (this->isDropDown) {
// Draw Operation Box. // Draw Operation Box.
Gui::Draw_Rect(5, 25, 140, 60, this->darkMode ? this->barColorDark : this->barColorLight);
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
Gui::Draw_Rect(dropPos[i].x, dropPos[i].y, dropPos[i].w, dropPos[i].h, this->darkMode ? this->barColorDark : this->barColorLight); Gui::Draw_Rect(dropPos[i].x, dropPos[i].y, dropPos[i].w, dropPos[i].h, this->darkMode ? this->boxColorDark : this->boxColorLight);
} }
Gui::drawAnimatedSelector(dropPos[dropSelection].x, dropPos[dropSelection].y, dropPos[dropSelection].w, dropPos[dropSelection].h, .090, this->darkMode ? this->barColorDark : this->barColorLight, TRANSPARENT); Gui::drawAnimatedSelector(dropPos[dropSelection].x, dropPos[dropSelection].y, dropPos[dropSelection].w, dropPos[dropSelection].h, .090, this->darkMode ? this->barColorDark : this->barColorLight, TRANSPARENT);
@@ -390,7 +392,7 @@ void UniStoreV2::DropLogic(u32 hDown, u32 hHeld, touchPosition touch) {
this->isDropDown = false; this->isDropDown = false;
} }
if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, this->iconPos[3]))) { if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, this->iconPos[0]))) {
this->isDropDown = false; this->isDropDown = false;
} }
@@ -421,23 +423,22 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_RIGHT) { if (hDown & KEY_RIGHT) {
// Try to go to next page. // Try to go to next page.
if (this->selectedBox == 2 || this->selectedBox == 5 || this->selectedBox == 8) { if (this->selectedBox == 4 || this->selectedBox == 9 || this->selectedBox == 14) {
if (STORE_ENTRIES + (this->storePage * STORE_ENTRIES) < (int)this->sortedStore->getSize()) { if (STORE_ENTRIES + (this->storePage * STORE_ENTRIES) < (int)this->sortedStore->getSize()) {
this->selectedBox = 0; this->selectedBox = 0;
this->storePage++; this->storePage++;
} }
} else { } else {
if ((this->storePage * STORE_ENTRIES) + this->selectedBox + 1 < (int)this->sortedStore->getSize()) { if ((this->storePage * STORE_ENTRIES) + this->selectedBox + 1 < (int)this->sortedStore->getSize()) {
if (this->selectedBox < 8 + (this->storePage * STORE_ENTRIES)) this->selectedBox++; if (this->selectedBox < 14 + (this->storePage * STORE_ENTRIES)) this->selectedBox++;
} }
} }
} }
if (hDown & KEY_LEFT) { if (hDown & KEY_LEFT) {
// Try to go to next page. // Try to go to next page.
if (this->selectedBox == 0 || this->selectedBox == 3 || this->selectedBox == 6) { if (this->selectedBox == 0 || this->selectedBox == 5 || this->selectedBox == 11) {
if (this->storePage > 0) { if (this->storePage > 0) {
this->selectedBox = 0;
this->storePage--; this->storePage--;
} }
} else { } else {
@@ -446,19 +447,24 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
} }
if (hDown & KEY_UP) { if (hDown & KEY_UP) {
if (this->selectedBox > 2 + (this->storePage * STORE_ENTRIES)) this->selectedBox -= 3; if (this->selectedBox > 4 + (this->storePage * STORE_ENTRIES)) this->selectedBox -= 5;
} }
if (hDown & KEY_DOWN) { if (hDown & KEY_DOWN) {
if ((this->storePage * STORE_ENTRIES) + this->selectedBox + 3 < (int)this->sortedStore->getSize()) { if ((this->storePage * STORE_ENTRIES) + this->selectedBox + 5 < (int)this->sortedStore->getSize()) {
if (this->selectedBox < 6) this->selectedBox += 3; if (this->selectedBox < 11) this->selectedBox += 5;
} }
} }
if (hDown & KEY_R) { if (hDown & KEY_R) {
if (STORE_ENTRIES + (this->storePage * STORE_ENTRIES) < (int)this->sortedStore->getSize()) { if (STORE_ENTRIES + (this->storePage * STORE_ENTRIES) < this->sortedStore->getSize()) {
this->selectedBox = 0; // Selected box is smaller.. so we can keep it on the same position.
this->storePage++; if (this->selectedBox + STORE_ENTRIES + (this->storePage * STORE_ENTRIES) < this->sortedStore->getSize()) {
this->storePage++;
} else {
this->selectedBox = 0;
this->storePage++;
}
} }
} }
@@ -480,7 +486,6 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_L) { if (hDown & KEY_L) {
if (this->storePage > 0) { if (this->storePage > 0) {
this->selectedBox = 0;
this->storePage--; this->storePage--;
} }
} }
@@ -529,14 +534,17 @@ void UniStoreV2::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_RIGHT || hDown & KEY_R) { if (hDown & KEY_RIGHT || hDown & KEY_R) {
if (STORE_ENTRIES_LIST + (this->storePageList * STORE_ENTRIES_LIST) < (int)this->sortedStore->getSize()) { if (STORE_ENTRIES_LIST + (this->storePageList * STORE_ENTRIES_LIST) < (int)this->sortedStore->getSize()) {
this->selectedBoxList = 0; if (this->selectedBoxList + STORE_ENTRIES_LIST + (this->storePageList * STORE_ENTRIES_LIST) < this->sortedStore->getSize()) {
this->storePageList++; this->storePageList++;
} else {
this->selectedBoxList = 0;
this->storePageList++;
}
} }
} }
if (hDown & KEY_LEFT || hDown & KEY_L) { if (hDown & KEY_LEFT || hDown & KEY_L) {
if (this->storePageList > 0) { if (this->storePageList > 0) {
this->selectedBoxList = 0;
this->storePageList--; this->storePageList--;
} }
} }
+6 -18
View File
@@ -100,38 +100,26 @@ int Store::searchForEntries(const std::string searchResult) {
// Title. // Title.
bool compareTitleDescending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) { bool compareTitleDescending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) {
int result = a.title.compare(b.title); return strcasecmp(a.title.c_str(), b.title.c_str()) > 0;
if (result > 0) return true;
else return false;
} }
bool compareTitleAscending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) { bool compareTitleAscending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) {
int result = b.title.compare(a.title); return strcasecmp(b.title.c_str(), a.title.c_str()) > 0;
if (result > 0) return true;
else return false;
} }
// Author. // Author.
bool compareAuthorDescending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) { bool compareAuthorDescending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) {
int result = a.author.compare(b.author); return strcasecmp(a.author.c_str(), b.author.c_str()) > 0;
if (result > 0) return true;
else return false;
} }
bool compareAuthorAscending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) { bool compareAuthorAscending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) {
int result = b.author.compare(a.author); return strcasecmp(b.author.c_str(), a.author.c_str()) > 0;
if (result > 0) return true;
else return false;
} }
// Last updated. // Last updated.
bool compareUpdateDescending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) { bool compareUpdateDescending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) {
int result = a.last_updated.compare(b.last_updated); return strcasecmp(a.last_updated.c_str(), b.last_updated.c_str()) > 0;
if (result > 0) return true;
else return false;
} }
bool compareUpdateAscending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) { bool compareUpdateAscending(const UniStoreV2Struct& a, const UniStoreV2Struct& b) {
int result = b.last_updated.compare(a.last_updated); return strcasecmp(b.last_updated.c_str(), a.last_updated.c_str()) > 0;
if (result > 0) return true;
else return false;
} }
void Store::sorting(bool Ascending, SortType sorttype) { void Store::sorting(bool Ascending, SortType sorttype) {