Move time clamp to Seek/transformSeekTo methods

This commit is contained in:
Marvin Schürz
2021-08-16 20:36:46 +02:00
parent d287db7961
commit 78f9f4a230

View File

@ -118,7 +118,6 @@ namespace osu.Game.Screens.Edit
if (!snapped || ControlPointInfo.TimingPoints.Count == 0) if (!snapped || ControlPointInfo.TimingPoints.Count == 0)
{ {
seekTime = Math.Clamp(seekTime, 0, TrackLength);
SeekSmoothlyTo(seekTime); SeekSmoothlyTo(seekTime);
return; return;
} }
@ -151,8 +150,6 @@ namespace osu.Game.Screens.Edit
if (seekTime < timingPoint.Time && timingPoint != ControlPointInfo.TimingPoints.First()) if (seekTime < timingPoint.Time && timingPoint != ControlPointInfo.TimingPoints.First())
seekTime = timingPoint.Time; seekTime = timingPoint.Time;
// Ensure the sought point is within the boundaries
seekTime = Math.Clamp(seekTime, 0, TrackLength);
SeekSmoothlyTo(seekTime); SeekSmoothlyTo(seekTime);
} }
@ -191,6 +188,9 @@ namespace osu.Game.Screens.Edit
seekingOrStopped.Value = IsSeeking = true; seekingOrStopped.Value = IsSeeking = true;
ClearTransforms(); ClearTransforms();
// Ensure the sought point is within the boundaries
position = Math.Clamp(position, 0, TrackLength);
return underlyingClock.Seek(position); return underlyingClock.Seek(position);
} }
@ -289,7 +289,7 @@ namespace osu.Game.Screens.Edit
} }
private void transformSeekTo(double seek, double duration = 0, Easing easing = Easing.None) private void transformSeekTo(double seek, double duration = 0, Easing easing = Easing.None)
=> this.TransformTo(this.PopulateTransform(new TransformSeek(), seek, duration, easing)); => this.TransformTo(this.PopulateTransform(new TransformSeek(), Math.Clamp(seek, 0, TrackLength), duration, easing));
private double currentTime private double currentTime
{ {