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

Merge pull request #3772 from peppy/fix-volume-precision

Fix volume adjustment precision regressing
This commit is contained in:
Dan Balasescu 2018-11-27 20:52:10 +09:00 committed by GitHub
commit 0bb8d5217c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Volume
private CircularProgress volumeCircle;
private CircularProgress volumeCircleGlow;
public BindableDouble Bindable { get; } = new BindableDouble { MinValue = 0, MaxValue = 1 };
public BindableDouble Bindable { get; } = new BindableDouble { MinValue = 0, MaxValue = 1, Precision = 0.01 };
private readonly float circleSize;
private readonly Color4 meterColour;
private readonly string name;
@ -222,7 +222,7 @@ namespace osu.Game.Overlays.Volume
private set => Bindable.Value = value;
}
private const float adjust_step = 0.05f;
private const double adjust_step = 0.05;
public void Increase(double amount = 1, bool isPrecise = false) => adjust(amount, isPrecise);
public void Decrease(double amount = 1, bool isPrecise = false) => adjust(-amount, isPrecise);
@ -236,7 +236,7 @@ namespace osu.Game.Overlays.Volume
var precision = Bindable.Precision;
while (Math.Abs(scrollAccumulation) > precision)
while (Precision.AlmostBigger(Math.Abs(scrollAccumulation), precision))
{
Volume += Math.Sign(scrollAccumulation) * precision;
scrollAccumulation = scrollAccumulation < 0 ? Math.Min(0, scrollAccumulation + precision) : Math.Max(0, scrollAccumulation - precision);