Make EditorTestScene go through EditorLoader

This commit is contained in:
Bartłomiej Dach
2021-09-11 20:43:17 +02:00
parent f370cb35e6
commit 8357efc74f
2 changed files with 43 additions and 16 deletions

View File

@ -34,6 +34,20 @@ namespace osu.Game.Screens.Edit
[CanBeNull] [CanBeNull]
private ScheduledDelegate scheduledDifficultySwitch; private ScheduledDelegate scheduledDifficultySwitch;
[BackgroundDependencyLoader]
private void load()
{
AddRangeInternal(new Drawable[]
{
new LoadingSpinner(true)
{
State = { Value = Visibility.Visible },
}
});
}
protected virtual Editor CreateEditor() => new Editor(this);
protected override void LogoArriving(OsuLogo logo, bool resuming) protected override void LogoArriving(OsuLogo logo, bool resuming)
{ {
base.LogoArriving(logo, resuming); base.LogoArriving(logo, resuming);
@ -47,18 +61,6 @@ namespace osu.Game.Screens.Edit
} }
} }
[BackgroundDependencyLoader]
private void load()
{
AddRangeInternal(new Drawable[]
{
new LoadingSpinner(true)
{
State = { Value = Visibility.Visible },
}
});
}
public void ScheduleDifficultySwitch(BeatmapInfo beatmapInfo) public void ScheduleDifficultySwitch(BeatmapInfo beatmapInfo)
{ {
scheduledDifficultySwitch?.Cancel(); scheduledDifficultySwitch?.Cancel();
@ -81,7 +83,7 @@ namespace osu.Game.Screens.Edit
private void pushEditor() private void pushEditor()
{ {
this.Push(new Editor(this)); this.Push(CreateEditor());
ValidForResume = false; ValidForResume = false;
} }

View File

@ -16,6 +16,7 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline; using osu.Game.Screens.Edit.Compose.Components.Timeline;
using osu.Game.Screens.Menu;
using osu.Game.Skinning; using osu.Game.Skinning;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -24,7 +25,9 @@ namespace osu.Game.Tests.Visual
{ {
protected EditorBeatmap EditorBeatmap; protected EditorBeatmap EditorBeatmap;
protected TestEditor Editor { get; private set; } private TestEditorLoader editorLoader;
protected TestEditor Editor => editorLoader.Editor;
protected EditorClock EditorClock { get; private set; } protected EditorClock EditorClock { get; private set; }
@ -33,9 +36,19 @@ namespace osu.Game.Tests.Visual
/// </summary> /// </summary>
protected virtual bool IsolateSavingFromDatabase => true; protected virtual bool IsolateSavingFromDatabase => true;
// required for screen transitions to work properly
// (see comment in EditorLoader.LogoArriving).
[Cached]
private OsuLogo logo = new OsuLogo
{
Alpha = 0
};
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio, RulesetStore rulesets) private void load(GameHost host, AudioManager audio, RulesetStore rulesets)
{ {
Add(logo);
var working = CreateWorkingBeatmap(Ruleset.Value); var working = CreateWorkingBeatmap(Ruleset.Value);
Beatmap.Value = working; Beatmap.Value = working;
@ -59,7 +72,7 @@ namespace osu.Game.Tests.Visual
protected virtual void LoadEditor() protected virtual void LoadEditor()
{ {
LoadScreen(Editor = CreateEditor()); LoadScreen(editorLoader = new TestEditorLoader());
} }
/// <summary> /// <summary>
@ -70,7 +83,14 @@ namespace osu.Game.Tests.Visual
protected sealed override Ruleset CreateRuleset() => CreateEditorRuleset(); protected sealed override Ruleset CreateRuleset() => CreateEditorRuleset();
protected virtual TestEditor CreateEditor() => new TestEditor(); protected class TestEditorLoader : EditorLoader
{
public TestEditor Editor { get; private set; }
protected sealed override Editor CreateEditor() => Editor = CreateTestEditor(this);
protected virtual TestEditor CreateTestEditor(EditorLoader loader) => new TestEditor(loader);
}
protected class TestEditor : Editor protected class TestEditor : Editor
{ {
@ -87,6 +107,11 @@ namespace osu.Game.Tests.Visual
public new void Paste() => base.Paste(); public new void Paste() => base.Paste();
public new bool HasUnsavedChanges => base.HasUnsavedChanges; public new bool HasUnsavedChanges => base.HasUnsavedChanges;
public TestEditor(EditorLoader loader = null)
: base(loader)
{
}
} }
private class TestBeatmapManager : BeatmapManager private class TestBeatmapManager : BeatmapManager