mirror of https://github.com/ppy/osu
Move implementation into resetTrack for safety
This commit is contained in:
parent
e904928314
commit
a849bc0746
|
@ -69,14 +69,6 @@ private void load(OsuColour colours, GameHost host)
|
|||
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<IFrameBasedClock>(clock);
|
||||
dependencies.CacheAs<IAdjustableClock>(clock);
|
||||
dependencies.Cache(beatDivisor);
|
||||
|
@ -249,7 +241,8 @@ public override void OnEntering(IScreen last)
|
|||
base.OnEntering(last);
|
||||
|
||||
Background.FadeColour(Color4.DarkGray, 500);
|
||||
resetTrack();
|
||||
|
||||
resetTrack(true);
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
|
@ -260,10 +253,24 @@ public override bool OnExiting(IScreen next)
|
|||
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());
|
||||
|
|
Loading…
Reference in New Issue