2021-11-11 06:11:25 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2021-11-11 22:45:10 +08:00
|
|
|
using osu.Framework.Allocation;
|
2021-11-11 22:25:58 +08:00
|
|
|
using osu.Framework.Screens;
|
2021-11-12 19:50:38 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2021-11-11 22:45:10 +08:00
|
|
|
using osu.Game.Overlays;
|
2021-11-11 06:11:25 +08:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
2021-11-12 19:07:38 +08:00
|
|
|
namespace osu.Game.Screens.Edit.GameplayTest
|
2021-11-11 06:11:25 +08:00
|
|
|
{
|
|
|
|
public class EditorPlayer : Player
|
|
|
|
{
|
2021-11-12 20:12:25 +08:00
|
|
|
private readonly Editor editor;
|
2021-11-12 19:50:38 +08:00
|
|
|
private readonly EditorState editorState;
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private MusicController musicController { get; set; }
|
|
|
|
|
2021-11-12 20:12:25 +08:00
|
|
|
public EditorPlayer(Editor editor)
|
2021-11-11 06:11:25 +08:00
|
|
|
: base(new PlayerConfiguration { ShowResults = false })
|
|
|
|
{
|
2021-11-12 20:12:25 +08:00
|
|
|
this.editor = editor;
|
|
|
|
editorState = editor.GetState();
|
2021-11-11 06:11:25 +08:00
|
|
|
}
|
|
|
|
|
2021-11-12 19:50:38 +08:00
|
|
|
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
|
|
|
=> new MasterGameplayClockContainer(beatmap, editorState.Time, true);
|
2021-11-11 22:45:10 +08:00
|
|
|
|
2021-11-11 22:25:58 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
ScoreProcessor.HasCompleted.BindValueChanged(completed =>
|
|
|
|
{
|
|
|
|
if (completed.NewValue)
|
|
|
|
Scheduler.AddDelayed(this.Exit, RESULTS_DISPLAY_DELAY);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-11-11 06:11:25 +08:00
|
|
|
protected override void PrepareReplay()
|
|
|
|
{
|
|
|
|
// don't record replays.
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool CheckModsAllowFailure() => false; // never fail.
|
2021-11-11 22:45:10 +08:00
|
|
|
|
2021-11-12 20:51:02 +08:00
|
|
|
public override void OnEntering(IScreen last)
|
|
|
|
{
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
|
|
|
// finish alpha transforms on entering to avoid gameplay starting in a half-hidden state.
|
|
|
|
// the finish calls are purposefully not propagated to children to avoid messing up their state.
|
|
|
|
FinishTransforms();
|
|
|
|
GameplayClockContainer.FinishTransforms(false, nameof(Alpha));
|
|
|
|
}
|
|
|
|
|
2021-11-11 22:45:10 +08:00
|
|
|
public override bool OnExiting(IScreen next)
|
|
|
|
{
|
|
|
|
musicController.Stop();
|
2021-11-12 20:12:25 +08:00
|
|
|
|
|
|
|
editorState.Time = GameplayClockContainer.CurrentTime;
|
|
|
|
editor.RestoreState(editorState);
|
2021-11-11 22:45:10 +08:00
|
|
|
return base.OnExiting(next);
|
|
|
|
}
|
2021-11-11 06:11:25 +08:00
|
|
|
}
|
|
|
|
}
|