Rename clock types to match across classes

This commit is contained in:
Dean Herbert 2018-02-27 16:10:12 +09:00
parent 3d52ead213
commit 37d2a2c3cc
3 changed files with 21 additions and 18 deletions

View File

@ -44,13 +44,13 @@ public class PauseContainer : Container
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 @@ public void Pause(bool force = false) => Schedule(() => // Scheduled to ensure a
if (IsPaused) return;
// stop the seekable clock (stops the audio eventually)
SeekableClock.Stop();
AdjustableClock.Stop();
IsPaused = true;
OnPause?.Invoke();
@ -98,8 +98,8 @@ public void Resume()
// 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();

View File

@ -61,7 +61,10 @@ public class Player : OsuScreen, IProvideCursor
/// </summary>
private FramedOffsetClock offsetClock;
private DecoupleableInterpolatingFramedClock decoupledClock;
/// <summary>
/// The decoupled clock used for gameplay. Should be used for seeks and clock control.
/// </summary>
private DecoupleableInterpolatingFramedClock adjustableClock;
private PauseContainer pauseContainer;
@ -144,16 +147,16 @@ private void load(AudioManager audio, OsuConfigManager config, APIAccess api)
}
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<double>(OsuSetting.AudioOffset);
userAudioOffset.ValueChanged += v => offsetClock.Offset = v;
@ -163,7 +166,7 @@ private void load(AudioManager audio, OsuConfigManager config, APIAccess api)
Children = new Drawable[]
{
pauseContainer = new PauseContainer(offsetClock, decoupledClock)
pauseContainer = new PauseContainer(offsetClock, adjustableClock)
{
OnRetry = Restart,
OnQuit = Exit,
@ -192,7 +195,7 @@ private void load(AudioManager audio, OsuConfigManager config, APIAccess api)
},
new SkipButton(firstObjectTime)
{
SeekableClock = decoupledClock,
AdjustableClock = adjustableClock,
FramedClock = offsetClock,
},
hudOverlay = new HUDOverlay(scoreProcessor, RulesetContainer, decoupledClock, working)
@ -304,7 +307,7 @@ private bool onFail()
if (Beatmap.Value.Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
return false;
decoupledClock.Stop();
adjustableClock.Stop();
HasFailed = true;
failOverlay.Retries = RestartCount;
@ -337,14 +340,14 @@ protected override void OnEntering(Screen last)
Schedule(() =>
{
decoupledClock.ChangeSource(sourceClock);
adjustableClock.ChangeSource(sourceClock);
applyRateFromMods();
this.Delay(750).Schedule(() =>
{
if (!pauseContainer.IsPaused)
{
decoupledClock.Start();
adjustableClock.Start();
}
});
});

View File

@ -25,7 +25,7 @@ public class SkipButton : OverlayContainer, IKeyBindingHandler<GlobalAction>
{
private readonly double startTime;
public IAdjustableClock SeekableClock;
public IAdjustableClock AdjustableClock;
public IFrameBasedClock FramedClock;
private Button button;
@ -111,7 +111,7 @@ protected override void LoadComplete()
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;