Fixed an issue with the scraper error dialog.

This commit is contained in:
Leon Styhre 2020-07-31 14:24:14 +02:00
parent af37173a0b
commit 317719b678
5 changed files with 25 additions and 12 deletions

View file

@ -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 * Non-transparent favorite icons were not rendered correctly
* Restart and power-off menu entries not working * Restart and power-off menu entries not working
* Unknown command line options were silently accepted instead of generating an error and notifying the user * 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 * 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 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 * The screensaver random function did not consider the previously selected game and could potentially show the same image or video over and over again

View file

@ -48,7 +48,7 @@ GuiGameScraper::GuiGameScraper(
// GuiScraperSearch. // GuiScraperSearch.
mSearch = std::make_shared<GuiScraperSearch>(window, mSearch = std::make_shared<GuiScraperSearch>(window,
GuiScraperSearch::NEVER_AUTO_ACCEPT); GuiScraperSearch::NEVER_AUTO_ACCEPT, 1);
mGrid.setEntry(mSearch, Vector2i(0, 5), true); mGrid.setEntry(mSearch, Vector2i(0, 5), true);
// Buttons // Buttons

View file

@ -57,13 +57,13 @@ GuiScraperMulti::GuiScraperMulti(
if (approveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic")) if (approveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic"))
mSearchComp = std::make_shared<GuiScraperSearch>(mWindow, mSearchComp = std::make_shared<GuiScraperSearch>(mWindow,
GuiScraperSearch::NEVER_AUTO_ACCEPT); GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames);
else if (approveResults && Settings::getInstance()->getBool("ScraperSemiautomatic")) else if (approveResults && Settings::getInstance()->getBool("ScraperSemiautomatic"))
mSearchComp = std::make_shared<GuiScraperSearch>(mWindow, mSearchComp = std::make_shared<GuiScraperSearch>(mWindow,
GuiScraperSearch::ACCEPT_SINGLE_MATCHES); GuiScraperSearch::ACCEPT_SINGLE_MATCHES, mTotalGames);
else if (!approveResults) else if (!approveResults)
mSearchComp = std::make_shared<GuiScraperSearch>(mWindow, mSearchComp = std::make_shared<GuiScraperSearch>(mWindow,
GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT); GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames);
mSearchComp->setAcceptCallback(std::bind(&GuiScraperMulti::acceptResult, mSearchComp->setAcceptCallback(std::bind(&GuiScraperMulti::acceptResult,
this, std::placeholders::_1)); this, std::placeholders::_1));
mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this)); mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this));

View file

@ -34,11 +34,13 @@
GuiScraperSearch::GuiScraperSearch( GuiScraperSearch::GuiScraperSearch(
Window* window, Window* window,
SearchType type) SearchType type,
unsigned int scrapeCount)
: GuiComponent(window), : GuiComponent(window),
mGrid(window, Vector2i(4, 3)), mGrid(window, Vector2i(4, 3)),
mBusyAnim(window), mBusyAnim(window),
mSearchType(type), mSearchType(type),
mScrapeCount(scrapeCount),
mScrapeRatings(false) mScrapeRatings(false)
{ {
addChild(&mGrid); addChild(&mGrid);
@ -346,12 +348,20 @@ void GuiScraperSearch::onSearchDone(const std::vector<ScraperSearchResult>& resu
void GuiScraperSearch::onSearchError(const std::string& error) void GuiScraperSearch::onSearchError(const std::string& error)
{ {
if (mScrapeCount > 1) {
LOG(LogInfo) << "GuiScraperSearch search error: " << error; LOG(LogInfo) << "GuiScraperSearch search error: " << error;
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), Utils::String::toUpper(error), mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), Utils::String::toUpper(error),
"RETRY", std::bind(&GuiScraperSearch::search, this, mLastSearch), "RETRY", std::bind(&GuiScraperSearch::search, this, mLastSearch),
"SKIP", mSkipCallback, "SKIP", mSkipCallback,
"CANCEL", mCancelCallback)); "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() int GuiScraperSearch::getSelectedIndex()
{ {
@ -465,6 +475,7 @@ void GuiScraperSearch::returnResult(ScraperSearchResult result)
return; return;
} }
mScrapeCount -= 1;
mAcceptCallback(result); mAcceptCallback(result);
} }

View file

@ -36,7 +36,7 @@ public:
NEVER_AUTO_ACCEPT 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 search(const ScraperSearchParams& params);
void openInputScreen(ScraperSearchParams& from); void openInputScreen(ScraperSearchParams& from);
@ -51,7 +51,7 @@ public:
inline void setSkipCallback(const std::function<void()>& inline void setSkipCallback(const std::function<void()>&
skipCallback) { mSkipCallback = skipCallback; }; skipCallback) { mSkipCallback = skipCallback; };
inline void setCancelCallback(const std::function<void()>& inline void setCancelCallback(const std::function<void()>&
cancelCallback) { mCancelCallback = cancelCallback; } cancelCallback) { mScrapeCount -= 1; mCancelCallback = cancelCallback; }
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override; void update(int deltaTime) override;
@ -116,6 +116,7 @@ private:
std::function<void(const ScraperSearchResult&)> mAcceptCallback; std::function<void(const ScraperSearchResult&)> mAcceptCallback;
std::function<void()> mSkipCallback; std::function<void()> mSkipCallback;
std::function<void()> mCancelCallback; std::function<void()> mCancelCallback;
unsigned int mScrapeCount;
bool mBlockAccept; bool mBlockAccept;
bool mFoundGame; bool mFoundGame;
bool mScrapeRatings; bool mScrapeRatings;