Move screen management logic to EditorLoader

This commit is contained in:
Bartłomiej Dach 2021-09-06 21:30:50 +02:00
parent bd7d6dd35d
commit 2d59008f52
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
2 changed files with 11 additions and 19 deletions

View File

@ -740,24 +740,9 @@ namespace osu.Game.Screens.Edit
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, switchToDifficulty);
}
private void switchToDifficulty(BeatmapInfo beatmapInfo)
{
if (loader == null)
return;
private void switchToDifficulty(BeatmapInfo beatmapInfo) => loader?.ScheduleDifficultySwitch(beatmapInfo);
loader.ValidForResume = true;
this.Exit();
loader.ScheduleDifficultySwitch(beatmapInfo);
}
private void cancelExit()
{
if (loader == null)
return;
loader.ValidForResume = false;
loader.CancelDifficultySwitch();
}
private void cancelExit() => loader?.CancelPendingDifficultySwitch();
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);

View File

@ -48,7 +48,10 @@ namespace osu.Game.Screens.Edit
public void ScheduleDifficultySwitch(BeatmapInfo beatmapInfo)
{
CancelDifficultySwitch();
scheduledDifficultySwitch?.Cancel();
ValidForResume = true;
this.MakeCurrent();
scheduledDifficultySwitch = Schedule(() =>
{
Beatmap.Value = beatmapManager.GetWorkingBeatmap(beatmapInfo);
@ -56,6 +59,10 @@ namespace osu.Game.Screens.Edit
});
}
public void CancelDifficultySwitch() => scheduledDifficultySwitch?.Cancel();
public void CancelPendingDifficultySwitch()
{
scheduledDifficultySwitch?.Cancel();
ValidForResume = false;
}
}
}