Fix multiple calls to seek method potentially not working

This commit is contained in:
smoogipoo 2021-06-03 17:47:22 +09:00
parent c3280083a2
commit be03a2d7d2

View File

@ -583,6 +583,8 @@ namespace osu.Game.Screens.Play
/// <param name="time">The destination time to seek to.</param> /// <param name="time">The destination time to seek to.</param>
public void Seek(double time) => GameplayClockContainer.Seek(time); public void Seek(double time) => GameplayClockContainer.Seek(time);
private ScheduledDelegate frameStablePlaybackResetDelegate;
/// <summary> /// <summary>
/// Seeks to a specific time in gameplay, bypassing frame stability. /// Seeks to a specific time in gameplay, bypassing frame stability.
/// </summary> /// </summary>
@ -592,13 +594,16 @@ namespace osu.Game.Screens.Play
/// <param name="time">The destination time to seek to.</param> /// <param name="time">The destination time to seek to.</param>
public void NonFrameStableSeek(double time) public void NonFrameStableSeek(double time)
{ {
if (frameStablePlaybackResetDelegate?.Cancelled == false && !frameStablePlaybackResetDelegate.Completed)
frameStablePlaybackResetDelegate.RunTask();
bool wasFrameStable = DrawableRuleset.FrameStablePlayback; bool wasFrameStable = DrawableRuleset.FrameStablePlayback;
DrawableRuleset.FrameStablePlayback = false; DrawableRuleset.FrameStablePlayback = false;
Seek(time); Seek(time);
// Delay resetting frame-stable playback for one frame to give the FrameStabilityContainer a chance to seek. // Delay resetting frame-stable playback for one frame to give the FrameStabilityContainer a chance to seek.
ScheduleAfterChildren(() => DrawableRuleset.FrameStablePlayback = wasFrameStable); frameStablePlaybackResetDelegate = ScheduleAfterChildren(() => DrawableRuleset.FrameStablePlayback = wasFrameStable);
} }
/// <summary> /// <summary>
@ -931,8 +936,7 @@ namespace osu.Game.Screens.Play
/// Creates the player's <see cref="Scoring.Score"/>. /// Creates the player's <see cref="Scoring.Score"/>.
/// </summary> /// </summary>
/// <returns>The <see cref="Scoring.Score"/>.</returns> /// <returns>The <see cref="Scoring.Score"/>.</returns>
protected virtual Score CreateScore() => protected virtual Score CreateScore() => new Score
new Score
{ {
ScoreInfo = new ScoreInfo { User = api.LocalUser.Value }, ScoreInfo = new ScoreInfo { User = api.LocalUser.Value },
}; };