1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 01:07:24 +08:00
osu-lazer/osu.Game/Tests/Visual/PlayerTestScene.cs

58 lines
1.6 KiB
C#
Raw Normal View History

// 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;
2019-03-18 18:44:14 +08:00
using osu.Framework.Testing;
2019-04-12 13:53:23 +08:00
using osu.Game.Configuration;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual
{
public abstract class PlayerTestScene : RateAdjustedBeatmapTestScene
{
private readonly Ruleset ruleset;
protected Player Player;
protected PlayerTestScene(Ruleset ruleset)
{
this.ruleset = ruleset;
}
[BackgroundDependencyLoader]
private void load()
{
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 18:44:14 +08:00
}
2019-03-18 18:44:14 +08:00
[SetUpSteps]
public virtual void SetUpSteps()
2019-03-18 18:44:14 +08:00
{
AddStep(ruleset.RulesetInfo.Name, loadPlayer);
2019-04-25 16:36:17 +08:00
AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1);
}
protected virtual bool AllowFail => false;
private void loadPlayer()
{
var beatmap = CreateBeatmap(ruleset.RulesetInfo);
Beatmap.Value = CreateWorkingBeatmap(beatmap);
if (!AllowFail)
2019-04-10 11:03:57 +08:00
Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
Player = CreatePlayer(ruleset);
LoadScreen(Player);
}
protected virtual Player CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false);
}
}