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

This commit is contained in:
Leon Styhre 2020-05-16 20:52:33 +02:00
parent 08a152db16
commit 6028ec8444
3 changed files with 6 additions and 5 deletions

View file

@ -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();

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="128" height="128" version="1.1" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg">
<path d="m51.200002 17.094353c-5.307206 0-12.400847 25.54313-16.694468 28.662627-4.293619 3.119497-30.7786329 1.972687-32.4186494 7.020139-1.64001672 5.047453 20.4608874 19.687168 22.1009044 24.734622 1.640016 5.047452-7.634984 29.881809-3.341365 33.001309 4.29362 3.1195 25.046372-13.37579 30.353578-13.37579 5.307206 1e-6 26.059954 16.49529 30.353573 13.37579 4.29362-3.11949-4.981379-27.953859-3.341362-33.001312 1.640017-5.047452 23.740917-19.687164 22.100907-24.734616-1.640019-5.047453-28.125035-3.900646-32.418655-7.020143-4.293619-3.119498-11.387257-28.662627-16.694463-28.662626z" fill="#777" stroke="#777" stroke-linejoin="round" stroke-width="4"/>
<path d="m62.200002 17.094353c-5.307206 0-12.400847 25.54313-16.694468 28.662627-4.293619 3.119497-30.7786329 1.972687-32.4186494 7.020139-1.64001672 5.047453 20.4608874 19.687168 22.1009044 24.734622 1.640016 5.047452-7.634984 29.881809-3.341365 33.001309 4.29362 3.1195 25.046372-13.37579 30.353578-13.37579 5.307206 1e-6 26.059954 16.49529 30.353573 13.37579 4.29362-3.11949-4.981379-27.953859-3.341362-33.001312 1.640017-5.047452 23.740917-19.687164 22.100907-24.734616-1.640019-5.047453-28.125035-3.900646-32.418655-7.020143-4.293619-3.119498-11.387257-28.662627-16.694463-28.662626z" fill="#777" stroke="#777" stroke-linejoin="round" stroke-width="4"/>
</svg>

Before

Width:  |  Height:  |  Size: 807 B

After

Width:  |  Height:  |  Size: 807 B

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="128" height="128" version="1.1" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg">
<path d="m51.200002 17.094353c-5.307206 0-12.400847 25.54313-16.694468 28.662627-4.293619 3.119497-30.7786329 1.972687-32.4186494 7.020139-1.64001672 5.047453 20.4608874 19.687168 22.1009044 24.734622 1.640016 5.047452-7.634984 29.881809-3.341365 33.001309 4.29362 3.1195 25.046372-13.37579 30.353578-13.37579 5.307206 1e-6 26.059954 16.49529 30.353573 13.37579 4.29362-3.11949-4.981379-27.953859-3.341362-33.001312 1.640017-5.047452 23.740917-19.687164 22.100907-24.734616-1.640019-5.047453-28.125035-3.900646-32.418655-7.020143-4.293619-3.119498-11.387257-28.662627-16.694463-28.662626z" fill="none" stroke="#777" stroke-linejoin="round" stroke-width="4"/>
<path d="m62.200002 17.094353c-5.307206 0-12.400847 25.54313-16.694468 28.662627-4.293619 3.119497-30.7786329 1.972687-32.4186494 7.020139-1.64001672 5.047453 20.4608874 19.687168 22.1009044 24.734622 1.640016 5.047452-7.634984 29.881809-3.341365 33.001309 4.29362 3.1195 25.046372-13.37579 30.353578-13.37579 5.307206 1e-6 26.059954 16.49529 30.353573 13.37579 4.29362-3.11949-4.981379-27.953859-3.341362-33.001312 1.640017-5.047452 23.740917-19.687164 22.100907-24.734616-1.640019-5.047453-28.125035-3.900646-32.418655-7.020143-4.293619-3.119498-11.387257-28.662627-16.694463-28.662626z" fill="none" stroke="#777" stroke-linejoin="round" stroke-width="4"/>
</svg>

Before

Width:  |  Height:  |  Size: 807 B

After

Width:  |  Height:  |  Size: 807 B