From 2562412125e974efc2c89a4b4b31daa2070aa589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 12 Nov 2021 13:12:25 +0100 Subject: [PATCH] Propagate clock state from gameplay test back to editor --- osu.Game/Screens/Edit/Editor.cs | 6 +++--- osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs | 9 +++++++-- osu.Game/Screens/Edit/GameplayTest/EditorPlayerLoader.cs | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index ff9a19434b..2a7e2c9cef 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -332,7 +332,7 @@ namespace osu.Game.Screens.Edit /// The next beatmap to be shown, in the case of difficulty switch. /// indicates that the beatmap will not be changing. /// - private EditorState getState([CanBeNull] BeatmapInfo nextBeatmap = null) => new EditorState + public EditorState GetState([CanBeNull] BeatmapInfo nextBeatmap = null) => new EditorState { Time = clock.CurrentTimeAccurate, ClipboardContent = nextBeatmap == null || editorBeatmap.BeatmapInfo.RulesetID == nextBeatmap.RulesetID ? Clipboard.Content.Value : string.Empty @@ -793,7 +793,7 @@ namespace osu.Game.Screens.Edit return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, SwitchToDifficulty); } - protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, getState(nextBeatmap)); + protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, GetState(nextBeatmap)); private void cancelExit() { @@ -816,7 +816,7 @@ namespace osu.Game.Screens.Edit pushEditorPlayer(); } - void pushEditorPlayer() => this.Push(new EditorPlayerLoader(getState())); + void pushEditorPlayer() => this.Push(new EditorPlayerLoader(this)); } public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime); diff --git a/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs b/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs index 266c5e81d4..479dc2e6b3 100644 --- a/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs +++ b/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs @@ -11,15 +11,17 @@ namespace osu.Game.Screens.Edit.GameplayTest { public class EditorPlayer : Player { + private readonly Editor editor; private readonly EditorState editorState; [Resolved] private MusicController musicController { get; set; } - public EditorPlayer(EditorState editorState) + public EditorPlayer(Editor editor) : base(new PlayerConfiguration { ShowResults = false }) { - this.editorState = editorState; + this.editor = editor; + editorState = editor.GetState(); } protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) @@ -45,6 +47,9 @@ namespace osu.Game.Screens.Edit.GameplayTest public override bool OnExiting(IScreen next) { musicController.Stop(); + + editorState.Time = GameplayClockContainer.CurrentTime; + editor.RestoreState(editorState); return base.OnExiting(next); } } diff --git a/osu.Game/Screens/Edit/GameplayTest/EditorPlayerLoader.cs b/osu.Game/Screens/Edit/GameplayTest/EditorPlayerLoader.cs index 5c2ab04fd7..addc79ba61 100644 --- a/osu.Game/Screens/Edit/GameplayTest/EditorPlayerLoader.cs +++ b/osu.Game/Screens/Edit/GameplayTest/EditorPlayerLoader.cs @@ -14,8 +14,8 @@ namespace osu.Game.Screens.Edit.GameplayTest [Resolved] private OsuLogo osuLogo { get; set; } - public EditorPlayerLoader(EditorState editorState) - : base(() => new EditorPlayer(editorState)) + public EditorPlayerLoader(Editor editor) + : base(() => new EditorPlayer(editor)) { }