mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Merge remote-tracking branch 'origin/master' into performance-calculator
This commit is contained in:
48
osu.Game/Tests/Visual/ScreenTestCase.cs
Normal file
48
osu.Game/Tests/Visual/ScreenTestCase.cs
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
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 (IsCurrentScreen)
|
||||
{
|
||||
Push(screen);
|
||||
nextScreen = null;
|
||||
}
|
||||
else
|
||||
MakeCurrent();
|
||||
});
|
||||
|
||||
protected override void OnResuming(Screen last)
|
||||
{
|
||||
base.OnResuming(last);
|
||||
if (nextScreen != null)
|
||||
LoadScreen(nextScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,14 +17,12 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public abstract class TestCasePlayer : OsuTestCase
|
||||
public abstract class TestCasePlayer : ScreenTestCase
|
||||
{
|
||||
private readonly Type ruleset;
|
||||
|
||||
protected Player Player;
|
||||
|
||||
public override string Description => @"Showing everything to play the game.";
|
||||
|
||||
/// <summary>
|
||||
/// Create a TestCase which runs through the Player screen.
|
||||
/// </summary>
|
||||
@ -46,6 +44,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Depth = int.MaxValue
|
||||
});
|
||||
|
||||
string instantiation = ruleset?.AssemblyQualifiedName;
|
||||
@ -79,19 +78,17 @@ namespace osu.Game.Tests.Visual
|
||||
if (Player != null)
|
||||
Remove(Player);
|
||||
|
||||
Add(Player = CreatePlayer(working, instance));
|
||||
LoadScreen(CreatePlayer(working, instance));
|
||||
}
|
||||
|
||||
protected virtual Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset)
|
||||
protected virtual Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) => new Player
|
||||
{
|
||||
return new Player
|
||||
{
|
||||
InitialBeatmap = beatmap
|
||||
};
|
||||
}
|
||||
InitialBeatmap = beatmap,
|
||||
AllowPause = false
|
||||
};
|
||||
|
||||
private const string test_beatmap_data =
|
||||
@"osu file format v14
|
||||
@"osu file format v14
|
||||
|
||||
[General]
|
||||
AudioLeadIn: 500
|
||||
|
Reference in New Issue
Block a user