From 317719b678d63bf2fa5e1b18ada23352b47ad1f4 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 31 Jul 2020 14:24:14 +0200 Subject: [PATCH] Fixed an issue with the scraper error dialog. --- NEWS.md | 1 + es-app/src/guis/GuiGameScraper.cpp | 2 +- es-app/src/guis/GuiScraperMulti.cpp | 6 +++--- es-app/src/guis/GuiScraperSearch.cpp | 23 +++++++++++++++++------ es-app/src/guis/GuiScraperSearch.h | 5 +++-- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3194297c0..f79e0538d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -63,6 +63,7 @@ Many bugs have been fixed, and numerous features that were only partially implem * Non-transparent favorite icons were not rendered correctly * Restart and power-off menu entries not working * Unknown command line options were silently accepted instead of generating an error and notifying the user +* The scraper didn't handle error conditions correctly * Toggling the screensaver didn't work as expected * The setting to enable or disable audio for the video screensaver only worked on Raspberry Pi * The screensaver random function did not consider the previously selected game and could potentially show the same image or video over and over again diff --git a/es-app/src/guis/GuiGameScraper.cpp b/es-app/src/guis/GuiGameScraper.cpp index 8135cba1b..ff8f942a0 100644 --- a/es-app/src/guis/GuiGameScraper.cpp +++ b/es-app/src/guis/GuiGameScraper.cpp @@ -48,7 +48,7 @@ GuiGameScraper::GuiGameScraper( // GuiScraperSearch. mSearch = std::make_shared(window, - GuiScraperSearch::NEVER_AUTO_ACCEPT); + GuiScraperSearch::NEVER_AUTO_ACCEPT, 1); mGrid.setEntry(mSearch, Vector2i(0, 5), true); // Buttons diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index 2cf4796e5..2d6b36a22 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -57,13 +57,13 @@ GuiScraperMulti::GuiScraperMulti( if (approveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic")) mSearchComp = std::make_shared(mWindow, - GuiScraperSearch::NEVER_AUTO_ACCEPT); + GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames); else if (approveResults && Settings::getInstance()->getBool("ScraperSemiautomatic")) mSearchComp = std::make_shared(mWindow, - GuiScraperSearch::ACCEPT_SINGLE_MATCHES); + GuiScraperSearch::ACCEPT_SINGLE_MATCHES, mTotalGames); else if (!approveResults) mSearchComp = std::make_shared(mWindow, - GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT); + GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames); mSearchComp->setAcceptCallback(std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1)); mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this)); diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index e5c41a0bc..598c22693 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -34,11 +34,13 @@ GuiScraperSearch::GuiScraperSearch( Window* window, - SearchType type) + SearchType type, + unsigned int scrapeCount) : GuiComponent(window), mGrid(window, Vector2i(4, 3)), mBusyAnim(window), mSearchType(type), + mScrapeCount(scrapeCount), mScrapeRatings(false) { addChild(&mGrid); @@ -346,11 +348,19 @@ void GuiScraperSearch::onSearchDone(const std::vector& resu void GuiScraperSearch::onSearchError(const std::string& error) { - LOG(LogInfo) << "GuiScraperSearch search error: " << error; - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), Utils::String::toUpper(error), - "RETRY", std::bind(&GuiScraperSearch::search, this, mLastSearch), - "SKIP", mSkipCallback, - "CANCEL", mCancelCallback)); + if (mScrapeCount > 1) { + LOG(LogInfo) << "GuiScraperSearch search error: " << error; + mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), Utils::String::toUpper(error), + "RETRY", std::bind(&GuiScraperSearch::search, this, mLastSearch), + "SKIP", mSkipCallback, + "CANCEL", mCancelCallback)); + } + else { + LOG(LogInfo) << "GuiScraperSearch search error: " << error; + mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), Utils::String::toUpper(error), + "RETRY", std::bind(&GuiScraperSearch::search, this, mLastSearch), + "CANCEL", mCancelCallback)); + } } int GuiScraperSearch::getSelectedIndex() @@ -465,6 +475,7 @@ void GuiScraperSearch::returnResult(ScraperSearchResult result) return; } + mScrapeCount -= 1; mAcceptCallback(result); } diff --git a/es-app/src/guis/GuiScraperSearch.h b/es-app/src/guis/GuiScraperSearch.h index 44360bc83..e87a2147a 100644 --- a/es-app/src/guis/GuiScraperSearch.h +++ b/es-app/src/guis/GuiScraperSearch.h @@ -36,7 +36,7 @@ public: NEVER_AUTO_ACCEPT }; - GuiScraperSearch(Window* window, SearchType searchType = NEVER_AUTO_ACCEPT); + GuiScraperSearch(Window* window, SearchType searchType, unsigned int scrapeCount = 1); void search(const ScraperSearchParams& params); void openInputScreen(ScraperSearchParams& from); @@ -51,7 +51,7 @@ public: inline void setSkipCallback(const std::function& skipCallback) { mSkipCallback = skipCallback; }; inline void setCancelCallback(const std::function& - cancelCallback) { mCancelCallback = cancelCallback; } + cancelCallback) { mScrapeCount -= 1; mCancelCallback = cancelCallback; } bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; @@ -116,6 +116,7 @@ private: std::function mAcceptCallback; std::function mSkipCallback; std::function mCancelCallback; + unsigned int mScrapeCount; bool mBlockAccept; bool mFoundGame; bool mScrapeRatings;