diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 663f6b6c9..5f6e66998 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -160,6 +160,9 @@ void SystemView::update(int deltaTime) for (auto& anim : mSystemElements[mPrimary->getCursor()].GIFAnimComponents) anim->update(deltaTime); + for (auto& container : mSystemElements[mPrimary->getCursor()].containerComponents) + container->update(deltaTime); + GuiComponent::update(deltaTime); } @@ -279,6 +282,9 @@ void SystemView::onCursorChanged(const CursorState& state) video->pauseVideoPlayer(); } + for (auto& container : mSystemElements[mPrimary->getCursor()].containerComponents) + container->reset(); + // This is needed to avoid erratic camera movements during extreme navigation input when using // slide transitions. This should very rarely occur during normal application usage. if (transitionAnim == ViewTransitionAnimation::SLIDE) { @@ -651,9 +657,19 @@ void SystemView::populate() else if (element.second.type == "text" && !(element.second.has("visible") && !element.second.get("visible"))) { + // Set as container by default if metadata type is "description". + bool container {false}; + if (element.second.has("container")) { + container = element.second.get("container"); + } + else if (element.second.has("metadata") && + element.second.get("metadata") == "description") { + container = true; + } if (element.second.has("systemdata") && element.second.get("systemdata").substr(0, 9) == "gamecount") { + // A container can't be used if systemdata is set to a gamecount value. if (element.second.has("systemdata")) { elements.gameCountComponents.emplace_back( std::make_unique()); @@ -665,11 +681,39 @@ void SystemView::populate() } } else { - elements.textComponents.emplace_back(std::make_unique()); - elements.textComponents.back()->setDefaultZIndex(40.0f); - elements.textComponents.back()->applyTheme( - theme, "system", element.first, ThemeFlags::ALL); - elements.children.emplace_back(elements.textComponents.back().get()); + if (container) { + elements.containerComponents.push_back( + std::make_unique()); + elements.containerComponents.back()->setDefaultZIndex(40.0f); + elements.containerTextComponents.push_back( + std::make_unique()); + elements.containerTextComponents.back()->setDefaultZIndex(40.0f); + elements.containerComponents.back()->addChild( + elements.containerTextComponents.back().get()); + elements.containerComponents.back()->applyTheme( + theme, "system", element.first, + ThemeFlags::POSITION | ThemeFlags::SIZE | ThemeFlags::Z_INDEX | + ThemeFlags::VISIBLE); + elements.containerComponents.back()->setAutoScroll(true); + elements.containerTextComponents.back()->setSize( + elements.containerComponents.back()->getSize().x, 0.0f); + elements.containerTextComponents.back()->applyTheme( + theme, "system", element.first, + ThemeFlags::ALL ^ ThemeFlags::POSITION ^ ThemeFlags::ORIGIN ^ + ThemeFlags::Z_INDEX ^ ThemeFlags::SIZE ^ + ThemeFlags::VISIBLE ^ ThemeFlags::ROTATION); + elements.children.emplace_back( + elements.containerComponents.back().get()); + } + else { + elements.textComponents.emplace_back( + std::make_unique()); + elements.textComponents.back()->setDefaultZIndex(40.0f); + elements.textComponents.back()->applyTheme( + theme, "system", element.first, ThemeFlags::ALL); + elements.children.emplace_back( + elements.textComponents.back().get()); + } } } else if (element.second.type == "datetime" && @@ -712,6 +756,12 @@ void SystemView::populate() const std::unique_ptr& b) { return b->getZIndex() > a->getZIndex(); }); + std::stable_sort(elements.containerTextComponents.begin(), + elements.containerTextComponents.end(), + [](const std::unique_ptr& a, + const std::unique_ptr& b) { + return b->getZIndex() > a->getZIndex(); + }); mSystemElements.emplace_back(std::move(elements)); mSystemElements.back().helpStyle.applyTheme(theme, "system"); } @@ -818,6 +868,16 @@ void SystemView::populate() text->setValue(text->getThemeSystemdata()); } } + for (auto& containerText : elements.containerTextComponents) { + if (containerText->getThemeSystemdata() != "") { + if (containerText->getThemeSystemdata() == "name") + containerText->setValue(elements.name); + else if (containerText->getThemeSystemdata() == "fullname") + containerText->setValue(elements.fullName); + else + containerText->setValue(containerText->getThemeSystemdata()); + } + } } if (mPrimary->getNumEntries() == 0) { @@ -1192,9 +1252,10 @@ void SystemView::updateGameSelectors() } } - for (auto& text : mSystemElements[cursor].textComponents) { + auto textSelectorFunc = [this, cursor, + multipleSelectors](std::unique_ptr& text) { if (text->getThemeMetadata() == "") - continue; + return; GameSelectorComponent* gameSelector {nullptr}; if (multipleSelectors) { const std::string& textSelector {text->getThemeGameSelector()}; @@ -1316,7 +1377,13 @@ void SystemView::updateGameSelectors() else { text->setValue(""); } - } + }; + + for (auto& text : mSystemElements[cursor].textComponents) + textSelectorFunc(text); + + for (auto& containerText : mSystemElements[cursor].containerTextComponents) + textSelectorFunc(containerText); for (auto& dateTime : mSystemElements[cursor].dateTimeComponents) { if (dateTime->getThemeMetadata() == "") diff --git a/es-app/src/views/SystemView.h b/es-app/src/views/SystemView.h index b3bb3f9b6..d53314de6 100644 --- a/es-app/src/views/SystemView.h +++ b/es-app/src/views/SystemView.h @@ -18,6 +18,7 @@ #include "components/GameSelectorComponent.h" #include "components/LottieAnimComponent.h" #include "components/RatingComponent.h" +#include "components/ScrollableContainer.h" #include "components/TextComponent.h" #include "components/VideoFFmpegComponent.h" #include "components/primary/CarouselComponent.h" @@ -123,6 +124,8 @@ private: std::vector> videoComponents; std::vector> lottieAnimComponents; std::vector> GIFAnimComponents; + std::vector> containerComponents; + std::vector> containerTextComponents; std::vector> gameCountComponents; std::vector> textComponents; std::vector> dateTimeComponents;