From c36dcb6728acf1040b5eef22da8ba56485bc09e5 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 20 Feb 2020 11:10:55 +0100 Subject: [PATCH] Rename GameList::loadIcon to GameList::updateTitleInfo. Only call the callback when things acutally have changed. --- src/game/GameList.cpp | 16 +++++++++++----- src/game/GameList.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/game/GameList.cpp b/src/game/GameList.cpp index a58266c..4080ae0 100644 --- a/src/game/GameList.cpp +++ b/src/game/GameList.cpp @@ -132,15 +132,18 @@ int32_t GameList::readGameList() { return cnt; } -void GameList::loadIcons() { +void GameList::updateTitleInfo() { for (int i = 0; i < this->size(); i++) { gameInfo * newHeader = this->at(i); + bool hasChanged = false; + ACPMetaXml* meta = (ACPMetaXml*)calloc(1, 0x4000); //TODO fix wut if(meta) { auto acp = ACPGetTitleMetaXml(newHeader->titleId, meta); if(acp >= 0) { newHeader->name = meta->shortname_en; + hasChanged = true; } free(meta); } @@ -155,14 +158,17 @@ void GameList::loadIcons() { GuiImageData * imageData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR); if(imageData) { newHeader->imageData = imageData; + hasChanged = true; } //! free original image buffer which is converted to texture now and not needed anymore free(buffer); } } - DCFlushRange(newHeader, sizeof(gameInfo)); - titleUpdated(newHeader); + if(hasChanged) { + DCFlushRange(newHeader, sizeof(gameInfo)); + titleUpdated(newHeader); + } } } @@ -194,7 +200,7 @@ int32_t GameList::filterList(const char * filter) { titleListChanged(this); - AsyncExecutor::execute([&] { loadIcons();}); + AsyncExecutor::execute([&] { updateTitleInfo();}); return filteredList.size(); } @@ -220,7 +226,7 @@ int32_t GameList::loadUnfiltered() { sortList(); - AsyncExecutor::execute([&] { loadIcons();}); + AsyncExecutor::execute([&] { updateTitleInfo();}); titleListChanged(this); diff --git a/src/game/GameList.h b/src/game/GameList.h index b8c206d..e5c3773 100644 --- a/src/game/GameList.h +++ b/src/game/GameList.h @@ -87,7 +87,7 @@ protected: void internalFilterList(std::vector & fullList); void internalLoadUnfiltered(std::vector & fullList); - void loadIcons(); + void updateTitleInfo(); static bool nameSortCallback(const gameInfo *a, const gameInfo *b);