mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15: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},
|
{"text", STRING},
|
||||||
{"systemdata", STRING},
|
{"systemdata", STRING},
|
||||||
{"metadata", STRING},
|
{"metadata", STRING},
|
||||||
|
{"defaultValue", STRING},
|
||||||
{"metadataElement", BOOLEAN},
|
{"metadataElement", BOOLEAN},
|
||||||
{"gameselector", STRING},
|
{"gameselector", STRING},
|
||||||
{"gameselectorEntry", UNSIGNED_INTEGER},
|
{"gameselectorEntry", UNSIGNED_INTEGER},
|
||||||
|
@ -393,6 +394,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"rotation", FLOAT},
|
{"rotation", FLOAT},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"metadata", STRING},
|
{"metadata", STRING},
|
||||||
|
{"defaultValue", STRING},
|
||||||
{"gameselector", STRING},
|
{"gameselector", STRING},
|
||||||
{"gameselectorEntry", UNSIGNED_INTEGER},
|
{"gameselectorEntry", UNSIGNED_INTEGER},
|
||||||
{"fontPath", PATH},
|
{"fontPath", PATH},
|
||||||
|
|
|
@ -69,8 +69,12 @@ std::string DateTimeComponent::getDisplayString() const
|
||||||
{
|
{
|
||||||
if (mDisplayRelative) {
|
if (mDisplayRelative) {
|
||||||
// Workaround to handle Unix epoch for different time zones.
|
// Workaround to handle Unix epoch for different time zones.
|
||||||
if (mTime.getTime() < 82800)
|
if (mTime.getTime() < 82800) {
|
||||||
return "never";
|
if (mDefaultValue == "")
|
||||||
|
return "never";
|
||||||
|
else
|
||||||
|
return mDefaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
Utils::Time::DateTime now {Utils::Time::now()};
|
Utils::Time::DateTime now {Utils::Time::now()};
|
||||||
Utils::Time::Duration dur {now.getTime() - mTime.getTime()};
|
Utils::Time::Duration dur {now.getTime() - mTime.getTime()};
|
||||||
|
@ -93,8 +97,12 @@ std::string DateTimeComponent::getDisplayString() const
|
||||||
return std::string(buf);
|
return std::string(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTime.getTime() == 0)
|
if (mTime.getTime() == 0) {
|
||||||
return "unknown";
|
if (mDefaultValue == "")
|
||||||
|
return "unknown";
|
||||||
|
else
|
||||||
|
return mDefaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
return Utils::Time::timeToString(mTime.getTime(), mFormat);
|
return Utils::Time::timeToString(mTime.getTime(), mFormat);
|
||||||
}
|
}
|
||||||
|
@ -176,6 +184,13 @@ void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
mThemeMetadata = "";
|
mThemeMetadata = "";
|
||||||
const std::string& metadata {elem->get<std::string>("metadata")};
|
const std::string& metadata {elem->get<std::string>("metadata")};
|
||||||
if (metadata == "releasedate" || metadata == "lastplayed") {
|
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;
|
mThemeMetadata = metadata;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -48,6 +48,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
std::string getDisplayString() const;
|
std::string getDisplayString() const;
|
||||||
|
|
||||||
|
std::string mDefaultValue;
|
||||||
Utils::Time::DateTime mTime;
|
Utils::Time::DateTime mTime;
|
||||||
std::string mFormat;
|
std::string mFormat;
|
||||||
bool mDisplayRelative;
|
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()
|
void TextComponent::onTextChanged()
|
||||||
{
|
{
|
||||||
mTextCache.reset();
|
mTextCache.reset();
|
||||||
|
@ -443,6 +455,16 @@ void TextComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
for (auto& type : supportedMetadataTypes) {
|
for (auto& type : supportedMetadataTypes) {
|
||||||
if (type == metadata) {
|
if (type == metadata) {
|
||||||
mThemeMetadata = type;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
void render(const glm::mat4& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
||||||
std::string getValue() const override { return mText; }
|
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; }
|
std::string getHiddenValue() const override { return mHiddenText; }
|
||||||
void setHiddenValue(const std::string& value) override { setHiddenText(value); }
|
void setHiddenValue(const std::string& value) override { setHiddenText(value); }
|
||||||
|
@ -102,6 +102,7 @@ private:
|
||||||
"broken", "playcount", "controller", "altemulator"};
|
"broken", "playcount", "controller", "altemulator"};
|
||||||
|
|
||||||
Renderer* mRenderer;
|
Renderer* mRenderer;
|
||||||
|
std::string mDefaultValue;
|
||||||
unsigned int mColor;
|
unsigned int mColor;
|
||||||
unsigned int mBgColor;
|
unsigned int mBgColor;
|
||||||
float mColorOpacity;
|
float mColorOpacity;
|
||||||
|
|
Loading…
Reference in a new issue