mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
TextComponent now only accepts valid metadata and systemdata property values.
This commit is contained in:
parent
8c24d0a3b7
commit
d24102db0e
|
@ -172,8 +172,18 @@ void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
<< str << "\"";
|
||||
}
|
||||
|
||||
if (properties & METADATA && elem->has("metadata"))
|
||||
mThemeMetadata = elem->get<std::string>("metadata");
|
||||
if (properties & METADATA && elem->has("metadata")) {
|
||||
mThemeMetadata = "";
|
||||
const std::string metadata {elem->get<std::string>("metadata")};
|
||||
if (metadata == "releasedate" || metadata == "lastplayed") {
|
||||
mThemeMetadata = metadata;
|
||||
}
|
||||
else {
|
||||
LOG(LogWarning) << "DateTimeComponent: Invalid theme configuration, property "
|
||||
"<metadata> defined as \""
|
||||
<< metadata << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (mThemeMetadata == "lastplayed")
|
||||
setDisplayRelative(true);
|
||||
|
|
|
@ -450,11 +450,37 @@ void TextComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
if (properties & TEXT && elem->has("text"))
|
||||
setText(elem->get<std::string>("text"));
|
||||
|
||||
if (properties & METADATA && elem->has("systemdata"))
|
||||
mThemeSystemdata = elem->get<std::string>("systemdata");
|
||||
if (properties & METADATA && elem->has("systemdata")) {
|
||||
mThemeSystemdata = "";
|
||||
const std::string systemdata {elem->get<std::string>("systemdata")};
|
||||
for (auto& type : systemdataTypes) {
|
||||
if (type == systemdata) {
|
||||
mThemeSystemdata = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mThemeSystemdata == "") {
|
||||
LOG(LogWarning)
|
||||
<< "TextComponent: Invalid theme configuration, property <systemdata> defined as \""
|
||||
<< systemdata << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (properties & METADATA && elem->has("metadata"))
|
||||
mThemeMetadata = elem->get<std::string>("metadata");
|
||||
if (properties & METADATA && elem->has("metadata")) {
|
||||
mThemeMetadata = "";
|
||||
const std::string metadata {elem->get<std::string>("metadata")};
|
||||
for (auto& type : metadataTypes) {
|
||||
if (type == metadata) {
|
||||
mThemeMetadata = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mThemeMetadata == "") {
|
||||
LOG(LogWarning)
|
||||
<< "TextComponent: Invalid theme configuration, property <metadata> defined as \""
|
||||
<< metadata << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (properties & LETTER_CASE && elem->has("letterCase")) {
|
||||
std::string letterCase {elem->get<std::string>("letterCase")};
|
||||
|
|
|
@ -91,6 +91,14 @@ private:
|
|||
void calculateExtent();
|
||||
void onColorChanged();
|
||||
|
||||
static inline std::vector<std::string> systemdataTypes {
|
||||
"name", "fullname", "gamecount", "gamecount_games", "gamecount_favorites"};
|
||||
|
||||
static inline std::vector<std::string> metadataTypes {
|
||||
"name", "description", "rating", "developer", "publisher",
|
||||
"genre", "players", "favorite", "completed", "kidgame",
|
||||
"broken", "playcount", "controller", "altemulator"};
|
||||
|
||||
Renderer* mRenderer;
|
||||
unsigned int mColor;
|
||||
unsigned int mBgColor;
|
||||
|
|
Loading…
Reference in a new issue