From 57a594225a08dcf3bfaa6f325956f90cb20ce91c Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 13 Feb 2022 22:30:03 +0100 Subject: [PATCH] Added initial game selector support to SystemView. --- es-app/src/views/SystemView.cpp | 49 +++++++++++++++++++++++++++++++-- es-app/src/views/SystemView.h | 8 +++--- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 46e51e2de..1d2c24a15 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -63,6 +63,7 @@ void SystemView::goToSystem(SystemData* system, bool animate) { mCarousel->setCursor(system); updateGameCount(); + updateGameSelector(); if (!animate) finishSystemAnimation(0); @@ -173,11 +174,10 @@ HelpStyle SystemView::getHelpStyle() void SystemView::onCursorChanged(const CursorState& /*state*/) { - // Update help style. updateHelpPrompts(); + updateGameSelector(); int scrollVelocity {mCarousel->getScrollingVelocity()}; - float startPos {mCamOffset}; float posMax {static_cast(mCarousel->getNumEntries())}; float target {static_cast(mCarousel->getCursor())}; @@ -336,6 +336,12 @@ void SystemView::populate() elements.name = it->getName(); elements.fullName = it->getFullName(); for (auto& element : theme->getViewElements("system").elements) { + if (element.second.type == "gameselector") { + elements.gameSelector = std::make_unique(it); + elements.gameSelector->applyTheme(theme, "system", element.first, + ThemeFlags::ALL); + elements.gameSelector->refreshGames(); + } if (element.second.type == "carousel") { mCarousel->applyTheme(theme, "system", element.first, ThemeFlags::ALL); if (element.second.has("logo")) @@ -420,6 +426,8 @@ void SystemView::populate() } } + updateGameSelector(); + if (mCarousel->getNumEntries() == 0) { // Something is wrong, there is not a single system to show, check if UI mode is not full. if (!UIModeController::getInstance()->isUIModeFull()) { @@ -489,6 +497,43 @@ void SystemView::updateGameCount() } } +void SystemView::updateGameSelector() +{ + int cursor {mCarousel->getCursor()}; + + if (mSystemElements[cursor].gameSelector != nullptr) { + mSystemElements[mCarousel->getCursor()].gameSelector->refreshGames(); + std::vector games {mSystemElements[cursor].gameSelector->getGames()}; + if (!games.empty()) { + if (!mLegacyMode) { + for (auto& image : mSystemElements[cursor].imageComponents) { + const std::string imageType {image->getThemeImageType()}; + if (imageType == "image") + image->setImage(games.front()->getImagePath()); + else if (image->getThemeImageType() == "miximage") + image->setImage(games.front()->getMiximagePath()); + else if (image->getThemeImageType() == "marquee") + image->setImage(games.front()->getMarqueePath()); + else if (image->getThemeImageType() == "screenshot") + image->setImage(games.front()->getScreenshotPath()); + else if (image->getThemeImageType() == "titlescreen") + image->setImage(games.front()->getTitleScreenPath()); + else if (image->getThemeImageType() == "cover") + image->setImage(games.front()->getCoverPath()); + else if (image->getThemeImageType() == "backcover") + image->setImage(games.front()->getBackCoverPath()); + else if (image->getThemeImageType() == "3dbox") + image->setImage(games.front()->get3DBoxPath()); + else if (image->getThemeImageType() == "fanart") + image->setImage(games.front()->getFanArtPath()); + else if (image->getThemeImageType() == "thumbnail") + image->setImage(games.front()->getThumbnailPath()); + } + } + } + } +} + void SystemView::legacyApplyTheme(const std::shared_ptr& theme) { if (theme->hasView("system")) diff --git a/es-app/src/views/SystemView.h b/es-app/src/views/SystemView.h index 631119100..7f3d88ee5 100644 --- a/es-app/src/views/SystemView.h +++ b/es-app/src/views/SystemView.h @@ -9,13 +9,13 @@ #ifndef ES_APP_VIEWS_SYSTEM_VIEW_H #define ES_APP_VIEWS_SYSTEM_VIEW_H +#include "FileData.h" #include "GuiComponent.h" #include "Sound.h" #include "SystemData.h" #include "components/CarouselComponent.h" -#include "components/DateTimeComponent.h" +#include "components/GameSelectorComponent.h" #include "components/LottieComponent.h" -#include "components/ScrollableContainer.h" #include "components/TextComponent.h" #include "components/TextListComponent.h" #include "components/VideoFFmpegComponent.h" @@ -28,6 +28,7 @@ class SystemData; struct SystemViewElements { std::string name; std::string fullName; + std::unique_ptr gameSelector; std::vector legacyExtras; std::vector children; @@ -36,8 +37,6 @@ struct SystemViewElements { std::vector> imageComponents; std::vector> videoComponents; std::vector> lottieAnimComponents; - std::vector> containerComponents; - std::vector> containerTextComponents; }; class SystemView : public GuiComponent @@ -78,6 +77,7 @@ protected: private: void populate(); void updateGameCount(); + void updateGameSelector(); void legacyApplyTheme(const std::shared_ptr& theme); void renderElements(const glm::mat4& parentTrans, bool abovePrimary);