mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Propagate clock state from editor to gameplay test
This commit is contained in:
parent
ca239ca40a
commit
d2ddc25ab3
@ -325,6 +325,19 @@ namespace osu.Game.Screens.Edit
|
||||
/// </summary>
|
||||
public void UpdateClockSource() => clock.ChangeSource(Beatmap.Value.Track);
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="EditorState"/> instance representing the current state of the editor.
|
||||
/// </summary>
|
||||
/// <param name="nextBeatmap">
|
||||
/// 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
|
||||
{
|
||||
Time = clock.CurrentTimeAccurate,
|
||||
ClipboardContent = nextBeatmap == null || editorBeatmap.BeatmapInfo.RulesetID == nextBeatmap.RulesetID ? Clipboard.Content.Value : string.Empty
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Restore the editor to a provided state.
|
||||
/// </summary>
|
||||
@ -780,11 +793,7 @@ namespace osu.Game.Screens.Edit
|
||||
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, SwitchToDifficulty);
|
||||
}
|
||||
|
||||
protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, new EditorState
|
||||
{
|
||||
Time = clock.CurrentTimeAccurate,
|
||||
ClipboardContent = editorBeatmap.BeatmapInfo.RulesetID == nextBeatmap.RulesetID ? Clipboard.Content.Value : string.Empty
|
||||
});
|
||||
protected void SwitchToDifficulty(BeatmapInfo nextBeatmap) => loader?.ScheduleDifficultySwitch(nextBeatmap, getState(nextBeatmap));
|
||||
|
||||
private void cancelExit()
|
||||
{
|
||||
@ -807,7 +816,7 @@ namespace osu.Game.Screens.Edit
|
||||
pushEditorPlayer();
|
||||
}
|
||||
|
||||
void pushEditorPlayer() => this.Push(new EditorPlayerLoader());
|
||||
void pushEditorPlayer() => this.Push(new EditorPlayerLoader(getState()));
|
||||
}
|
||||
|
||||
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
@ -10,14 +11,20 @@ namespace osu.Game.Screens.Edit.GameplayTest
|
||||
{
|
||||
public class EditorPlayer : Player
|
||||
{
|
||||
public EditorPlayer()
|
||||
: base(new PlayerConfiguration { ShowResults = false })
|
||||
{
|
||||
}
|
||||
private readonly EditorState editorState;
|
||||
|
||||
[Resolved]
|
||||
private MusicController musicController { get; set; }
|
||||
|
||||
public EditorPlayer(EditorState editorState)
|
||||
: base(new PlayerConfiguration { ShowResults = false })
|
||||
{
|
||||
this.editorState = editorState;
|
||||
}
|
||||
|
||||
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
||||
=> new MasterGameplayClockContainer(beatmap, editorState.Time, true);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
@ -14,8 +14,8 @@ namespace osu.Game.Screens.Edit.GameplayTest
|
||||
[Resolved]
|
||||
private OsuLogo osuLogo { get; set; }
|
||||
|
||||
public EditorPlayerLoader()
|
||||
: base(() => new EditorPlayer())
|
||||
public EditorPlayerLoader(EditorState editorState)
|
||||
: base(() => new EditorPlayer(editorState))
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user