diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs index 09e8253080..6e5b19daff 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs @@ -114,6 +114,27 @@ namespace osu.Game.Tests.Visual.Navigation && songSelect.Beatmap.Value is DummyWorkingBeatmap); } + [Test] + public void TestEditorRestoresModeOnReload() + { + prepareBeatmap(); + openEditor(); + + makeMetadataChange(commit: false); + + Editor editor1 = null!; + + AddStep("store current editor", () => editor1 = getEditor()); + + AddStep("reload", () => getEditor().SwitchToDifficulty(getEditorBeatmap().BeatmapInfo)); + AddUntilStep("save dialog displayed", () => Game.ChildrenOfType().SingleOrDefault()?.CurrentDialog is PromptForSaveDialog); + AddStep("confirm", () => InputManager.Key(Key.Number1)); + + AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse); + AddAssert("editor is new instance", () => getEditor() != editor1); + AddAssert("mode is still song setup", () => getEditor().Mode.Value == EditorScreenMode.SongSetup); + } + [Test] public void TestChangeMetadataExitWhileTextboxFocusedPromptsSave() { diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index f6af728b91..d57dab0716 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -513,6 +513,7 @@ namespace osu.Game.Screens.Edit /// public EditorState GetState([CanBeNull] RulesetInfo nextRuleset = null) => new EditorState { + Mode = Mode.Value, Time = clock.CurrentTimeAccurate, ClipboardContent = nextRuleset == null || editorBeatmap.BeatmapInfo.Ruleset.ShortName == nextRuleset.ShortName ? Clipboard.Content.Value : string.Empty }; @@ -523,6 +524,7 @@ namespace osu.Game.Screens.Edit /// The state to restore. public void RestoreState([NotNull] EditorState state) => Schedule(() => { + Mode.Value = state.Mode; clock.Seek(state.Time); Clipboard.Content.Value = state.ClipboardContent; }); diff --git a/osu.Game/Screens/Edit/EditorState.cs b/osu.Game/Screens/Edit/EditorState.cs index 1751de4d3e..05b86538e6 100644 --- a/osu.Game/Screens/Edit/EditorState.cs +++ b/osu.Game/Screens/Edit/EditorState.cs @@ -8,6 +8,11 @@ namespace osu.Game.Screens.Edit /// public class EditorState { + /// + /// The current editor mode. + /// + public EditorScreenMode Mode { get; set; } + /// /// The current audio time. ///