1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 02:43:19 +08:00

Propagate clock state from gameplay test back to editor

This commit is contained in:
Bartłomiej Dach 2021-11-12 13:12:25 +01:00
parent d2ddc25ab3
commit 2562412125
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
3 changed files with 12 additions and 7 deletions

View File

@ -332,7 +332,7 @@ namespace osu.Game.Screens.Edit
/// The next beatmap to be shown, in the case of difficulty switch.
/// <see langword="null"/> indicates that the beatmap will not be changing.
/// </param>
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);

View File

@ -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);
}
}

View File

@ -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))
{
}