1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 18:53:21 +08:00

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

View File

@ -16,6 +16,7 @@ using System.Collections.Generic;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using System.Linq; using System.Linq;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
@ -177,12 +178,12 @@ namespace osu.Game.Screens.Select.Details
valueText.Text = (value.adjustedValue ?? value.baseValue).ToString(forceDecimalPlaces ? "0.00" : "0.##"); valueText.Text = (value.adjustedValue ?? value.baseValue).ToString(forceDecimalPlaces ? "0.00" : "0.##");
ModBar.Length = (value.adjustedValue ?? 0) / maxValue; 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; ModBar.AccentColour = valueText.Colour = colours.Red;
else if (value.adjustedValue < value.baseValue) else if (value.adjustedValue < value.baseValue)
ModBar.AccentColour = valueText.Colour = colours.BlueDark; ModBar.AccentColour = valueText.Colour = colours.BlueDark;
else
ModBar.AccentColour = valueText.Colour = Color4.White;
} }
} }