mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 14:23:02 +08:00
Fix test screen loading
This commit is contained in:
parent
beab367e6d
commit
e8c39b9c37
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
|
|
||||||
@ -11,38 +12,21 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ScreenTestCase : OsuTestCase
|
public abstract class ScreenTestCase : OsuTestCase
|
||||||
{
|
{
|
||||||
private readonly TestOsuScreen baseScreen;
|
private readonly ScreenStack stack;
|
||||||
|
|
||||||
protected ScreenTestCase()
|
protected ScreenTestCase()
|
||||||
{
|
{
|
||||||
Add(baseScreen = new TestOsuScreen());
|
Add(stack = new ScreenStack
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void LoadScreen(OsuScreen screen) => baseScreen.LoadScreen(screen);
|
protected void LoadScreen(OsuScreen screen)
|
||||||
|
|
||||||
public class TestOsuScreen : OsuScreen
|
|
||||||
{
|
{
|
||||||
private OsuScreen nextScreen;
|
if (stack.CurrentScreen != null)
|
||||||
|
stack.Exit();
|
||||||
public void LoadScreen(OsuScreen screen) => Schedule(() =>
|
stack.Push(screen);
|
||||||
{
|
|
||||||
nextScreen = screen;
|
|
||||||
|
|
||||||
if (this.IsCurrentScreen())
|
|
||||||
{
|
|
||||||
this.Push(screen);
|
|
||||||
nextScreen = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.MakeCurrent();
|
|
||||||
});
|
|
||||||
|
|
||||||
public override void OnResuming(IScreen last)
|
|
||||||
{
|
|
||||||
base.OnResuming(last);
|
|
||||||
if (nextScreen != null)
|
|
||||||
LoadScreen(nextScreen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user