diff --git a/es-core/src/components/DateTimeComponent.cpp b/es-core/src/components/DateTimeComponent.cpp index 37667e4da..485e895b6 100644 --- a/es-core/src/components/DateTimeComponent.cpp +++ b/es-core/src/components/DateTimeComponent.cpp @@ -172,8 +172,18 @@ void DateTimeComponent::applyTheme(const std::shared_ptr& theme, << str << "\""; } - if (properties & METADATA && elem->has("metadata")) - mThemeMetadata = elem->get("metadata"); + if (properties & METADATA && elem->has("metadata")) { + mThemeMetadata = ""; + const std::string metadata {elem->get("metadata")}; + if (metadata == "releasedate" || metadata == "lastplayed") { + mThemeMetadata = metadata; + } + else { + LOG(LogWarning) << "DateTimeComponent: Invalid theme configuration, property " + " defined as \"" + << metadata << "\""; + } + } if (mThemeMetadata == "lastplayed") setDisplayRelative(true); diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index 7b0c1cee9..fed620366 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -450,11 +450,37 @@ void TextComponent::applyTheme(const std::shared_ptr& theme, if (properties & TEXT && elem->has("text")) setText(elem->get("text")); - if (properties & METADATA && elem->has("systemdata")) - mThemeSystemdata = elem->get("systemdata"); + if (properties & METADATA && elem->has("systemdata")) { + mThemeSystemdata = ""; + const std::string systemdata {elem->get("systemdata")}; + for (auto& type : systemdataTypes) { + if (type == systemdata) { + mThemeSystemdata = type; + break; + } + } + if (mThemeSystemdata == "") { + LOG(LogWarning) + << "TextComponent: Invalid theme configuration, property defined as \"" + << systemdata << "\""; + } + } - if (properties & METADATA && elem->has("metadata")) - mThemeMetadata = elem->get("metadata"); + if (properties & METADATA && elem->has("metadata")) { + mThemeMetadata = ""; + const std::string metadata {elem->get("metadata")}; + for (auto& type : metadataTypes) { + if (type == metadata) { + mThemeMetadata = type; + break; + } + } + if (mThemeMetadata == "") { + LOG(LogWarning) + << "TextComponent: Invalid theme configuration, property defined as \"" + << metadata << "\""; + } + } if (properties & LETTER_CASE && elem->has("letterCase")) { std::string letterCase {elem->get("letterCase")}; diff --git a/es-core/src/components/TextComponent.h b/es-core/src/components/TextComponent.h index 9558f4320..ffba57d96 100644 --- a/es-core/src/components/TextComponent.h +++ b/es-core/src/components/TextComponent.h @@ -91,6 +91,14 @@ private: void calculateExtent(); void onColorChanged(); + static inline std::vector systemdataTypes { + "name", "fullname", "gamecount", "gamecount_games", "gamecount_favorites"}; + + static inline std::vector metadataTypes { + "name", "description", "rating", "developer", "publisher", + "genre", "players", "favorite", "completed", "kidgame", + "broken", "playcount", "controller", "altemulator"}; + Renderer* mRenderer; unsigned int mColor; unsigned int mBgColor;