mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Make EditorTestScene
go through EditorLoader
This commit is contained in:
parent
f370cb35e6
commit
8357efc74f
@ -34,6 +34,20 @@ namespace osu.Game.Screens.Edit
|
||||
[CanBeNull]
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
scheduledDifficultySwitch?.Cancel();
|
||||
@ -81,7 +83,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
private void pushEditor()
|
||||
{
|
||||
this.Push(new Editor(this));
|
||||
this.Push(CreateEditor());
|
||||
ValidForResume = false;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
@ -24,7 +25,9 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
protected EditorBeatmap EditorBeatmap;
|
||||
|
||||
protected TestEditor Editor { get; private set; }
|
||||
private TestEditorLoader editorLoader;
|
||||
|
||||
protected TestEditor Editor => editorLoader.Editor;
|
||||
|
||||
protected EditorClock EditorClock { get; private set; }
|
||||
|
||||
@ -33,9 +36,19 @@ namespace osu.Game.Tests.Visual
|
||||
/// </summary>
|
||||
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]
|
||||
private void load(GameHost host, AudioManager audio, RulesetStore rulesets)
|
||||
{
|
||||
Add(logo);
|
||||
|
||||
var working = CreateWorkingBeatmap(Ruleset.Value);
|
||||
|
||||
Beatmap.Value = working;
|
||||
@ -59,7 +72,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected virtual void LoadEditor()
|
||||
{
|
||||
LoadScreen(Editor = CreateEditor());
|
||||
LoadScreen(editorLoader = new TestEditorLoader());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -70,7 +83,14 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
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
|
||||
{
|
||||
@ -87,6 +107,11 @@ namespace osu.Game.Tests.Visual
|
||||
public new void Paste() => base.Paste();
|
||||
|
||||
public new bool HasUnsavedChanges => base.HasUnsavedChanges;
|
||||
|
||||
public TestEditor(EditorLoader loader = null)
|
||||
: base(loader)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestBeatmapManager : BeatmapManager
|
||||
|
Loading…
Reference in New Issue
Block a user