Add Description to UniStorev2 List.

This commit is contained in:
StackZ
2020-07-15 23:38:48 +02:00
parent dcb7bd66ee
commit 2f0c07df6e
3 changed files with 20 additions and 19 deletions
+4 -3
View File
@@ -201,9 +201,10 @@ void UniStoreV2::DrawList(void) const {
GFX::DrawSprite(sprites_updateStore_idx, this->StoreBoxesList[i].x+340, this->StoreBoxesList[i].y+30);
}
// Display Author & App name.
Gui::DrawString(this->StoreBoxesList[i].x+55, this->StoreBoxesList[i].y+12, 0.45f, this->returnTextColor(), this->sortedStore->returnTitle(i + (this->storePageList * STORE_ENTRIES_LIST)), 300);
Gui::DrawString(this->StoreBoxesList[i].x+55, this->StoreBoxesList[i].y+28, 0.45f, this->returnTextColor(), this->sortedStore->returnAuthor(i + (this->storePageList * STORE_ENTRIES_LIST)), 300);
// Display Title, Author and Description.
Gui::DrawString(this->StoreBoxesList[i].x+55, this->StoreBoxesList[i].y+5, 0.45f, this->returnTextColor(), this->sortedStore->returnTitle(i + (this->storePageList * STORE_ENTRIES_LIST)), 300);
Gui::DrawString(this->StoreBoxesList[i].x+55, this->StoreBoxesList[i].y+18, 0.45f, this->returnTextColor(), this->sortedStore->returnAuthor(i + (this->storePageList * STORE_ENTRIES_LIST)), 300);
Gui::DrawString(this->StoreBoxesList[i].x+55, this->StoreBoxesList[i].y+32, 0.45f, this->returnTextColor(), this->sortedStore->returnDescription(i + (this->storePageList * STORE_ENTRIES_LIST)), 300);
}
}
+14 -16
View File
@@ -106,7 +106,7 @@ void Store::writeToFile(int index) {
// Here we get the data of the UniStore!
UniStoreV2Struct Store::getData(const int index) {
UniStoreV2Struct temp = {"", "", "", "", "" ,"", -1, 0, false};
UniStoreV2Struct temp = {"", "", "", "", "", "" ,"", -1, 0, false};
if (index > (int)this->storeJson["storeContent"].size()) return temp; // Empty.
@@ -121,6 +121,11 @@ UniStoreV2Struct Store::getData(const int index) {
temp.author = this->storeJson["storeContent"][index]["info"]["author"];
}
// Description.
if (this->storeJson["storeContent"][index]["info"].contains("description")) {
temp.description = this->storeJson["storeContent"][index]["info"]["description"];
}
// Version.
if (this->storeJson["storeContent"][index]["info"].contains("version")) {
temp.version = this->storeJson["storeContent"][index]["info"]["version"];
@@ -247,25 +252,13 @@ void Store::sorting(bool Ascending, SortType sorttype) {
this->sorttype = sorttype;
switch(this->sorttype) {
case SortType::TITLE:
if (Ascending) {
std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareTitleAscending);
} else {
std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareTitleDescending);
}
Ascending ? std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareTitleAscending) : std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareAuthorAscending);
break;
case SortType::AUTHOR:
if (Ascending) {
std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareAuthorAscending);
} else {
std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareAuthorDescending);
}
Ascending ? std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareTitleAscending) : std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareAuthorDescending);
break;
case SortType::LAST_UPDATED:
if (Ascending) {
std::sort(this->sortedStore.begin(), sortedStore.end(), compareUpdateAscending);
} else {
std::sort(this->sortedStore.begin(), sortedStore.end(), compareUpdateDescending);
}
Ascending ? std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareUpdateAscending) : std::sort(this->sortedStore.begin(), this->sortedStore.end(), compareUpdateDescending);
break;
}
}
@@ -281,6 +274,11 @@ std::string Store::returnAuthor(const int index) {
return this->sortedStore[index].author;
}
std::string Store::returnDescription(const int index) {
if (index > (int)this->sortedStore.size()) return "?"; // Out of scope.
return this->sortedStore[index].description;
}
int Store::returnIconIndex(const int index) {
if (index > (int)this->sortedStore.size()) return -1; // Out of scope.
return this->sortedStore[index].icon_index;