From 7383322bac642cf6896b28239d126dab85c77c30 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 16 Aug 2020 16:53:49 +0200 Subject: [PATCH] Changed scraper to always display the game name. Some minor cosmetic changes as well. --- es-app/src/guis/GuiScraperSearch.cpp | 33 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index 149527e38..f9764fd2e 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -311,18 +311,16 @@ void GuiScraperSearch::onSearchDone(const std::vector& resu } else { mFoundGame = true; - if (!(mSearchType == ACCEPT_SINGLE_MATCHES && results.size() == 1)) { - ComponentListRow row; + ComponentListRow row; - for (size_t i = 0; i < results.size(); i++) { - row.elements.clear(); - row.addElement(std::make_shared(mWindow, - Utils::String::toUpper(results.at(i).mdl.get("name")), font, color), true); - row.makeAcceptInputHandler([this, i] { returnResult(mScraperResults.at(i)); }); - mResultList->addRow(row); - } - mGrid.resetCursor(); + for (size_t i = 0; i < results.size(); i++) { + row.elements.clear(); + row.addElement(std::make_shared(mWindow, + Utils::String::toUpper(results.at(i).mdl.get("name")), font, color), true); + row.makeAcceptInputHandler([this, i] { returnResult(mScraperResults.at(i)); }); + mResultList->addRow(row); } + mGrid.resetCursor(); } mBlockAccept = false; @@ -382,7 +380,20 @@ void GuiScraperSearch::updateInfoPane() if (i != -1 && (int)mScraperResults.size() > i) { ScraperSearchResult& res = mScraperResults.at(i); - mResultName->setText(Utils::String::toUpper(res.mdl.get("name"))); + std::string formattedName; + + // Hack to make the game name align better with the image when using automatic mode. + mSearchType == ALWAYS_ACCEPT_FIRST_RESULT ? + formattedName = " " + Utils::String::toUpper(res.mdl.get("name")) : + formattedName = Utils::String::toUpper(res.mdl.get("name")); + + // If the game name is too long, cut it down. This does not affect the value that + // is actually scraped. + if (formattedName.size() > 40) + formattedName = formattedName.erase(40, formattedName.size()-40) + "..."; + + mResultName->setText(formattedName); + mResultDesc->setText(Utils::String::toUpper(res.mdl.get("desc"))); mDescContainer->reset();