Added a 'hideIfZero' property to the rating element

This commit is contained in:
Leon Styhre 2024-01-27 13:32:58 +01:00
parent 00e6908ccd
commit 6dff5ac75c
3 changed files with 9 additions and 0 deletions

View file

@ -488,6 +488,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"rotation", FLOAT},
{"rotationOrigin", NORMALIZED_PAIR},
{"stationary", STRING},
{"hideIfZero", BOOLEAN},
{"gameselector", STRING},
{"gameselectorEntry", UNSIGNED_INTEGER},
{"interpolation", STRING},

View file

@ -21,6 +21,7 @@ RatingComponent::RatingComponent(bool colorizeChanges, bool linearInterpolation)
, mColorChangedValue {mMenuColorPrimary}
, mColorizeChanges {colorizeChanges}
, mOverlay {true}
, mHideIfZero {false}
{
mSize = glm::vec2 {std::round(mRenderer->getScreenHeight() * 0.06f) * NUM_RATING_STARS,
std::round(mRenderer->getScreenHeight() * 0.06f)};
@ -127,6 +128,9 @@ void RatingComponent::render(const glm::mat4& parentTrans)
if (!isVisible() || mThemeOpacity == 0.0f || mOpacity == 0.0f)
return;
if (mHideIfZero && mValue == 0.0f)
return;
glm::mat4 trans {parentTrans * getTransform()};
mIconUnfilled.setOpacity(mOpacity * mThemeOpacity);
@ -227,6 +231,9 @@ void RatingComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
<< element.substr(7) << "\" defined as \"" << stationary << "\"";
}
if (elem->has("hideIfZero"))
mHideIfZero = elem->get<bool>("hideIfZero");
bool linearInterpolation {false};
// Enable linear interpolation by default if element is arbitrarily rotated.

View file

@ -61,6 +61,7 @@ private:
bool mColorizeChanges;
bool mOverlay;
bool mHideIfZero;
};
#endif // ES_APP_COMPONENTS_RATING_COMPONENT_H