Only set initial source in Reset()

This commit is contained in:
smoogipoo
2021-04-19 19:55:59 +09:00
parent c7183f92f7
commit acbf4580a4
2 changed files with 17 additions and 4 deletions

View File

@ -29,17 +29,22 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
protected readonly DecoupleableInterpolatingFramedClock AdjustableSource; protected readonly DecoupleableInterpolatingFramedClock AdjustableSource;
/// <summary>
/// The source clock.
/// </summary>
protected IClock SourceClock { get; private set; }
/// <summary> /// <summary>
/// Creates a new <see cref="GameplayClockContainer"/>. /// Creates a new <see cref="GameplayClockContainer"/>.
/// </summary> /// </summary>
/// <param name="sourceClock">The source <see cref="IClock"/> used for timing.</param> /// <param name="sourceClock">The source <see cref="IClock"/> used for timing.</param>
protected GameplayClockContainer(IClock sourceClock) protected GameplayClockContainer(IClock sourceClock)
{ {
SourceClock = sourceClock;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
AdjustableSource = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; AdjustableSource = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
AdjustableSource.ChangeSource(sourceClock);
IsPaused.BindValueChanged(OnIsPausedChanged); IsPaused.BindValueChanged(OnIsPausedChanged);
} }
@ -86,6 +91,8 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
public virtual void Reset() public virtual void Reset()
{ {
ChangeSource(SourceClock);
AdjustableSource.Seek(0); AdjustableSource.Seek(0);
AdjustableSource.Stop(); AdjustableSource.Stop();
@ -93,6 +100,12 @@ namespace osu.Game.Screens.Play
Start(); Start();
} }
/// <summary>
/// Changes the source clock.
/// </summary>
/// <param name="sourceClock">The new source.</param>
protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock);
protected override void Update() protected override void Update()
{ {
if (!IsPaused.Value) if (!IsPaused.Value)

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
public const double MINIMUM_SKIP_TIME = 1000; public const double MINIMUM_SKIP_TIME = 1000;
protected Track Track => (Track)AdjustableSource.Source; protected Track Track => (Track)SourceClock;
public readonly BindableNumber<double> UserPlaybackRate = new BindableDouble(1) public readonly BindableNumber<double> UserPlaybackRate = new BindableDouble(1)
{ {
@ -164,7 +164,7 @@ namespace osu.Game.Screens.Play
public void StopUsingBeatmapClock() public void StopUsingBeatmapClock()
{ {
removeSourceClockAdjustments(); removeSourceClockAdjustments();
AdjustableSource.ChangeSource(new TrackVirtual(beatmap.Track.Length)); ChangeSource(new TrackVirtual(beatmap.Track.Length));
} }
private bool speedAdjustmentsApplied; private bool speedAdjustmentsApplied;