mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35:38 +00:00
Added RatingComponent support to the system view.
This commit is contained in:
parent
44fe2f8fe7
commit
6f6f388257
|
@ -487,8 +487,17 @@ void SystemView::populate()
|
||||||
elements.dateTimeComponents.back()->setDefaultZIndex(40.0f);
|
elements.dateTimeComponents.back()->setDefaultZIndex(40.0f);
|
||||||
elements.dateTimeComponents.back()->applyTheme(
|
elements.dateTimeComponents.back()->applyTheme(
|
||||||
theme, "system", element.first, ThemeFlags::ALL);
|
theme, "system", element.first, ThemeFlags::ALL);
|
||||||
|
elements.dateTimeComponents.back()->setVisible(false);
|
||||||
elements.children.emplace_back(elements.dateTimeComponents.back().get());
|
elements.children.emplace_back(elements.dateTimeComponents.back().get());
|
||||||
}
|
}
|
||||||
|
else if (element.second.type == "rating") {
|
||||||
|
elements.ratingComponents.emplace_back(std::make_unique<RatingComponent>());
|
||||||
|
elements.ratingComponents.back()->setDefaultZIndex(45.0f);
|
||||||
|
elements.ratingComponents.back()->applyTheme(theme, "system", element.first,
|
||||||
|
ThemeFlags::ALL);
|
||||||
|
elements.ratingComponents.back()->setVisible(false);
|
||||||
|
elements.children.emplace_back(elements.ratingComponents.back().get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -631,8 +640,10 @@ void SystemView::updateGameSelectors()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
||||||
if (selector->getSelectorName() == imageSelector)
|
if (selector->getSelectorName() == imageSelector) {
|
||||||
gameSelector = selector.get();
|
gameSelector = selector.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gameSelector == nullptr) {
|
if (gameSelector == nullptr) {
|
||||||
LOG(LogWarning)
|
LOG(LogWarning)
|
||||||
|
@ -745,8 +756,10 @@ void SystemView::updateGameSelectors()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
||||||
if (selector->getSelectorName() == videoSelector)
|
if (selector->getSelectorName() == videoSelector) {
|
||||||
gameSelector = selector.get();
|
gameSelector = selector.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gameSelector == nullptr) {
|
if (gameSelector == nullptr) {
|
||||||
LOG(LogWarning)
|
LOG(LogWarning)
|
||||||
|
@ -781,8 +794,10 @@ void SystemView::updateGameSelectors()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
||||||
if (selector->getSelectorName() == imageSelector)
|
if (selector->getSelectorName() == imageSelector) {
|
||||||
gameSelector = selector.get();
|
gameSelector = selector.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gameSelector == nullptr) {
|
if (gameSelector == nullptr) {
|
||||||
LOG(LogWarning)
|
LOG(LogWarning)
|
||||||
|
@ -894,8 +909,10 @@ void SystemView::updateGameSelectors()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
||||||
if (selector->getSelectorName() == textSelector)
|
if (selector->getSelectorName() == textSelector) {
|
||||||
gameSelector = selector.get();
|
gameSelector = selector.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gameSelector == nullptr) {
|
if (gameSelector == nullptr) {
|
||||||
LOG(LogWarning)
|
LOG(LogWarning)
|
||||||
|
@ -956,8 +973,10 @@ void SystemView::updateGameSelectors()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
||||||
if (selector->getSelectorName() == dateTimeSelector)
|
if (selector->getSelectorName() == dateTimeSelector) {
|
||||||
gameSelector = selector.get();
|
gameSelector = selector.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gameSelector == nullptr) {
|
if (gameSelector == nullptr) {
|
||||||
LOG(LogWarning) << "SystemView::updateGameSelectors(): Invalid gameselector \""
|
LOG(LogWarning) << "SystemView::updateGameSelectors(): Invalid gameselector \""
|
||||||
|
@ -973,6 +992,7 @@ void SystemView::updateGameSelectors()
|
||||||
gameSelector->refreshGames();
|
gameSelector->refreshGames();
|
||||||
std::vector<FileData*> games {gameSelector->getGames()};
|
std::vector<FileData*> games {gameSelector->getGames()};
|
||||||
if (!games.empty()) {
|
if (!games.empty()) {
|
||||||
|
dateTime->setVisible(true);
|
||||||
const std::string metadata {dateTime->getThemeMetadata()};
|
const std::string metadata {dateTime->getThemeMetadata()};
|
||||||
if (metadata == "releasedate")
|
if (metadata == "releasedate")
|
||||||
dateTime->setValue(games.front()->metadata.get("releasedate"));
|
dateTime->setValue(games.front()->metadata.get("releasedate"));
|
||||||
|
@ -980,7 +1000,47 @@ void SystemView::updateGameSelectors()
|
||||||
dateTime->setValue(games.front()->metadata.get("lastplayed"));
|
dateTime->setValue(games.front()->metadata.get("lastplayed"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dateTime->setValue("19700101T000000");
|
dateTime->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& rating : mSystemElements[cursor].ratingComponents) {
|
||||||
|
GameSelectorComponent* gameSelector {nullptr};
|
||||||
|
if (multipleSelectors) {
|
||||||
|
const std::string& ratingSelector {rating->getThemeGameSelector()};
|
||||||
|
if (ratingSelector == "") {
|
||||||
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
||||||
|
LOG(LogWarning)
|
||||||
|
<< "SystemView::updateGameSelectors(): Multiple gameselector "
|
||||||
|
"elements defined but rating element does not state which one to "
|
||||||
|
"use, selecting first entry";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (auto& selector : mSystemElements[cursor].gameSelectors) {
|
||||||
|
if (selector->getSelectorName() == ratingSelector) {
|
||||||
|
gameSelector = selector.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gameSelector == nullptr) {
|
||||||
|
LOG(LogWarning)
|
||||||
|
<< "SystemView::updateGameSelectors(): Invalid gameselector \""
|
||||||
|
<< ratingSelector << "\" defined for rating element, selecting first entry";
|
||||||
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gameSelector = mSystemElements[cursor].gameSelectors.front().get();
|
||||||
|
}
|
||||||
|
gameSelector->refreshGames();
|
||||||
|
std::vector<FileData*> games {gameSelector->getGames()};
|
||||||
|
if (!games.empty()) {
|
||||||
|
rating->setVisible(true);
|
||||||
|
rating->setValue(games.front()->metadata.get("rating"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rating->setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "components/GIFAnimComponent.h"
|
#include "components/GIFAnimComponent.h"
|
||||||
#include "components/GameSelectorComponent.h"
|
#include "components/GameSelectorComponent.h"
|
||||||
#include "components/LottieAnimComponent.h"
|
#include "components/LottieAnimComponent.h"
|
||||||
|
#include "components/RatingComponent.h"
|
||||||
#include "components/TextComponent.h"
|
#include "components/TextComponent.h"
|
||||||
#include "components/TextListComponent.h"
|
#include "components/TextListComponent.h"
|
||||||
#include "components/VideoFFmpegComponent.h"
|
#include "components/VideoFFmpegComponent.h"
|
||||||
|
@ -35,13 +36,14 @@ struct SystemViewElements {
|
||||||
std::vector<GuiComponent*> legacyExtras;
|
std::vector<GuiComponent*> legacyExtras;
|
||||||
std::vector<GuiComponent*> children;
|
std::vector<GuiComponent*> children;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<TextComponent>> gameCountComponents;
|
|
||||||
std::vector<std::unique_ptr<TextComponent>> textComponents;
|
|
||||||
std::vector<std::unique_ptr<DateTimeComponent>> dateTimeComponents;
|
|
||||||
std::vector<std::unique_ptr<ImageComponent>> imageComponents;
|
std::vector<std::unique_ptr<ImageComponent>> imageComponents;
|
||||||
std::vector<std::unique_ptr<VideoFFmpegComponent>> videoComponents;
|
std::vector<std::unique_ptr<VideoFFmpegComponent>> videoComponents;
|
||||||
std::vector<std::unique_ptr<LottieAnimComponent>> lottieAnimComponents;
|
std::vector<std::unique_ptr<LottieAnimComponent>> lottieAnimComponents;
|
||||||
std::vector<std::unique_ptr<GIFAnimComponent>> GIFAnimComponents;
|
std::vector<std::unique_ptr<GIFAnimComponent>> GIFAnimComponents;
|
||||||
|
std::vector<std::unique_ptr<TextComponent>> gameCountComponents;
|
||||||
|
std::vector<std::unique_ptr<TextComponent>> textComponents;
|
||||||
|
std::vector<std::unique_ptr<DateTimeComponent>> dateTimeComponents;
|
||||||
|
std::vector<std::unique_ptr<RatingComponent>> ratingComponents;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SystemView : public GuiComponent
|
class SystemView : public GuiComponent
|
||||||
|
|
|
@ -229,6 +229,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"rotation", FLOAT},
|
{"rotation", FLOAT},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
|
{"gameselector", STRING},
|
||||||
{"color", COLOR},
|
{"color", COLOR},
|
||||||
{"filledPath", PATH},
|
{"filledPath", PATH},
|
||||||
{"unfilledPath", PATH},
|
{"unfilledPath", PATH},
|
||||||
|
|
Loading…
Reference in a new issue