2019-03-18 18:44:14 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-03-18 15:39:34 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using System.Linq;
|
2019-03-26 12:16:46 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-18 15:39:34 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-03-18 18:44:14 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2019-03-18 15:39:34 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
|
|
|
|
public abstract class PlayerTestCase : RateAdjustedBeatmapTestCase
|
|
|
|
|
{
|
|
|
|
|
private readonly Ruleset ruleset;
|
|
|
|
|
|
|
|
|
|
protected Player Player;
|
|
|
|
|
|
|
|
|
|
protected PlayerTestCase(Ruleset ruleset)
|
|
|
|
|
{
|
|
|
|
|
this.ruleset = ruleset;
|
2019-03-26 12:16:46 +08:00
|
|
|
|
}
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
2019-03-26 12:16:46 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2019-03-18 15:39:34 +08:00
|
|
|
|
Add(new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
Depth = int.MaxValue
|
|
|
|
|
});
|
2019-03-18 18:44:14 +08:00
|
|
|
|
}
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
2019-03-18 18:44:14 +08:00
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetUpSteps()
|
|
|
|
|
{
|
2019-03-18 15:39:34 +08:00
|
|
|
|
AddStep(ruleset.RulesetInfo.Name, loadPlayer);
|
|
|
|
|
AddUntilStep(() => Player.IsLoaded, "player loaded");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);
|
|
|
|
|
|
2019-03-18 18:43:55 +08:00
|
|
|
|
protected virtual bool AllowFail => false;
|
|
|
|
|
|
2019-03-18 15:39:34 +08:00
|
|
|
|
private void loadPlayer()
|
|
|
|
|
{
|
|
|
|
|
var beatmap = CreateBeatmap(ruleset);
|
|
|
|
|
|
|
|
|
|
Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock);
|
2019-03-18 18:43:55 +08:00
|
|
|
|
|
|
|
|
|
if (!AllowFail)
|
|
|
|
|
Beatmap.Value.Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
2019-03-22 13:10:38 +08:00
|
|
|
|
Player = CreatePlayer(ruleset);
|
|
|
|
|
LoadScreen(Player);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 15:53:44 +08:00
|
|
|
|
protected virtual Player CreatePlayer(Ruleset ruleset) => new Player(false, false);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|