mirror of
https://github.com/ppy/osu.git
synced 2024-11-09 01:57:24 +08:00
91302ea0bc
# Conflicts: # osu.Game/Screens/Multi/Match/MatchSubScreen.cs # osu.Game/Screens/Multi/Multiplayer.cs # osu.Game/Screens/Multi/MultiplayerSubScreen.cs # osu.Game/Screens/OsuScreen.cs # osu.Game/osu.Game.csproj # osu.sln
49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
// 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 osu.Framework.Screens;
|
|
using osu.Game.Screens;
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
{
|
|
/// <summary>
|
|
/// A test case which can be used to test a screen (that relies on OnEntering being called to execute startup instructions).
|
|
/// </summary>
|
|
public abstract class ScreenTestCase : OsuTestCase
|
|
{
|
|
private readonly TestOsuScreen baseScreen;
|
|
|
|
protected ScreenTestCase()
|
|
{
|
|
Add(baseScreen = new TestOsuScreen());
|
|
}
|
|
|
|
protected void LoadScreen(OsuScreen screen) => baseScreen.LoadScreen(screen);
|
|
|
|
public class TestOsuScreen : OsuScreen
|
|
{
|
|
private OsuScreen nextScreen;
|
|
|
|
public void LoadScreen(OsuScreen screen) => Schedule(() =>
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|