2019-03-26 07:13:58 +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.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
2019-05-31 06:58:46 +00:00
|
|
|
public class TestCaseLeadIn : RateAdjustedBeatmapTestScene
|
2019-03-26 07:13:58 +00:00
|
|
|
{
|
|
|
|
private Ruleset ruleset;
|
|
|
|
|
|
|
|
private LeadInPlayer player;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(RulesetStore rulesets)
|
|
|
|
{
|
|
|
|
Add(new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
Depth = int.MaxValue
|
|
|
|
});
|
|
|
|
|
|
|
|
ruleset = rulesets.AvailableRulesets.First().CreateInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestShortLeadIn()
|
|
|
|
{
|
|
|
|
AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 1000 } }));
|
|
|
|
AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestLongLeadIn()
|
|
|
|
{
|
|
|
|
AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 10000 } }));
|
|
|
|
AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void loadPlayerWithBeatmap(IBeatmap beatmap)
|
|
|
|
{
|
2019-11-15 05:03:51 +00:00
|
|
|
Beatmap.Value = new TestWorkingBeatmap(beatmap);
|
2019-03-26 07:13:58 +00:00
|
|
|
|
2019-05-31 06:58:46 +00:00
|
|
|
LoadScreen(player = new LeadInPlayer());
|
2019-03-26 07:13:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class LeadInPlayer : Player
|
|
|
|
{
|
2019-05-31 06:58:46 +00:00
|
|
|
public LeadInPlayer()
|
|
|
|
: base(false, false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-03-26 07:13:58 +00:00
|
|
|
public double? FirstFrameClockTime;
|
|
|
|
|
|
|
|
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
|
|
|
|
|
|
|
public double GameplayStartTime => DrawableRuleset.GameplayStartTime;
|
|
|
|
|
|
|
|
public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
|
|
|
|
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
{
|
|
|
|
base.UpdateAfterChildren();
|
2019-05-31 06:58:46 +00:00
|
|
|
|
2019-03-26 07:13:58 +00:00
|
|
|
if (!FirstFrameClockTime.HasValue)
|
|
|
|
{
|
|
|
|
FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
|
|
|
AddInternal(new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} "
|
|
|
|
+ $"LeadInTime: {Beatmap.Value.BeatmapInfo.AudioLeadIn} "
|
|
|
|
+ $"FirstFrameClockTime: {FirstFrameClockTime}"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|