1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Change drag adjustments to be linear (and account for partial deltas)

This commit is contained in:
Dean Herbert 2024-01-17 14:12:12 +09:00
parent cdc6621f33
commit 9cde04c30c
No known key found for this signature in database

View File

@ -309,24 +309,37 @@ namespace osu.Game.Overlays.Volume
private const double max_acceleration = 5;
private const double acceleration_multiplier = 1.8;
private const float mouse_drag_divisor = 20;
private ScheduledDelegate accelerationDebounce;
private void resetAcceleration() => accelerationModifier = 1;
private float dragDelta = 0;
protected override bool OnDragStart(DragStartEvent e)
{
adjust(-e.Delta.Y / mouse_drag_divisor, true);
dragDelta = 0;
adjustFromDrag(e.Delta);
return true;
}
protected override void OnDrag(DragEvent e)
{
adjust(-e.Delta.Y / mouse_drag_divisor, true);
adjustFromDrag(e.Delta);
base.OnDrag(e);
}
private void adjustFromDrag(Vector2 delta)
{
const float mouse_drag_divisor = 200;
dragDelta += delta.Y / mouse_drag_divisor;
if (Math.Abs(dragDelta) < 0.01) return;
Volume -= dragDelta;
dragDelta = 0;
}
private void adjust(double delta, bool isPrecise)
{
if (delta == 0)