From a849bc074654a65d25500f14ade4cff330683ce0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Nov 2019 18:51:01 +0900 Subject: [PATCH] Move implementation into resetTrack for safety --- osu.Game/Screens/Edit/Editor.cs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index f932517387..ca3b4fdce5 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -69,14 +69,6 @@ namespace osu.Game.Screens.Edit clock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false }; clock.ChangeSource(sourceClock); - if (Beatmap.Value.Beatmap.HitObjects.Count > 0) - { - double targetTime = Beatmap.Value.Beatmap.HitObjects[0].StartTime; - double beatLength = Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(targetTime).BeatLength; - - clock.Seek(Math.Max(0, targetTime - beatLength)); - } - dependencies.CacheAs(clock); dependencies.CacheAs(clock); dependencies.Cache(beatDivisor); @@ -249,7 +241,8 @@ namespace osu.Game.Screens.Edit base.OnEntering(last); Background.FadeColour(Color4.DarkGray, 500); - resetTrack(); + + resetTrack(true); } public override bool OnExiting(IScreen next) @@ -260,10 +253,24 @@ namespace osu.Game.Screens.Edit return base.OnExiting(next); } - private void resetTrack() + private void resetTrack(bool seekToStart = false) { Beatmap.Value.Track?.ResetSpeedAdjustments(); Beatmap.Value.Track?.Stop(); + + if (seekToStart) + { + double targetTime = 0; + + if (Beatmap.Value.Beatmap.HitObjects.Count > 0) + { + // seek to one beat length before the first hitobject + targetTime = Beatmap.Value.Beatmap.HitObjects[0].StartTime; + targetTime -= Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(targetTime).BeatLength; + } + + clock.Seek(Math.Max(0, targetTime)); + } } private void exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save());