2021-04-14 04:04:03 +00: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.Threading.Tasks;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Screens;
|
2021-04-16 04:59:10 +00:00
|
|
|
using osu.Framework.Testing;
|
2021-04-14 04:04:03 +00:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
using osu.Game.Screens.Ranking;
|
|
|
|
using osu.Game.Storyboards;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
|
|
|
public class TestSceneStoryboardWithOutro : PlayerTestScene
|
|
|
|
{
|
|
|
|
protected new OutroPlayer Player => (OutroPlayer)base.Player;
|
|
|
|
|
|
|
|
private const double storyboard_duration = 2000;
|
|
|
|
|
2021-04-16 04:59:10 +00:00
|
|
|
[SetUpSteps]
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
2021-04-17 17:57:32 +00:00
|
|
|
AddStep("enable storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, true));
|
|
|
|
AddStep("set dim level to 0", () => LocalConfig.SetValue<double>(OsuSetting.DimLevel, 0));
|
2021-04-16 04:59:10 +00:00
|
|
|
}
|
|
|
|
|
2021-04-14 04:04:03 +00:00
|
|
|
[Test]
|
|
|
|
public void TestStoryboardSkipOutro()
|
|
|
|
{
|
|
|
|
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
|
|
|
AddStep("skip outro", () => InputManager.Key(osuTK.Input.Key.Space));
|
|
|
|
AddAssert("score shown", () => Player.IsScoreShown);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestStoryboardNoSkipOutro()
|
|
|
|
{
|
2021-04-17 17:57:32 +00:00
|
|
|
AddUntilStep("storyboard ends", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= storyboard_duration);
|
2021-04-16 04:59:10 +00:00
|
|
|
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
2021-04-14 04:04:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestStoryboardExitToSkipOutro()
|
|
|
|
{
|
|
|
|
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
|
|
|
AddStep("exit via pause", () => Player.ExitViaPause());
|
|
|
|
AddAssert("score shown", () => Player.IsScoreShown);
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:49:29 +00:00
|
|
|
[TestCase(false)]
|
|
|
|
[TestCase(true)]
|
|
|
|
public void TestStoryboardToggle(bool enabledAtBeginning)
|
|
|
|
{
|
|
|
|
AddStep($"{(enabledAtBeginning ? "enable" : "disable")} storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, enabledAtBeginning));
|
2021-04-18 02:13:28 +00:00
|
|
|
AddStep("toggle storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, !enabledAtBeginning));
|
2021-04-18 01:49:29 +00:00
|
|
|
AddUntilStep("wait for score shown", () => Player.IsScoreShown);
|
|
|
|
}
|
|
|
|
|
2021-04-14 04:04:03 +00:00
|
|
|
protected override bool AllowFail => false;
|
|
|
|
|
|
|
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
|
|
|
|
|
|
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new OutroPlayer();
|
|
|
|
|
|
|
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
|
|
|
{
|
|
|
|
var beatmap = new Beatmap();
|
|
|
|
beatmap.HitObjects.Add(new HitCircle());
|
|
|
|
return beatmap;
|
|
|
|
}
|
|
|
|
|
2021-04-17 17:57:32 +00:00
|
|
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
|
|
|
{
|
|
|
|
if (storyboard == null)
|
|
|
|
{
|
|
|
|
storyboard = new Storyboard();
|
|
|
|
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
|
|
|
|
sprite.TimelineGroup.Alpha.Add(Easing.None, 0, storyboard_duration, 1, 0);
|
|
|
|
storyboard.GetLayer("Background").Add(sprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.CreateWorkingBeatmap(beatmap, storyboard);
|
|
|
|
}
|
2021-04-14 04:04:03 +00:00
|
|
|
|
|
|
|
protected class OutroPlayer : TestPlayer
|
|
|
|
{
|
|
|
|
public void ExitViaPause() => PerformExit(true);
|
|
|
|
|
|
|
|
public bool IsScoreShown => !this.IsCurrentScreen() && this.GetChildScreen() is ResultsScreen;
|
|
|
|
|
|
|
|
public OutroPlayer()
|
|
|
|
: base(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Task ImportScore(Score score)
|
|
|
|
{
|
|
|
|
return Task.CompletedTask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|