2019-05-10 17:10:07 +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-09-02 11:54:59 +08:00
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2019-03-18 18:44:14 +08:00
|
|
|
using osu.Framework.Testing;
|
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;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
{
|
2019-05-15 03:37:25 +08:00
|
|
|
public abstract class PlayerTestScene : RateAdjustedBeatmapTestScene
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
|
|
|
private readonly Ruleset ruleset;
|
|
|
|
|
|
|
|
protected Player Player;
|
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
protected PlayerTestScene(Ruleset ruleset)
|
2019-03-18 15:39:34 +08:00
|
|
|
{
|
|
|
|
this.ruleset = ruleset;
|
2019-03-26 12:16:46 +08:00
|
|
|
}
|
2019-03-18 15:39:34 +08:00
|
|
|
|
2019-08-28 18:57:17 +08:00
|
|
|
protected OsuConfigManager LocalConfig;
|
|
|
|
|
2019-03-26 12:16:46 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2019-08-28 18:57:17 +08:00
|
|
|
Dependencies.Cache(LocalConfig = new OsuConfigManager(LocalStorage));
|
|
|
|
LocalConfig.GetBindable<double>(OsuSetting.DimLevel).Value = 1.0;
|
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]
|
2019-05-10 17:10:07 +08:00
|
|
|
public virtual void SetUpSteps()
|
2019-03-18 18:44:14 +08:00
|
|
|
{
|
2019-03-18 15:39:34 +08:00
|
|
|
AddStep(ruleset.RulesetInfo.Name, loadPlayer);
|
2019-04-25 16:36:17 +08:00
|
|
|
AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1);
|
2019-03-18 15:39:34 +08:00
|
|
|
}
|
|
|
|
|
2019-03-18 18:43:55 +08:00
|
|
|
protected virtual bool AllowFail => false;
|
|
|
|
|
2019-09-02 11:54:59 +08:00
|
|
|
protected virtual bool Autoplay => false;
|
|
|
|
|
2019-03-18 15:39:34 +08:00
|
|
|
private void loadPlayer()
|
|
|
|
{
|
2019-05-31 13:40:53 +08:00
|
|
|
var beatmap = CreateBeatmap(ruleset.RulesetInfo);
|
2019-03-18 15:39:34 +08:00
|
|
|
|
2019-05-31 13:40:53 +08:00
|
|
|
Beatmap.Value = CreateWorkingBeatmap(beatmap);
|
2019-03-18 18:43:55 +08:00
|
|
|
|
|
|
|
if (!AllowFail)
|
2019-04-10 11:03:57 +08:00
|
|
|
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-09-02 11:54:59 +08:00
|
|
|
protected virtual Player CreatePlayer(Ruleset ruleset)
|
|
|
|
{
|
|
|
|
if (Autoplay)
|
|
|
|
{
|
|
|
|
var mod = ruleset.GetAutoplayMod();
|
|
|
|
if (mod != null)
|
|
|
|
Mods.Value = Mods.Value.Concat(mod.Yield()).ToArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
return new TestPlayer(false, false);
|
|
|
|
}
|
2019-03-18 15:39:34 +08:00
|
|
|
}
|
|
|
|
}
|