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

Prevent playback from going beyond song end

This commit is contained in:
voidedWarranties 2020-03-11 22:40:08 -07:00
parent cb0e698e04
commit 1d314a1f4b
2 changed files with 22 additions and 0 deletions

View File

@ -87,6 +87,9 @@ namespace osu.Game.Screens.Edit.Components
private void togglePause()
{
if ((adjustableClock as EditorClock)?.PlaybackFinished == true)
adjustableClock.Seek(0);
if (adjustableClock.IsRunning)
adjustableClock.Stop();
else

View File

@ -21,6 +21,8 @@ namespace osu.Game.Screens.Edit
private readonly BindableBeatDivisor beatDivisor;
public bool PlaybackFinished { get; private set; }
public EditorClock(WorkingBeatmap beatmap, BindableBeatDivisor beatDivisor)
{
this.beatDivisor = beatDivisor;
@ -37,6 +39,23 @@ namespace osu.Game.Screens.Edit
TrackLength = trackLength;
}
public override void ProcessFrame()
{
base.ProcessFrame();
if (CurrentTime >= TrackLength)
{
if (!PlaybackFinished)
{
PlaybackFinished = true;
Stop();
Seek(TrackLength);
}
}
else
PlaybackFinished = false;
}
/// <summary>
/// Seek to the closest snappable beat from a time.
/// </summary>