No longer show "input" and "skip" buttons when scraping in auto mode.

Fixed ScraperSearchComponent stopping in auto mode when it found a game with no results.
This commit is contained in:
Aloshi 2014-04-19 17:24:59 -05:00
parent 04df8fece6
commit 84565354dc
2 changed files with 30 additions and 12 deletions

View file

@ -81,6 +81,9 @@ void ScraperSearchComponent::onSizeChanged()
{ {
mGrid.setSize(mSize); mGrid.setSize(mSize);
if(mSize.x() == 0 || mSize.y() == 0)
return;
// column widths // column widths
mGrid.setColWidthPerc(0, 0.01f); mGrid.setColWidthPerc(0, 0.01f);
mGrid.setColWidthPerc(1, 0.25f); mGrid.setColWidthPerc(1, 0.25f);
@ -249,6 +252,7 @@ void ScraperSearchComponent::onSearchDone(const std::vector<ScraperSearchResult>
void ScraperSearchComponent::onSearchError(const std::string& error) void ScraperSearchComponent::onSearchError(const std::string& error)
{ {
LOG(LogInfo) << "ScraperSearchComponent search error: " << error;
mWindow->pushGui(new GuiMsgBox(mWindow, strToUpper(error), mWindow->pushGui(new GuiMsgBox(mWindow, strToUpper(error),
"RETRY", std::bind(&ScraperSearchComponent::search, this, mLastSearch), "RETRY", std::bind(&ScraperSearchComponent::search, this, mLastSearch),
"SKIP", mSkipCallback, "SKIP", mSkipCallback,
@ -369,14 +373,21 @@ void ScraperSearchComponent::update(int deltaTime)
if(mSearchHandle && mSearchHandle->status() != ASYNC_IN_PROGRESS) if(mSearchHandle && mSearchHandle->status() != ASYNC_IN_PROGRESS)
{ {
if(mSearchHandle->status() == ASYNC_DONE) auto status = mSearchHandle->status();
{ auto results = mSearchHandle->getResults();
onSearchDone(mSearchHandle->getResults()); auto statusString = mSearchHandle->getStatusString();
}else if(mSearchHandle->status() == ASYNC_ERROR)
{ // we reset here because onSearchDone in auto mode can call mSkipCallback() which can call
onSearchError(mSearchHandle->getStatusString()); // another search() which will set our mSearchHandle to something important
}
mSearchHandle.reset(); mSearchHandle.reset();
if(status == ASYNC_DONE)
{
onSearchDone(results);
}else if(status == ASYNC_ERROR)
{
onSearchError(statusString);
}
} }
if(mMDResolveHandle && mMDResolveHandle->status() != ASYNC_IN_PROGRESS) if(mMDResolveHandle && mMDResolveHandle->status() != ASYNC_IN_PROGRESS)

View file

@ -41,12 +41,19 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchP
mGrid.setEntry(mSearchComp, Vector2i(0, 3), approveResults, true); mGrid.setEntry(mSearchComp, Vector2i(0, 3), approveResults, true);
std::vector< std::shared_ptr<ButtonComponent> > buttons; std::vector< std::shared_ptr<ButtonComponent> > buttons;
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "search", [&] {
mSearchComp->openInputScreen(mSearchQueue.front()); if(approveResults)
mGrid.resetCursor(); {
})); buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "INPUT", "search", [&] {
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SKIP", "skip", std::bind(&GuiScraperMulti::skip, this))); mSearchComp->openInputScreen(mSearchQueue.front());
mGrid.resetCursor();
}));
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SKIP", "skip", std::bind(&GuiScraperMulti::skip, this)));
}
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "STOP", "stop (progress saved)", std::bind(&GuiScraperMulti::finish, this))); buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "STOP", "stop (progress saved)", std::bind(&GuiScraperMulti::finish, this)));
mButtonGrid = makeButtonGrid(mWindow, buttons); mButtonGrid = makeButtonGrid(mWindow, buttons);
mGrid.setEntry(mButtonGrid, Vector2i(0, 4), true, false); mGrid.setEntry(mButtonGrid, Vector2i(0, 4), true, false);