diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 26d73fb14..c07c27df7 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -365,6 +365,7 @@ std::map> {"text", STRING}, {"systemdata", STRING}, {"metadata", STRING}, + {"defaultValue", STRING}, {"metadataElement", BOOLEAN}, {"gameselector", STRING}, {"gameselectorEntry", UNSIGNED_INTEGER}, @@ -393,6 +394,7 @@ std::map> {"rotation", FLOAT}, {"rotationOrigin", NORMALIZED_PAIR}, {"metadata", STRING}, + {"defaultValue", STRING}, {"gameselector", STRING}, {"gameselectorEntry", UNSIGNED_INTEGER}, {"fontPath", PATH}, diff --git a/es-core/src/components/DateTimeComponent.cpp b/es-core/src/components/DateTimeComponent.cpp index 0f6ef38a4..e843ad743 100644 --- a/es-core/src/components/DateTimeComponent.cpp +++ b/es-core/src/components/DateTimeComponent.cpp @@ -69,8 +69,12 @@ std::string DateTimeComponent::getDisplayString() const { if (mDisplayRelative) { // Workaround to handle Unix epoch for different time zones. - if (mTime.getTime() < 82800) - return "never"; + if (mTime.getTime() < 82800) { + if (mDefaultValue == "") + return "never"; + else + return mDefaultValue; + } Utils::Time::DateTime now {Utils::Time::now()}; Utils::Time::Duration dur {now.getTime() - mTime.getTime()}; @@ -93,8 +97,12 @@ std::string DateTimeComponent::getDisplayString() const return std::string(buf); } - if (mTime.getTime() == 0) - return "unknown"; + if (mTime.getTime() == 0) { + if (mDefaultValue == "") + return "unknown"; + else + return mDefaultValue; + } return Utils::Time::timeToString(mTime.getTime(), mFormat); } @@ -176,6 +184,13 @@ void DateTimeComponent::applyTheme(const std::shared_ptr& theme, mThemeMetadata = ""; const std::string& metadata {elem->get("metadata")}; if (metadata == "releasedate" || metadata == "lastplayed") { + if (elem->has("defaultValue")) { + const std::string& defaultValue {elem->get("defaultValue")}; + if (defaultValue == ":space:") + mDefaultValue = " "; + else + mDefaultValue = defaultValue; + } mThemeMetadata = metadata; } else { diff --git a/es-core/src/components/DateTimeComponent.h b/es-core/src/components/DateTimeComponent.h index 5d848b0f5..c6d20a36c 100644 --- a/es-core/src/components/DateTimeComponent.h +++ b/es-core/src/components/DateTimeComponent.h @@ -48,6 +48,7 @@ protected: private: std::string getDisplayString() const; + std::string mDefaultValue; Utils::Time::DateTime mTime; std::string mFormat; bool mDisplayRelative; diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index 4bb5b7618..f07d5ba5d 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -238,6 +238,18 @@ void TextComponent::render(const glm::mat4& parentTrans) } } +void TextComponent::setValue(const std::string& value) +{ + if (value == "unknown" && mDefaultValue != "" && + (mThemeMetadata == "developer" || mThemeMetadata == "publisher" || + mThemeMetadata == "genre" || mThemeMetadata == "players")) { + setText(mDefaultValue); + } + else { + setText(value); + } +} + void TextComponent::onTextChanged() { mTextCache.reset(); @@ -443,6 +455,16 @@ void TextComponent::applyTheme(const std::shared_ptr& theme, for (auto& type : supportedMetadataTypes) { if (type == metadata) { mThemeMetadata = type; + if (elem->has("defaultValue")) { + if (mThemeMetadata == "developer" || mThemeMetadata == "publisher" || + mThemeMetadata == "genre" || mThemeMetadata == "players") { + const std::string& defaultValue {elem->get("defaultValue")}; + if (defaultValue == ":space:") + mDefaultValue = " "; + else + mDefaultValue = defaultValue; + } + } break; } } diff --git a/es-core/src/components/TextComponent.h b/es-core/src/components/TextComponent.h index d117f6a2a..58d4e2015 100644 --- a/es-core/src/components/TextComponent.h +++ b/es-core/src/components/TextComponent.h @@ -50,7 +50,7 @@ public: void render(const glm::mat4& parentTrans) override; std::string getValue() const override { return mText; } - void setValue(const std::string& value) override { setText(value); } + void setValue(const std::string& value) override; std::string getHiddenValue() const override { return mHiddenText; } void setHiddenValue(const std::string& value) override { setHiddenText(value); } @@ -102,6 +102,7 @@ private: "broken", "playcount", "controller", "altemulator"}; Renderer* mRenderer; + std::string mDefaultValue; unsigned int mColor; unsigned int mBgColor; float mColorOpacity;