2019-03-18 15:39:34 +08:00
|
|
|
// 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.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
using osu.Game.Beatmaps;
|
2019-04-12 13:53:23 +08:00
|
|
|
using osu.Game.Configuration;
|
2019-03-18 15:39:34 +08:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A base class which runs <see cref="Player"/> test for all available rulesets.
|
|
|
|
/// Steps to be run for each ruleset should be added via <see cref="AddCheckSteps"/>.
|
|
|
|
/// </summary>
|
2019-05-15 03:37:25 +08:00
|
|
|
public abstract class AllPlayersTestScene : RateAdjustedBeatmapTestScene
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
|
|
|
protected Player Player;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(RulesetStore rulesets)
|
|
|
|
{
|
|
|
|
foreach (var r in rulesets.AvailableRulesets)
|
|
|
|
{
|
|
|
|
Player p = null;
|
|
|
|
AddStep(r.Name, () => p = loadPlayerFor(r));
|
2019-04-25 16:36:17 +08:00
|
|
|
AddUntilStep("player loaded", () =>
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
|
|
|
if (p?.IsLoaded == true)
|
|
|
|
{
|
|
|
|
p = null;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-04-25 16:36:17 +08:00
|
|
|
});
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
|
|
AddCheckSteps();
|
|
|
|
}
|
2019-04-12 13:53:23 +08:00
|
|
|
|
|
|
|
OsuConfigManager manager;
|
|
|
|
Dependencies.Cache(manager = new OsuConfigManager(LocalStorage));
|
|
|
|
manager.GetBindable<double>(OsuSetting.DimLevel).Value = 1.0;
|
2019-03-18 15:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract void AddCheckSteps();
|
|
|
|
|
|
|
|
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);
|
|
|
|
|
|
|
|
protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock clock) =>
|
|
|
|
new TestWorkingBeatmap(beatmap, Clock);
|
|
|
|
|
|
|
|
private Player loadPlayerFor(RulesetInfo ri)
|
|
|
|
{
|
|
|
|
Ruleset.Value = ri;
|
|
|
|
var r = ri.CreateInstance();
|
|
|
|
|
|
|
|
var beatmap = CreateBeatmap(r);
|
|
|
|
var working = CreateWorkingBeatmap(beatmap, Clock);
|
|
|
|
|
|
|
|
Beatmap.Value = working;
|
2019-04-10 11:03:57 +08:00
|
|
|
Mods.Value = new[] { r.GetAllMods().First(m => m is ModNoFail) };
|
2019-03-18 15:39:34 +08:00
|
|
|
|
|
|
|
Player?.Exit();
|
|
|
|
Player = null;
|
|
|
|
|
2019-03-22 13:10:38 +08:00
|
|
|
Player = CreatePlayer(r);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
2019-03-22 13:10:38 +08:00
|
|
|
LoadScreen(Player);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
2019-03-22 13:10:38 +08:00
|
|
|
return Player;
|
2019-03-18 15:39:34 +08:00
|
|
|
}
|
|
|
|
|
2019-05-10 14:39:25 +08:00
|
|
|
protected virtual Player CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false);
|
2019-03-18 15:39:34 +08:00
|
|
|
}
|
|
|
|
}
|