1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 01:32:55 +08:00

Avoid destroying editor screens when changing between modes

This commit is contained in:
Dean Herbert 2020-09-24 17:03:54 +09:00
parent abec9224cf
commit 158d307126
7 changed files with 43 additions and 4 deletions

View File

@ -13,6 +13,11 @@ namespace osu.Game.Screens.Edit.Compose
{ {
private HitObjectComposer composer; private HitObjectComposer composer;
public ComposeScreen()
: base(EditorScreenMode.Compose)
{
}
protected override Drawable CreateMainContent() protected override Drawable CreateMainContent()
{ {
var ruleset = Beatmap.Value.BeatmapInfo.Ruleset?.CreateInstance(); var ruleset = Beatmap.Value.BeatmapInfo.Ruleset?.CreateInstance();

View File

@ -6,6 +6,7 @@ namespace osu.Game.Screens.Edit.Design
public class DesignScreen : EditorScreen public class DesignScreen : EditorScreen
{ {
public DesignScreen() public DesignScreen()
: base(EditorScreenMode.Design)
{ {
Child = new ScreenWhiteBox.UnderConstructionMessage("Design mode"); Child = new ScreenWhiteBox.UnderConstructionMessage("Design mode");
} }

View File

@ -68,7 +68,7 @@ namespace osu.Game.Screens.Edit
private string lastSavedHash; private string lastSavedHash;
private Box bottomBackground; private Box bottomBackground;
private Container screenContainer; private Container<EditorScreen> screenContainer;
private EditorScreen currentScreen; private EditorScreen currentScreen;
@ -163,7 +163,7 @@ namespace osu.Game.Screens.Edit
Name = "Screen container", Name = "Screen container",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 40, Bottom = 60 }, Padding = new MarginPadding { Top = 40, Bottom = 60 },
Child = screenContainer = new Container Child = screenContainer = new Container<EditorScreen>
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true Masking = true
@ -512,7 +512,21 @@ namespace osu.Game.Screens.Edit
private void onModeChanged(ValueChangedEvent<EditorScreenMode> e) private void onModeChanged(ValueChangedEvent<EditorScreenMode> e)
{ {
currentScreen?.Exit(); var lastScreen = currentScreen;
lastScreen?
.ScaleTo(0.98f, 200, Easing.OutQuint)
.FadeOut(200, Easing.OutQuint);
if ((currentScreen = screenContainer.FirstOrDefault(s => s.Type == e.NewValue)) != null)
{
screenContainer.ChangeChildDepth(currentScreen, lastScreen?.Depth + 1 ?? 0);
currentScreen
.ScaleTo(1, 200, Easing.OutQuint)
.FadeIn(200, Easing.OutQuint);
return;
}
switch (e.NewValue) switch (e.NewValue)
{ {

View File

@ -23,8 +23,12 @@ namespace osu.Game.Screens.Edit
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
private readonly Container content; private readonly Container content;
protected EditorScreen() public readonly EditorScreenMode Type;
protected EditorScreen(EditorScreenMode type)
{ {
Type = type;
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;

View File

@ -25,6 +25,11 @@ namespace osu.Game.Screens.Edit
private Container timelineContainer; private Container timelineContainer;
protected EditorScreenWithTimeline(EditorScreenMode type)
: base(type)
{
}
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load([CanBeNull] BindableBeatDivisor beatDivisor) private void load([CanBeNull] BindableBeatDivisor beatDivisor)
{ {

View File

@ -24,6 +24,11 @@ namespace osu.Game.Screens.Edit.Setup
private LabelledTextBox creatorTextBox; private LabelledTextBox creatorTextBox;
private LabelledTextBox difficultyTextBox; private LabelledTextBox difficultyTextBox;
public SetupScreen()
: base(EditorScreenMode.SongSetup)
{
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {

View File

@ -24,6 +24,11 @@ namespace osu.Game.Screens.Edit.Timing
[Resolved] [Resolved]
private EditorClock clock { get; set; } private EditorClock clock { get; set; }
public TimingScreen()
: base(EditorScreenMode.Timing)
{
}
protected override Drawable CreateMainContent() => new GridContainer protected override Drawable CreateMainContent() => new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,