From 6028ec844430138da6edbf47cb81c401fa19ab57 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 16 May 2020 20:52:33 +0200 Subject: [PATCH] Added support for half-star rating increments when editing game metadata. Added rounding up to nearest half-star for all ratings read from the gamelist files. Fixed a small issue with rating symbols not being properly aligned --- es-app/src/components/RatingComponent.cpp | 7 ++++--- resources/star_filled.svg | 2 +- resources/star_unfilled.svg | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/es-app/src/components/RatingComponent.cpp b/es-app/src/components/RatingComponent.cpp index a4903657e..6eb16b919 100644 --- a/es-app/src/components/RatingComponent.cpp +++ b/es-app/src/components/RatingComponent.cpp @@ -19,7 +19,8 @@ void RatingComponent::setValue(const std::string& value) { mValue = 0.0f; }else{ - mValue = stof(value); + // Round up to the closest .1 value, i.e. to the closest half-star + mValue = Math::ceilf(stof(value) / 0.1) / 10; if(mValue > 1.0f) mValue = 1.0f; else if(mValue < 0.0f) @@ -143,8 +144,8 @@ bool RatingComponent::input(InputConfig* config, Input input) { if(config->isMappedTo("a", input) && input.value != 0) { - mValue += 1.f / NUM_RATING_STARS; - if(mValue > 1.0f) + mValue += (1.f/2) / NUM_RATING_STARS; + if(mValue > 1.05f) mValue = 0.0f; updateVertices(); diff --git a/resources/star_filled.svg b/resources/star_filled.svg index 0be43f791..890aea7a5 100644 --- a/resources/star_filled.svg +++ b/resources/star_filled.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/star_unfilled.svg b/resources/star_unfilled.svg index 9d3a2f737..05bf4106c 100644 --- a/resources/star_unfilled.svg +++ b/resources/star_unfilled.svg @@ -1,4 +1,4 @@ - +