Apply precision when comparing adjusted values

In some cases, applying the Difficulty Adjust mod without actually
changing any of the settings previously caused the bar in song select
beatmap details to appear red/blue instead of staying white.

This was caused by not accounting for floating-point imprecisions when
determining bar colour in AdvancedStats. To resolve, first check
equality with tolerance, and only then apply blue/red colours if that
equality check does not hold.
This commit is contained in:
Bartłomiej Dach 2020-02-01 16:16:15 +01:00
parent e90ae667b7
commit 0bfadfbbf1
1 changed files with 4 additions and 3 deletions

View File

@ -16,6 +16,7 @@
using osu.Game.Rulesets.Mods;
using System.Linq;
using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
@ -177,12 +178,12 @@ public string Title
valueText.Text = (value.adjustedValue ?? value.baseValue).ToString(forceDecimalPlaces ? "0.00" : "0.##");
ModBar.Length = (value.adjustedValue ?? 0) / maxValue;
if (value.adjustedValue > value.baseValue)
if (Precision.AlmostEquals(value.baseValue, value.adjustedValue ?? value.baseValue, 0.05f))
ModBar.AccentColour = valueText.Colour = Color4.White;
else if (value.adjustedValue > value.baseValue)
ModBar.AccentColour = valueText.Colour = colours.Red;
else if (value.adjustedValue < value.baseValue)
ModBar.AccentColour = valueText.Colour = colours.BlueDark;
else
ModBar.AccentColour = valueText.Colour = Color4.White;
}
}