From 37d2a2c3ccbe280e92c41777ea2673ef93461126 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Feb 2018 16:10:12 +0900 Subject: [PATCH] Rename clock types to match across classes --- osu.Game/Screens/Play/PauseContainer.cs | 12 ++++++------ osu.Game/Screens/Play/Player.cs | 23 +++++++++++++---------- osu.Game/Screens/Play/SkipButton.cs | 4 ++-- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Play/PauseContainer.cs b/osu.Game/Screens/Play/PauseContainer.cs index b2f2fe2d4c..8827b437ba 100644 --- a/osu.Game/Screens/Play/PauseContainer.cs +++ b/osu.Game/Screens/Play/PauseContainer.cs @@ -44,13 +44,13 @@ namespace osu.Game.Screens.Play public Action OnResume; public Action OnPause; - public readonly IAdjustableClock SeekableClock; + public readonly IAdjustableClock AdjustableClock; public readonly FramedClock FramedClock; - public PauseContainer(FramedClock framedClock, IAdjustableClock seekableClock) + public PauseContainer(FramedClock framedClock, IAdjustableClock adjustableClock) { FramedClock = framedClock; - SeekableClock = seekableClock; + AdjustableClock = adjustableClock; RelativeSizeAxes = Axes.Both; @@ -79,7 +79,7 @@ namespace osu.Game.Screens.Play if (IsPaused) return; // stop the seekable clock (stops the audio eventually) - SeekableClock.Stop(); + AdjustableClock.Stop(); IsPaused = true; OnPause?.Invoke(); @@ -98,8 +98,8 @@ namespace osu.Game.Screens.Play // seek back to the time of the framed clock. // this accounts for the audio clock potentially taking time to enter a completely stopped state. - SeekableClock.Seek(FramedClock.CurrentTime); - SeekableClock.Start(); + AdjustableClock.Seek(FramedClock.CurrentTime); + AdjustableClock.Start(); OnResume?.Invoke(); pauseOverlay.Hide(); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ce2ae08bed..a2e044b800 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -61,7 +61,10 @@ namespace osu.Game.Screens.Play /// private FramedOffsetClock offsetClock; - private DecoupleableInterpolatingFramedClock decoupledClock; + /// + /// The decoupled clock used for gameplay. Should be used for seeks and clock control. + /// + private DecoupleableInterpolatingFramedClock adjustableClock; private PauseContainer pauseContainer; @@ -144,16 +147,16 @@ namespace osu.Game.Screens.Play } sourceClock = (IAdjustableClock)working.Track ?? new StopwatchClock(); - decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; + adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; var firstObjectTime = RulesetContainer.Objects.First().StartTime; - decoupledClock.Seek(AllowLeadIn + adjustableClock.Seek(AllowLeadIn ? Math.Min(0, firstObjectTime - Math.Max(beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, beatmap.BeatmapInfo.AudioLeadIn)) : firstObjectTime); - decoupledClock.ProcessFrame(); + adjustableClock.ProcessFrame(); - offsetClock = new FramedOffsetClock(decoupledClock); + offsetClock = new FramedOffsetClock(adjustableClock); userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); userAudioOffset.ValueChanged += v => offsetClock.Offset = v; @@ -163,7 +166,7 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { - pauseContainer = new PauseContainer(offsetClock, decoupledClock) + pauseContainer = new PauseContainer(offsetClock, adjustableClock) { OnRetry = Restart, OnQuit = Exit, @@ -192,7 +195,7 @@ namespace osu.Game.Screens.Play }, new SkipButton(firstObjectTime) { - SeekableClock = decoupledClock, + AdjustableClock = adjustableClock, FramedClock = offsetClock, }, hudOverlay = new HUDOverlay(scoreProcessor, RulesetContainer, decoupledClock, working) @@ -304,7 +307,7 @@ namespace osu.Game.Screens.Play if (Beatmap.Value.Mods.Value.OfType().Any(m => !m.AllowFail)) return false; - decoupledClock.Stop(); + adjustableClock.Stop(); HasFailed = true; failOverlay.Retries = RestartCount; @@ -337,14 +340,14 @@ namespace osu.Game.Screens.Play Schedule(() => { - decoupledClock.ChangeSource(sourceClock); + adjustableClock.ChangeSource(sourceClock); applyRateFromMods(); this.Delay(750).Schedule(() => { if (!pauseContainer.IsPaused) { - decoupledClock.Start(); + adjustableClock.Start(); } }); }); diff --git a/osu.Game/Screens/Play/SkipButton.cs b/osu.Game/Screens/Play/SkipButton.cs index 463dcc1644..b7e075d893 100644 --- a/osu.Game/Screens/Play/SkipButton.cs +++ b/osu.Game/Screens/Play/SkipButton.cs @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Play { private readonly double startTime; - public IAdjustableClock SeekableClock; + public IAdjustableClock AdjustableClock; public IFrameBasedClock FramedClock; private Button button; @@ -111,7 +111,7 @@ namespace osu.Game.Screens.Play using (BeginAbsoluteSequence(beginFadeTime)) this.FadeOut(fade_time); - button.Action = () => SeekableClock?.Seek(startTime - skip_required_cutoff - fade_time); + button.Action = () => AdjustableClock?.Seek(startTime - skip_required_cutoff - fade_time); displayTime = Time.Current;