Rename GameList::loadIcon to GameList::updateTitleInfo. Only call the callback when things acutally have changed.

This commit is contained in:
Maschell 2020-02-20 11:10:55 +01:00
parent b8226ea729
commit c36dcb6728
2 changed files with 12 additions and 6 deletions

View File

@ -132,15 +132,18 @@ int32_t GameList::readGameList() {
return cnt; return cnt;
} }
void GameList::loadIcons() { void GameList::updateTitleInfo() {
for (int i = 0; i < this->size(); i++) { for (int i = 0; i < this->size(); i++) {
gameInfo * newHeader = this->at(i); gameInfo * newHeader = this->at(i);
bool hasChanged = false;
ACPMetaXml* meta = (ACPMetaXml*)calloc(1, 0x4000); //TODO fix wut ACPMetaXml* meta = (ACPMetaXml*)calloc(1, 0x4000); //TODO fix wut
if(meta) { if(meta) {
auto acp = ACPGetTitleMetaXml(newHeader->titleId, meta); auto acp = ACPGetTitleMetaXml(newHeader->titleId, meta);
if(acp >= 0) { if(acp >= 0) {
newHeader->name = meta->shortname_en; newHeader->name = meta->shortname_en;
hasChanged = true;
} }
free(meta); free(meta);
} }
@ -155,14 +158,17 @@ void GameList::loadIcons() {
GuiImageData * imageData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR); GuiImageData * imageData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR);
if(imageData) { if(imageData) {
newHeader->imageData = imageData; newHeader->imageData = imageData;
hasChanged = true;
} }
//! free original image buffer which is converted to texture now and not needed anymore //! free original image buffer which is converted to texture now and not needed anymore
free(buffer); free(buffer);
} }
} }
DCFlushRange(newHeader, sizeof(gameInfo)); if(hasChanged) {
titleUpdated(newHeader); DCFlushRange(newHeader, sizeof(gameInfo));
titleUpdated(newHeader);
}
} }
} }
@ -194,7 +200,7 @@ int32_t GameList::filterList(const char * filter) {
titleListChanged(this); titleListChanged(this);
AsyncExecutor::execute([&] { loadIcons();}); AsyncExecutor::execute([&] { updateTitleInfo();});
return filteredList.size(); return filteredList.size();
} }
@ -220,7 +226,7 @@ int32_t GameList::loadUnfiltered() {
sortList(); sortList();
AsyncExecutor::execute([&] { loadIcons();}); AsyncExecutor::execute([&] { updateTitleInfo();});
titleListChanged(this); titleListChanged(this);

View File

@ -87,7 +87,7 @@ protected:
void internalFilterList(std::vector<gameInfo*> & fullList); void internalFilterList(std::vector<gameInfo*> & fullList);
void internalLoadUnfiltered(std::vector<gameInfo*> & fullList); void internalLoadUnfiltered(std::vector<gameInfo*> & fullList);
void loadIcons(); void updateTitleInfo();
static bool nameSortCallback(const gameInfo *a, const gameInfo *b); static bool nameSortCallback(const gameInfo *a, const gameInfo *b);