diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs
index eba75f4408..5bb47e1c11 100644
--- a/osu.Game/Screens/Edit/Editor.cs
+++ b/osu.Game/Screens/Edit/Editor.cs
@@ -317,6 +317,16 @@ namespace osu.Game.Screens.Edit
///
public void UpdateClockSource() => clock.ChangeSource(Beatmap.Value.Track);
+ ///
+ /// Restore the editor to a provided state.
+ ///
+ /// The state to restore.
+ public void RestoreState([NotNull] EditorState state) => Schedule(() =>
+ {
+ clock.Seek(state.Time);
+ clipboard.Value = state.ClipboardContent;
+ });
+
protected void Save()
{
// no longer new after first user-triggered save.
@@ -476,8 +486,6 @@ namespace osu.Game.Screens.Edit
});
resetTrack(true);
- if (loader?.State != null)
- restoreState(loader.State);
}
public override bool OnExiting(IScreen next)
@@ -745,17 +753,9 @@ namespace osu.Game.Screens.Edit
protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, new EditorState
{
Time = clock.CurrentTimeAccurate,
- ClipboardContent = editorBeatmap.BeatmapInfo.RulesetID == nextBeatmap.RulesetID ? clipboard.Value : null
+ ClipboardContent = editorBeatmap.BeatmapInfo.RulesetID == nextBeatmap.RulesetID ? clipboard.Value : string.Empty
});
- private void restoreState([NotNull] EditorState state)
- {
- if (state.Time != null)
- clock.Seek(state.Time.Value);
-
- clipboard.Value = state.ClipboardContent ?? clipboard.Value;
- }
-
private void cancelExit() => loader?.CancelPendingDifficultySwitch();
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
diff --git a/osu.Game/Screens/Edit/EditorLoader.cs b/osu.Game/Screens/Edit/EditorLoader.cs
index 5ad720f7f0..2a01a5b6b2 100644
--- a/osu.Game/Screens/Edit/EditorLoader.cs
+++ b/osu.Game/Screens/Edit/EditorLoader.cs
@@ -91,7 +91,13 @@ namespace osu.Game.Screens.Edit
private void pushEditor()
{
- this.Push(CreateEditor());
+ var editor = CreateEditor();
+
+ this.Push(editor);
+
+ if (state != null)
+ editor.RestoreState(state);
+
ValidForResume = false;
}