From acbf4580a412772b6be6d8e3d60446bbe35b9003 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 19 Apr 2021 19:55:59 +0900 Subject: [PATCH] Only set initial source in Reset() --- osu.Game/Screens/Play/GameplayClockContainer.cs | 17 +++++++++++++++-- .../Play/MasterGameplayClockContainer.cs | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index ee65384bc9..3da28f3560 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -29,17 +29,22 @@ public abstract class GameplayClockContainer : Container /// protected readonly DecoupleableInterpolatingFramedClock AdjustableSource; + /// + /// The source clock. + /// + protected IClock SourceClock { get; private set; } + /// /// Creates a new . /// /// The source used for timing. protected GameplayClockContainer(IClock sourceClock) { + SourceClock = sourceClock; + RelativeSizeAxes = Axes.Both; AdjustableSource = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; - AdjustableSource.ChangeSource(sourceClock); - IsPaused.BindValueChanged(OnIsPausedChanged); } @@ -86,6 +91,8 @@ public virtual void Start() /// public virtual void Reset() { + ChangeSource(SourceClock); + AdjustableSource.Seek(0); AdjustableSource.Stop(); @@ -93,6 +100,12 @@ public virtual void Reset() Start(); } + /// + /// Changes the source clock. + /// + /// The new source. + protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock); + protected override void Update() { if (!IsPaused.Value) diff --git a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs index 5ea50cbdc7..f019e50b60 100644 --- a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs +++ b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs @@ -33,7 +33,7 @@ public class MasterGameplayClockContainer : GameplayClockContainer /// public const double MINIMUM_SKIP_TIME = 1000; - protected Track Track => (Track)AdjustableSource.Source; + protected Track Track => (Track)SourceClock; public readonly BindableNumber UserPlaybackRate = new BindableDouble(1) { @@ -164,7 +164,7 @@ protected override GameplayClock CreateGameplayClock(IFrameBasedClock source) public void StopUsingBeatmapClock() { removeSourceClockAdjustments(); - AdjustableSource.ChangeSource(new TrackVirtual(beatmap.Track.Length)); + ChangeSource(new TrackVirtual(beatmap.Track.Length)); } private bool speedAdjustmentsApplied;