mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 09:22:54 +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:
parent
e90ae667b7
commit
0bfadfbbf1
@ -16,6 +16,7 @@ using System.Collections.Generic;
|
||||
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 @@ namespace osu.Game.Screens.Select.Details
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user