1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Merge pull request #14494 from frenzibyte/editor-quick-mode-switch-crash

Fix editor crashing when quickly switching between screens
This commit is contained in:
Dean Herbert 2021-08-25 23:43:32 +09:00 committed by GitHub
commit f02b6b3657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 13 deletions

View File

@ -0,0 +1,29 @@
// 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.
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components.Menus;
namespace osu.Game.Tests.Visual.Editing
{
public class TestSceneEditorScreenModes : EditorTestScene
{
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
[Test]
public void TestSwitchScreensInstantaneously()
{
AddStep("switch between all screens at once", () =>
{
foreach (var screen in Enum.GetValues(typeof(EditorScreenMode)).Cast<EditorScreenMode>())
Editor.ChildrenOfType<EditorMenuBar>().Single().Mode.Value = screen;
});
}
}
}

View File

@ -605,19 +605,14 @@ namespace osu.Game.Screens.Edit
{
var lastScreen = currentScreen;
lastScreen?
.ScaleTo(0.98f, 200, Easing.OutQuint)
.FadeOut(200, Easing.OutQuint);
lastScreen?.Hide();
try
{
if ((currentScreen = screenContainer.SingleOrDefault(s => s.Type == e.NewValue)) != null)
{
screenContainer.ChangeChildDepth(currentScreen, lastScreen?.Depth + 1 ?? 0);
currentScreen
.ScaleTo(1, 200, Easing.OutQuint)
.FadeIn(200, Easing.OutQuint);
currentScreen.Show();
return;
}
@ -650,7 +645,10 @@ namespace osu.Game.Screens.Edit
LoadComponentAsync(currentScreen, newScreen =>
{
if (newScreen == currentScreen)
{
screenContainer.Add(newScreen);
newScreen.Show();
}
});
}
finally

View File

@ -10,7 +10,7 @@ namespace osu.Game.Screens.Edit
/// <summary>
/// TODO: eventually make this inherit Screen and add a local screen stack inside the Editor.
/// </summary>
public abstract class EditorScreen : Container
public abstract class EditorScreen : VisibilityContainer
{
[Resolved]
protected EditorBeatmap EditorBeatmap { get; private set; }
@ -31,13 +31,16 @@ namespace osu.Game.Screens.Edit
InternalChild = content = new Container { RelativeSizeAxes = Axes.Both };
}
protected override void LoadComplete()
protected override void PopIn()
{
base.LoadComplete();
this.ScaleTo(1f, 200, Easing.OutQuint)
.FadeIn(200, Easing.OutQuint);
}
this.FadeTo(0)
.Then()
.FadeTo(1f, 250, Easing.OutQuint);
protected override void PopOut()
{
this.ScaleTo(0.98f, 200, Easing.OutQuint)
.FadeOut(200, Easing.OutQuint);
}
}
}