Merge pull request #2762 from peppy/fix-volume-precise-scroll

Fix volume control adjustment being extreme when precision scrolling
This commit is contained in:
Thomas Müller 2018-06-08 04:37:19 -07:00 committed by GitHub
commit b287b69476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -167,9 +167,25 @@ namespace osu.Game.Overlays.Volume
private set => Bindable.Value = value;
}
public void Increase() => Volume += 0.05f;
private const float adjust_step = 0.05f;
public void Decrease() => Volume -= 0.05f;
public void Increase() => adjust(1);
public void Decrease() => adjust(-1);
private void adjust(int direction)
{
float amount = adjust_step * direction;
var mouse = GetContainingInputManager().CurrentState.Mouse;
if (mouse.HasPreciseScroll)
{
float scrollDelta = mouse.ScrollDelta.Y;
if (scrollDelta != 0)
amount *= Math.Abs(scrollDelta / 10);
}
Volume += amount;
}
public bool OnPressed(GlobalAction action)
{