mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 16:03:14 +08:00
Fix Reset() potentially not resetting to the intended start position
This commit is contained in:
parent
acbf4580a4
commit
a92ae8ce76
@ -29,6 +29,11 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly DecoupleableInterpolatingFramedClock AdjustableSource;
|
protected readonly DecoupleableInterpolatingFramedClock AdjustableSource;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The offset at which to start playing. Affects the time which the clock is reset to via <see cref="Reset"/>.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual double StartOffset => 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The source clock.
|
/// The source clock.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -93,9 +98,12 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
ChangeSource(SourceClock);
|
ChangeSource(SourceClock);
|
||||||
|
|
||||||
AdjustableSource.Seek(0);
|
AdjustableSource.Seek(StartOffset);
|
||||||
AdjustableSource.Stop();
|
AdjustableSource.Stop();
|
||||||
|
|
||||||
|
// Make sure the gameplay clock takes on the new time, otherwise the adjustable source will be seeked to the gameplay clock time in Start().
|
||||||
|
GameplayClock.UnderlyingClock.ProcessFrame();
|
||||||
|
|
||||||
if (!IsPaused.Value)
|
if (!IsPaused.Value)
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
|
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
|
||||||
|
|
||||||
|
protected override double StartOffset => startOffset;
|
||||||
|
private double startOffset;
|
||||||
|
|
||||||
private readonly WorkingBeatmap beatmap;
|
private readonly WorkingBeatmap beatmap;
|
||||||
private readonly double gameplayStartTime;
|
private readonly double gameplayStartTime;
|
||||||
private readonly bool startAtGameplayStart;
|
private readonly bool startAtGameplayStart;
|
||||||
@ -74,27 +77,23 @@ namespace osu.Game.Screens.Play
|
|||||||
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
|
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
|
||||||
|
|
||||||
// sane default provided by ruleset.
|
// sane default provided by ruleset.
|
||||||
double startTime = gameplayStartTime;
|
startOffset = gameplayStartTime;
|
||||||
|
|
||||||
if (!startAtGameplayStart)
|
if (!startAtGameplayStart)
|
||||||
{
|
{
|
||||||
startTime = Math.Min(0, startTime);
|
startOffset = Math.Min(0, startOffset);
|
||||||
|
|
||||||
// if a storyboard is present, it may dictate the appropriate start time by having events in negative time space.
|
// if a storyboard is present, it may dictate the appropriate start time by having events in negative time space.
|
||||||
// this is commonly used to display an intro before the audio track start.
|
// this is commonly used to display an intro before the audio track start.
|
||||||
double? firstStoryboardEvent = beatmap.Storyboard.EarliestEventTime;
|
double? firstStoryboardEvent = beatmap.Storyboard.EarliestEventTime;
|
||||||
if (firstStoryboardEvent != null)
|
if (firstStoryboardEvent != null)
|
||||||
startTime = Math.Min(startTime, firstStoryboardEvent.Value);
|
startOffset = Math.Min(startOffset, firstStoryboardEvent.Value);
|
||||||
|
|
||||||
// some beatmaps specify a current lead-in time which should be used instead of the ruleset-provided value when available.
|
// some beatmaps specify a current lead-in time which should be used instead of the ruleset-provided value when available.
|
||||||
// this is not available as an option in the live editor but can still be applied via .osu editing.
|
// this is not available as an option in the live editor but can still be applied via .osu editing.
|
||||||
if (beatmap.BeatmapInfo.AudioLeadIn > 0)
|
if (beatmap.BeatmapInfo.AudioLeadIn > 0)
|
||||||
startTime = Math.Min(startTime, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn);
|
startOffset = Math.Min(startOffset, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
Seek(startTime);
|
|
||||||
|
|
||||||
AdjustableSource.ProcessFrame();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnIsPausedChanged(ValueChangedEvent<bool> isPaused)
|
protected override void OnIsPausedChanged(ValueChangedEvent<bool> isPaused)
|
||||||
|
Loading…
Reference in New Issue
Block a user