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;
}
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,16 +158,19 @@ 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);
}
}
if(hasChanged) {
DCFlushRange(newHeader, sizeof(gameInfo));
titleUpdated(newHeader);
}
}
}
void GameList::internalFilterList(std::vector<gameInfo*> &fullList) {
for (uint32_t i = 0; i < fullList.size(); ++i) {
@ -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);

View File

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