Fixed an issue where the gamelist entry would not update properly if the user aborted the single-game scraper.

This commit is contained in:
Leon Styhre 2021-02-01 18:52:49 +01:00
parent 3b6ace73ae
commit dc3731660b
3 changed files with 23 additions and 1 deletions

View file

@ -76,7 +76,17 @@ GuiGameScraper::GuiGameScraper(
mGrid.resetCursor();
}));
buttons.push_back(std::make_shared<ButtonComponent>(
mWindow, "CANCEL", "cancel", [&] { delete this; }));
mWindow, "CANCEL", "cancel", [&] {
if (mSearch->getSavedNewMedia()) {
// If the user aborted the scraping but there was still some media downloaded,
// then force an unload of the textures for the game image and marquee, and make
// an update of the game entry. Otherwise the images would not get updated until
// the user scrolls up and down the gamelist.
TextureResource::manualUnload(mSearchParams.game->getImagePath(), false);
TextureResource::manualUnload(mSearchParams.game->getMarqueePath(), false);
ViewController::get()->onFileChanged(mSearchParams.game, true);
}
delete this; }));
mButtonGrid = makeButtonGrid(mWindow, buttons);
mGrid.setEntry(mButtonGrid, Vector2i(0, 6), true, false);
@ -134,6 +144,15 @@ void GuiGameScraper::onSizeChanged()
bool GuiGameScraper::input(InputConfig* config, Input input)
{
if (config->isMappedTo("b", input) && input.value) {
if (mSearch->getSavedNewMedia()) {
// If the user aborted the scraping but there was still some media downloaded,
// then force an unload of the textures for the game image and marquee, and make
// an update of the game entry. Otherwise the images would not get updated until
// the user scrolls up and down the gamelist.
TextureResource::manualUnload(mSearchParams.game->getImagePath(), false);
TextureResource::manualUnload(mSearchParams.game->getMarqueePath(), false);
ViewController::get()->onFileChanged(mSearchParams.game, true);
}
delete this;
return true;
}

View file

@ -44,6 +44,8 @@ public:
void openInputScreen(ScraperSearchParams& from);
void stop();
inline SearchType getSearchType() const { return mSearchType; }
bool getSavedNewMedia()
{ return (mMDResolveHandle ? mMDResolveHandle->getSavedNewMedia() : false); };
static bool saveMetadata(const ScraperSearchResult& result,
MetaDataList& metadata, FileData* scrapedGame);

View file

@ -179,6 +179,7 @@ public:
void update() override;
inline const ScraperSearchResult& getResult() const
{ assert(mStatus == ASYNC_DONE); return mResult; }
bool getSavedNewMedia() { return mResult.savedNewMedia; }
private:
ScraperSearchResult mResult;