mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Added support for overriding the default 'unknown' values when a game has no metadata available.
This commit is contained in:
parent
688697e334
commit
e560ab0f58
|
@ -365,6 +365,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
|||
{"text", STRING},
|
||||
{"systemdata", STRING},
|
||||
{"metadata", STRING},
|
||||
{"defaultValue", STRING},
|
||||
{"metadataElement", BOOLEAN},
|
||||
{"gameselector", STRING},
|
||||
{"gameselectorEntry", UNSIGNED_INTEGER},
|
||||
|
@ -393,6 +394,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
|||
{"rotation", FLOAT},
|
||||
{"rotationOrigin", NORMALIZED_PAIR},
|
||||
{"metadata", STRING},
|
||||
{"defaultValue", STRING},
|
||||
{"gameselector", STRING},
|
||||
{"gameselectorEntry", UNSIGNED_INTEGER},
|
||||
{"fontPath", PATH},
|
||||
|
|
|
@ -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<ThemeData>& theme,
|
|||
mThemeMetadata = "";
|
||||
const std::string& metadata {elem->get<std::string>("metadata")};
|
||||
if (metadata == "releasedate" || metadata == "lastplayed") {
|
||||
if (elem->has("defaultValue")) {
|
||||
const std::string& defaultValue {elem->get<std::string>("defaultValue")};
|
||||
if (defaultValue == ":space:")
|
||||
mDefaultValue = " ";
|
||||
else
|
||||
mDefaultValue = defaultValue;
|
||||
}
|
||||
mThemeMetadata = metadata;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -48,6 +48,7 @@ protected:
|
|||
private:
|
||||
std::string getDisplayString() const;
|
||||
|
||||
std::string mDefaultValue;
|
||||
Utils::Time::DateTime mTime;
|
||||
std::string mFormat;
|
||||
bool mDisplayRelative;
|
||||
|
|
|
@ -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<ThemeData>& 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<std::string>("defaultValue")};
|
||||
if (defaultValue == ":space:")
|
||||
mDefaultValue = " ";
|
||||
else
|
||||
mDefaultValue = defaultValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue