mirror of
https://github.com/osukey/osukey.git
synced 2025-06-28 06:38:00 +09:00
Merge pull request #14323 from minetoblend/editor-seek
Prevent seeking before mp3 start time while editor is playing
This commit is contained in:
commit
98357d51da
@ -78,6 +78,24 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestClampWhenSeekOutsideBeatmapBounds()
|
||||||
|
{
|
||||||
|
AddStep("stop clock", Clock.Stop);
|
||||||
|
|
||||||
|
AddStep("seek before start time", () => Clock.Seek(-1000));
|
||||||
|
AddAssert("time is clamped to 0", () => Clock.CurrentTime == 0);
|
||||||
|
|
||||||
|
AddStep("seek beyond track length", () => Clock.Seek(Clock.TrackLength + 1000));
|
||||||
|
AddAssert("time is clamped to track length", () => Clock.CurrentTime == Clock.TrackLength);
|
||||||
|
|
||||||
|
AddStep("seek smoothly before start time", () => Clock.SeekSmoothlyTo(-1000));
|
||||||
|
AddAssert("time is clamped to 0", () => Clock.CurrentTime == 0);
|
||||||
|
|
||||||
|
AddStep("seek smoothly beyond track length", () => Clock.SeekSmoothlyTo(Clock.TrackLength + 1000));
|
||||||
|
AddAssert("time is clamped to track length", () => Clock.CurrentTime == Clock.TrackLength);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
Beatmap.Disabled = false;
|
Beatmap.Disabled = false;
|
||||||
|
@ -150,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,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
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user