1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 21:03:08 +08:00

Move EditorClock processing to Update and always decouple

This commit is contained in:
Dean Herbert 2022-08-26 18:08:39 +09:00
parent 31e459364b
commit 12d6d6793c
2 changed files with 17 additions and 23 deletions

View File

@ -220,7 +220,7 @@ namespace osu.Game.Screens.Edit
} }
// Todo: should probably be done at a DrawableRuleset level to share logic with Player. // Todo: should probably be done at a DrawableRuleset level to share logic with Player.
clock = new EditorClock(playableBeatmap, beatDivisor) { IsCoupled = false }; clock = new EditorClock(playableBeatmap, beatDivisor);
clock.ChangeSource(loadableBeatmap.Track); clock.ChangeSource(loadableBeatmap.Track);
dependencies.CacheAs(clock); dependencies.CacheAs(clock);

View File

@ -54,7 +54,7 @@ namespace osu.Game.Screens.Edit
this.beatDivisor = beatDivisor ?? new BindableBeatDivisor(); this.beatDivisor = beatDivisor ?? new BindableBeatDivisor();
underlyingClock = new FramedBeatmapClock(applyOffsets: true); underlyingClock = new FramedBeatmapClock(applyOffsets: true) { IsCoupled = false };
AddInternal(underlyingClock); AddInternal(underlyingClock);
} }
@ -222,21 +222,7 @@ namespace osu.Game.Screens.Edit
public void ProcessFrame() public void ProcessFrame()
{ {
// EditorClock wasn't being added in many places. This gives us more certainty that it is. // Noop to ensure an external consumer doesn't process the internal clock an extra time.
Debug.Assert(underlyingClock.LoadState > LoadState.NotLoaded);
underlyingClock.ProcessFrame();
playbackFinished = CurrentTime >= TrackLength;
if (playbackFinished)
{
if (IsRunning)
underlyingClock.Stop();
if (CurrentTime > TrackLength)
underlyingClock.Seek(TrackLength);
}
} }
public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime; public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime;
@ -253,18 +239,26 @@ namespace osu.Game.Screens.Edit
public IClock Source => underlyingClock.Source; public IClock Source => underlyingClock.Source;
public bool IsCoupled
{
get => underlyingClock.IsCoupled;
set => underlyingClock.IsCoupled = value;
}
private const double transform_time = 300; private const double transform_time = 300;
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
// EditorClock wasn't being added in many places. This gives us more certainty that it is.
Debug.Assert(underlyingClock.LoadState > LoadState.NotLoaded);
playbackFinished = CurrentTime >= TrackLength;
if (playbackFinished)
{
if (IsRunning)
underlyingClock.Stop();
if (CurrentTime > TrackLength)
underlyingClock.Seek(TrackLength);
}
updateSeekingState(); updateSeekingState();
} }