Tween track frequency on pause

This commit is contained in:
Dean Herbert 2019-06-10 00:56:35 +09:00
parent 164b05abd6
commit d964f6ba9e
1 changed files with 13 additions and 1 deletions

View File

@ -69,6 +69,7 @@ public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, d
RelativeSizeAxes = Axes.Both;
sourceClock = (IAdjustableClock)beatmap.Track ?? new StopwatchClock();
(sourceClock as IAdjustableAudioComponent)?.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
@ -85,8 +86,16 @@ public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, d
GameplayClock.IsPaused.BindTo(IsPaused);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
(sourceClock as IAdjustableAudioComponent)?.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
}
private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
@ -122,6 +131,8 @@ public void Start()
Seek(GameplayClock.CurrentTime);
adjustableClock.Start();
IsPaused.Value = false;
this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In);
}
/// <summary>
@ -143,7 +154,8 @@ public void Seek(double time)
public void Stop()
{
adjustableClock.Stop();
this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => { adjustableClock.Stop(); });
IsPaused.Value = true;
}