From bd7e0e5820e8fe0737fea28365a8db0017a46b13 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 30 Jul 2020 16:29:38 +0200 Subject: [PATCH] Some cosmetic improvements to the scraper. --- es-app/src/guis/GuiScraperSearch.cpp | 24 +++++++++++++++--------- es-app/src/guis/GuiScraperSearch.h | 2 ++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index c49f42518..e5c41a0bc 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -38,7 +38,8 @@ GuiScraperSearch::GuiScraperSearch( : GuiComponent(window), mGrid(window, Vector2i(4, 3)), mBusyAnim(window), - mSearchType(type) + mSearchType(type), + mScrapeRatings(false) { addChild(&mGrid); @@ -74,9 +75,13 @@ GuiScraperSearch::GuiScraperSearch( mMD_Publisher = std::make_shared(mWindow, "", font, mdColor); mMD_Genre = std::make_shared(mWindow, "", font, mdColor); mMD_Players = std::make_shared(mWindow, "", font, mdColor); + mMD_Filler = std::make_shared(mWindow, "", font, mdColor); if (Settings::getInstance()->getBool("ScrapeRatings") && Settings::getInstance()->getString("Scraper") != "thegamesdb") + mScrapeRatings = true; + + if (mScrapeRatings) mMD_Pairs.push_back(MetaDataPair(std::make_shared (mWindow, "RATING:", font, mdLblColor), mMD_Rating, false)); mMD_Pairs.push_back(MetaDataPair(std::make_shared @@ -89,6 +94,11 @@ GuiScraperSearch::GuiScraperSearch( (mWindow, "GENRE:", font, mdLblColor), mMD_Genre)); mMD_Pairs.push_back(MetaDataPair(std::make_shared (mWindow, "PLAYERS:", font, mdLblColor), mMD_Players)); + // If no rating is being scraped, add a filler to make sure the fonts keep the same + // size and the GUI looks consistent. + if (!mScrapeRatings) + mMD_Pairs.push_back(MetaDataPair(std::make_shared + (mWindow, "", font, mdLblColor), mMD_Filler)); mMD_Grid = std::make_shared(mWindow, Vector2i(2, (int)mMD_Pairs.size()*2 - 1)); @@ -192,8 +202,7 @@ void GuiScraperSearch::resizeMetadata() mMD_Grid->setColWidthPerc(0, maxLblWidth / mMD_Grid->getSize().x()); - if (Settings::getInstance()->getBool("ScrapeRatings") && - Settings::getInstance()->getString("Scraper") != "thegamesdb") { + if (mScrapeRatings) { // Rating is manually sized. mMD_Rating->setSize(mMD_Grid->getColWidth(1), fontLbl->getHeight() * 0.65f); mMD_Grid->onSizeChanged(); @@ -391,8 +400,7 @@ void GuiScraperSearch::updateInfoPane() } // Metadata. - if (Settings::getInstance()->getBool("ScrapeRatings") && - Settings::getInstance()->getString("Scraper") != "thegamesdb") { + if (mScrapeRatings) { mMD_Rating->setValue(Utils::String::toUpper(res.mdl.get("rating"))); mMD_Rating->setOpacity(255); } @@ -409,8 +417,7 @@ void GuiScraperSearch::updateInfoPane() mResultThumbnail->setImage(""); // Metadata. - if (Settings::getInstance()->getBool("ScrapeRatings") && - Settings::getInstance()->getString("Scraper") != "thegamesdb") { + if (mScrapeRatings) { mMD_Rating->setValue(""); mMD_Rating->setOpacity(0); } @@ -439,11 +446,10 @@ void GuiScraperSearch::render(const Transform4x4f& parentTrans) Transform4x4f trans = parentTrans * getTransform(); renderChildren(trans); + Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000009, 0x00000009); if (mBlockAccept) { Renderer::setMatrix(trans); - Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000011, 0x00000011); - mBusyAnim.render(trans); } } diff --git a/es-app/src/guis/GuiScraperSearch.h b/es-app/src/guis/GuiScraperSearch.h index 636451bbb..44360bc83 100644 --- a/es-app/src/guis/GuiScraperSearch.h +++ b/es-app/src/guis/GuiScraperSearch.h @@ -96,6 +96,7 @@ private: std::shared_ptr mMD_Publisher; std::shared_ptr mMD_Genre; std::shared_ptr mMD_Players; + std::shared_ptr mMD_Filler; // Label-component pair. struct MetaDataPair { @@ -117,6 +118,7 @@ private: std::function mCancelCallback; bool mBlockAccept; bool mFoundGame; + bool mScrapeRatings; std::unique_ptr mSearchHandle; std::unique_ptr mMDRetrieveURLsHandle;