Added gameselectorEntry properties to a number of elements.

This commit is contained in:
Leon Styhre 2022-12-15 18:23:48 +01:00
parent da3fb9a825
commit ae6c062984
6 changed files with 85 additions and 50 deletions

View file

@ -878,12 +878,12 @@ void SystemView::updateGameSelectors()
if (mLegacyMode) if (mLegacyMode)
return; return;
int cursor {mPrimary->getCursor()}; const int cursor {mPrimary->getCursor()};
if (mSystemElements[cursor].gameSelectors.size() == 0) if (mSystemElements[cursor].gameSelectors.size() == 0)
return; return;
bool multipleSelectors {mSystemElements[cursor].gameSelectors.size() > 1}; const bool multipleSelectors {mSystemElements[cursor].gameSelectors.size() > 1};
for (auto& image : mSystemElements[cursor].imageComponents) { for (auto& image : mSystemElements[cursor].imageComponents) {
if (image->getThemeImageTypes().size() == 0) if (image->getThemeImageTypes().size() == 0)
@ -915,76 +915,79 @@ void SystemView::updateGameSelectors()
else { else {
gameSelector = mSystemElements[cursor].gameSelectors.front().get(); gameSelector = mSystemElements[cursor].gameSelectors.front().get();
} }
const size_t gameSelectorEntry {static_cast<size_t>(
glm::clamp(image->getThemeGameSelectorEntry(), 0u,
static_cast<unsigned int>(gameSelector->getGameCount() - 1)))};
gameSelector->refreshGames(); gameSelector->refreshGames();
std::vector<FileData*> games {gameSelector->getGames()}; std::vector<FileData*> games {gameSelector->getGames()};
if (!games.empty()) { if (games.size() > gameSelectorEntry) {
std::string path; std::string path;
for (auto& imageType : image->getThemeImageTypes()) { for (auto& imageType : image->getThemeImageTypes()) {
if (imageType == "image") { if (imageType == "image") {
path = games.front()->getImagePath(); path = games.at(gameSelectorEntry)->getImagePath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
} }
} }
else if (imageType == "miximage") { else if (imageType == "miximage") {
path = games.front()->getMiximagePath(); path = games.at(gameSelectorEntry)->getMiximagePath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
} }
} }
else if (imageType == "marquee") { else if (imageType == "marquee") {
path = games.front()->getMarqueePath(); path = games.at(gameSelectorEntry)->getMarqueePath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
} }
} }
else if (imageType == "screenshot") { else if (imageType == "screenshot") {
path = games.front()->getScreenshotPath(); path = games.at(gameSelectorEntry)->getScreenshotPath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
} }
} }
else if (imageType == "titlescreen") { else if (imageType == "titlescreen") {
path = games.front()->getTitleScreenPath(); path = games.at(gameSelectorEntry)->getTitleScreenPath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
} }
} }
else if (imageType == "cover") { else if (imageType == "cover") {
path = games.front()->getCoverPath(); path = games.at(gameSelectorEntry)->getCoverPath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
} }
} }
else if (imageType == "backcover") { else if (imageType == "backcover") {
path = games.front()->getBackCoverPath(); path = games.at(gameSelectorEntry)->getBackCoverPath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
} }
} }
else if (imageType == "3dbox") { else if (imageType == "3dbox") {
path = games.front()->get3DBoxPath(); path = games.at(gameSelectorEntry)->get3DBoxPath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
} }
} }
else if (imageType == "physicalmedia") { else if (imageType == "physicalmedia") {
path = games.front()->getPhysicalMediaPath(); path = games.at(gameSelectorEntry)->getPhysicalMediaPath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
} }
} }
else if (imageType == "fanart") { else if (imageType == "fanart") {
path = games.front()->getFanArtPath(); path = games.at(gameSelectorEntry)->getFanArtPath();
if (path != "") { if (path != "") {
image->setImage(path); image->setImage(path);
break; break;
@ -1031,10 +1034,13 @@ void SystemView::updateGameSelectors()
else { else {
gameSelector = mSystemElements[cursor].gameSelectors.front().get(); gameSelector = mSystemElements[cursor].gameSelectors.front().get();
} }
const size_t gameSelectorEntry {static_cast<size_t>(
glm::clamp(video->getThemeGameSelectorEntry(), 0u,
static_cast<unsigned int>(gameSelector->getGameCount() - 1)))};
gameSelector->refreshGames(); gameSelector->refreshGames();
std::vector<FileData*> games {gameSelector->getGames()}; std::vector<FileData*> games {gameSelector->getGames()};
if (!games.empty()) { if (games.size() > gameSelectorEntry) {
if (!video->setVideo(games.front()->getVideoPath())) if (!video->setVideo(games.at(gameSelectorEntry)->getVideoPath()))
video->setDefaultVideo(); video->setDefaultVideo();
} }
} }
@ -1069,76 +1075,79 @@ void SystemView::updateGameSelectors()
else { else {
gameSelector = mSystemElements[cursor].gameSelectors.front().get(); gameSelector = mSystemElements[cursor].gameSelectors.front().get();
} }
const size_t gameSelectorEntry {static_cast<size_t>(
glm::clamp(video->getThemeGameSelectorEntry(), 0u,
static_cast<unsigned int>(gameSelector->getGameCount() - 1)))};
gameSelector->refreshGames(); gameSelector->refreshGames();
std::vector<FileData*> games {gameSelector->getGames()}; std::vector<FileData*> games {gameSelector->getGames()};
if (!games.empty()) { if (games.size() > gameSelectorEntry) {
std::string path; std::string path;
for (auto& imageType : video->getThemeImageTypes()) { for (auto& imageType : video->getThemeImageTypes()) {
if (imageType == "image") { if (imageType == "image") {
path = games.front()->getImagePath(); path = games.at(gameSelectorEntry)->getImagePath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
} }
} }
else if (imageType == "miximage") { else if (imageType == "miximage") {
path = games.front()->getMiximagePath(); path = games.at(gameSelectorEntry)->getMiximagePath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
} }
} }
else if (imageType == "marquee") { else if (imageType == "marquee") {
path = games.front()->getMarqueePath(); path = games.at(gameSelectorEntry)->getMarqueePath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
} }
} }
else if (imageType == "screenshot") { else if (imageType == "screenshot") {
path = games.front()->getScreenshotPath(); path = games.at(gameSelectorEntry)->getScreenshotPath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
} }
} }
else if (imageType == "titlescreen") { else if (imageType == "titlescreen") {
path = games.front()->getTitleScreenPath(); path = games.at(gameSelectorEntry)->getTitleScreenPath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
} }
} }
else if (imageType == "cover") { else if (imageType == "cover") {
path = games.front()->getCoverPath(); path = games.at(gameSelectorEntry)->getCoverPath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
} }
} }
else if (imageType == "backcover") { else if (imageType == "backcover") {
path = games.front()->getBackCoverPath(); path = games.at(gameSelectorEntry)->getBackCoverPath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
} }
} }
else if (imageType == "3dbox") { else if (imageType == "3dbox") {
path = games.front()->get3DBoxPath(); path = games.at(gameSelectorEntry)->get3DBoxPath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
} }
} }
else if (imageType == "physicalmedia") { else if (imageType == "physicalmedia") {
path = games.front()->getPhysicalMediaPath(); path = games.at(gameSelectorEntry)->getPhysicalMediaPath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
} }
} }
else if (imageType == "fanart") { else if (imageType == "fanart") {
path = games.front()->getFanArtPath(); path = games.at(gameSelectorEntry)->getFanArtPath();
if (path != "") { if (path != "") {
video->setImage(path); video->setImage(path);
break; break;
@ -1184,37 +1193,45 @@ void SystemView::updateGameSelectors()
else { else {
gameSelector = mSystemElements[cursor].gameSelectors.front().get(); gameSelector = mSystemElements[cursor].gameSelectors.front().get();
} }
const size_t gameSelectorEntry {static_cast<size_t>(
glm::clamp(text->getThemeGameSelectorEntry(), 0u,
static_cast<unsigned int>(gameSelector->getGameCount() - 1)))};
gameSelector->refreshGames(); gameSelector->refreshGames();
std::vector<FileData*> games {gameSelector->getGames()}; std::vector<FileData*> games {gameSelector->getGames()};
if (!games.empty()) { if (games.size() > gameSelectorEntry) {
const std::string metadata {text->getThemeMetadata()}; const std::string metadata {text->getThemeMetadata()};
if (metadata == "name") if (metadata == "name")
text->setValue(games.front()->metadata.get("name")); text->setValue(games.at(gameSelectorEntry)->metadata.get("name"));
if (metadata == "description") if (metadata == "description")
text->setValue(games.front()->metadata.get("desc")); text->setValue(games.at(gameSelectorEntry)->metadata.get("desc"));
if (metadata == "rating") if (metadata == "rating")
text->setValue( text->setValue(RatingComponent::getRatingValue(
RatingComponent::getRatingValue(games.front()->metadata.get("rating"))); games.at(gameSelectorEntry)->metadata.get("rating")));
if (metadata == "developer") if (metadata == "developer")
text->setValue(games.front()->metadata.get("developer")); text->setValue(games.at(gameSelectorEntry)->metadata.get("developer"));
if (metadata == "publisher") if (metadata == "publisher")
text->setValue(games.front()->metadata.get("publisher")); text->setValue(games.at(gameSelectorEntry)->metadata.get("publisher"));
if (metadata == "genre") if (metadata == "genre")
text->setValue(games.front()->metadata.get("genre")); text->setValue(games.at(gameSelectorEntry)->metadata.get("genre"));
if (metadata == "players") if (metadata == "players")
text->setValue(games.front()->metadata.get("players")); text->setValue(games.at(gameSelectorEntry)->metadata.get("players"));
if (metadata == "favorite") if (metadata == "favorite")
text->setValue(games.front()->metadata.get("favorite") == "true" ? "yes" : "no"); text->setValue(
games.at(gameSelectorEntry)->metadata.get("favorite") == "true" ? "yes" : "no");
if (metadata == "completed") if (metadata == "completed")
text->setValue(games.front()->metadata.get("completed") == "true" ? "yes" : "no"); text->setValue(games.at(gameSelectorEntry)->metadata.get("completed") == "true" ?
"yes" :
"no");
if (metadata == "kidgame") if (metadata == "kidgame")
text->setValue(games.front()->metadata.get("kidgame") == "true" ? "yes" : "no"); text->setValue(
games.at(gameSelectorEntry)->metadata.get("kidgame") == "true" ? "yes" : "no");
if (metadata == "broken") if (metadata == "broken")
text->setValue(games.front()->metadata.get("broken") == "true" ? "yes" : "no"); text->setValue(
games.at(gameSelectorEntry)->metadata.get("broken") == "true" ? "yes" : "no");
if (metadata == "playcount") if (metadata == "playcount")
text->setValue(games.front()->metadata.get("playcount")); text->setValue(games.at(gameSelectorEntry)->metadata.get("playcount"));
if (metadata == "altemulator") if (metadata == "altemulator")
text->setValue(games.front()->metadata.get("altemulator")); text->setValue(games.at(gameSelectorEntry)->metadata.get("altemulator"));
} }
else { else {
text->setValue(""); text->setValue("");
@ -1251,15 +1268,18 @@ void SystemView::updateGameSelectors()
else { else {
gameSelector = mSystemElements[cursor].gameSelectors.front().get(); gameSelector = mSystemElements[cursor].gameSelectors.front().get();
} }
const size_t gameSelectorEntry {static_cast<size_t>(
glm::clamp(dateTime->getThemeGameSelectorEntry(), 0u,
static_cast<unsigned int>(gameSelector->getGameCount() - 1)))};
gameSelector->refreshGames(); gameSelector->refreshGames();
std::vector<FileData*> games {gameSelector->getGames()}; std::vector<FileData*> games {gameSelector->getGames()};
if (!games.empty()) { if (games.size() > gameSelectorEntry) {
dateTime->setVisible(true); 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.at(gameSelectorEntry)->metadata.get("releasedate"));
if (metadata == "lastplayed") if (metadata == "lastplayed")
dateTime->setValue(games.front()->metadata.get("lastplayed")); dateTime->setValue(games.at(gameSelectorEntry)->metadata.get("lastplayed"));
} }
else { else {
dateTime->setVisible(false); dateTime->setVisible(false);
@ -1295,11 +1315,14 @@ void SystemView::updateGameSelectors()
else { else {
gameSelector = mSystemElements[cursor].gameSelectors.front().get(); gameSelector = mSystemElements[cursor].gameSelectors.front().get();
} }
const size_t gameSelectorEntry {static_cast<size_t>(
glm::clamp(rating->getThemeGameSelectorEntry(), 0u,
static_cast<unsigned int>(gameSelector->getGameCount() - 1)))};
gameSelector->refreshGames(); gameSelector->refreshGames();
std::vector<FileData*> games {gameSelector->getGames()}; std::vector<FileData*> games {gameSelector->getGames()};
if (!games.empty()) { if (games.size() > gameSelectorEntry) {
rating->setVisible(true); rating->setVisible(true);
rating->setValue(games.front()->metadata.get("rating")); rating->setValue(games.at(gameSelectorEntry)->metadata.get("rating"));
} }
else { else {
rating->setVisible(false); rating->setVisible(false);

View file

@ -19,6 +19,7 @@
GuiComponent::GuiComponent() GuiComponent::GuiComponent()
: mWindow {Window::getInstance()} : mWindow {Window::getInstance()}
, mParent {nullptr} , mParent {nullptr}
, mThemeGameSelectorEntry {0}
, mColor {0} , mColor {0}
, mColorShift {0} , mColorShift {0}
, mColorShiftEnd {0} , mColorShiftEnd {0}
@ -398,6 +399,9 @@ void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
if (properties && elem->has("gameselector")) if (properties && elem->has("gameselector"))
mThemeGameSelector = elem->get<std::string>("gameselector"); mThemeGameSelector = elem->get<std::string>("gameselector");
if (properties && elem->has("gameselectorEntry"))
mThemeGameSelectorEntry = elem->get<unsigned int>("gameselectorEntry");
} }
void GuiComponent::updateHelpPrompts() void GuiComponent::updateHelpPrompts()

View file

@ -259,7 +259,8 @@ public:
const std::string& getThemeMetadata() { return mThemeMetadata; } const std::string& getThemeMetadata() { return mThemeMetadata; }
void setThemeMetadata(const std::string& text) { mThemeMetadata = text; } void setThemeMetadata(const std::string& text) { mThemeMetadata = text; }
const std::vector<std::string>& getThemeImageTypes() { return mThemeImageTypes; } const std::vector<std::string>& getThemeImageTypes() { return mThemeImageTypes; }
const std::string& getThemeGameSelector() { return mThemeGameSelector; } const std::string& getThemeGameSelector() const { return mThemeGameSelector; }
const unsigned int getThemeGameSelectorEntry() const { return mThemeGameSelectorEntry; }
virtual std::shared_ptr<Font> getFont() const { return nullptr; } virtual std::shared_ptr<Font> getFont() const { return nullptr; }
@ -325,6 +326,7 @@ protected:
std::string mThemeSystemdata; std::string mThemeSystemdata;
std::string mThemeMetadata; std::string mThemeMetadata;
std::string mThemeGameSelector; std::string mThemeGameSelector;
unsigned int mThemeGameSelectorEntry;
unsigned int mColor; unsigned int mColor;
unsigned int mColorShift; unsigned int mColorShift;

View file

@ -253,6 +253,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"imageType", STRING}, {"imageType", STRING},
{"metadataElement", BOOLEAN}, {"metadataElement", BOOLEAN},
{"gameselector", STRING}, {"gameselector", STRING},
{"gameselectorEntry", UNSIGNED_INTEGER},
{"tile", BOOLEAN}, {"tile", BOOLEAN},
{"tileSize", NORMALIZED_PAIR}, {"tileSize", NORMALIZED_PAIR},
{"tileHorizontalAlignment", STRING}, {"tileHorizontalAlignment", STRING},
@ -278,6 +279,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"imageType", STRING}, {"imageType", STRING},
{"metadataElement", BOOLEAN}, {"metadataElement", BOOLEAN},
{"gameselector", STRING}, {"gameselector", STRING},
{"gameselectorEntry", UNSIGNED_INTEGER},
{"audio", BOOLEAN}, {"audio", BOOLEAN},
{"interpolation", STRING}, {"interpolation", STRING},
{"color", COLOR}, {"color", COLOR},
@ -347,6 +349,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"metadata", STRING}, {"metadata", STRING},
{"metadataElement", BOOLEAN}, {"metadataElement", BOOLEAN},
{"gameselector", STRING}, {"gameselector", STRING},
{"gameselectorEntry", UNSIGNED_INTEGER},
{"container", BOOLEAN}, {"container", BOOLEAN},
{"containerVerticalSnap", BOOLEAN}, {"containerVerticalSnap", BOOLEAN},
{"containerScrollSpeed", FLOAT}, {"containerScrollSpeed", FLOAT},
@ -373,6 +376,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"rotationOrigin", NORMALIZED_PAIR}, {"rotationOrigin", NORMALIZED_PAIR},
{"metadata", STRING}, {"metadata", STRING},
{"gameselector", STRING}, {"gameselector", STRING},
{"gameselectorEntry", UNSIGNED_INTEGER},
{"fontPath", PATH}, {"fontPath", PATH},
{"fontSize", FLOAT}, {"fontSize", FLOAT},
{"horizontalAlignment", STRING}, {"horizontalAlignment", STRING},
@ -411,6 +415,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"rotation", FLOAT}, {"rotation", FLOAT},
{"rotationOrigin", NORMALIZED_PAIR}, {"rotationOrigin", NORMALIZED_PAIR},
{"gameselector", STRING}, {"gameselector", STRING},
{"gameselectorEntry", UNSIGNED_INTEGER},
{"interpolation", STRING}, {"interpolation", STRING},
{"color", COLOR}, {"color", COLOR},
{"filledPath", PATH}, {"filledPath", PATH},

View file

@ -45,6 +45,7 @@ public:
const bool getNeedsRefresh() { return mNeedsRefresh; } const bool getNeedsRefresh() { return mNeedsRefresh; }
const GameSelection getGameSelection() const { return mGameSelection; } const GameSelection getGameSelection() const { return mGameSelection; }
const std::string& getSelectorName() const { return mSelectorName; } const std::string& getSelectorName() const { return mSelectorName; }
const int getGameCount() const { return mGameCount; }
void refreshGames() void refreshGames()
{ {

View file

@ -3,7 +3,7 @@
// EmulationStation Desktop Edition // EmulationStation Desktop Edition
// IList.h // IList.h
// //
// List base class, used by both the gamelist views and the menu. // List base class, used by the system view, gamelist view and menu system.
// //
#ifndef ES_CORE_COMPONENTS_ILIST_H #ifndef ES_CORE_COMPONENTS_ILIST_H
@ -284,7 +284,7 @@ protected:
} }
// Actually perform the scrolling. // Actually perform the scrolling.
for (int i = 0; i < scrollCount; ++i) for (int i {0}; i < scrollCount; ++i)
scroll(mScrollVelocity); scroll(mScrollVelocity);
} }
@ -300,7 +300,7 @@ protected:
} }
std::string titleIndex; std::string titleIndex;
bool favoritesSorting; bool favoritesSorting {true};
if (getSelected()->getSystem()->isCustomCollection()) if (getSelected()->getSystem()->isCustomCollection())
favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom"); favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom");