mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 08:43:01 +08:00
Merge pull request #22598 from peppy/fix-skip-intro-replay
Fix "skip" key binding no longer working in replay playback
This commit is contained in:
commit
8292052dc2
@ -1,32 +1,64 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneReplayPlayer : RateAdjustedBeatmapTestScene
|
||||
{
|
||||
protected TestReplayPlayer Player;
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("Initialise player", () => Player = CreatePlayer(new OsuRuleset()));
|
||||
AddStep("Load player", () => LoadScreen(Player));
|
||||
AddUntilStep("player loaded", () => Player.IsLoaded);
|
||||
}
|
||||
protected TestReplayPlayer Player = null!;
|
||||
|
||||
[Test]
|
||||
public void TestPauseViaSpace()
|
||||
{
|
||||
loadPlayerWithBeatmap();
|
||||
|
||||
double? lastTime = null;
|
||||
|
||||
AddUntilStep("wait for first hit", () => Player.ScoreProcessor.TotalScore.Value > 0);
|
||||
|
||||
AddStep("Pause playback with space", () => InputManager.Key(Key.Space));
|
||||
|
||||
AddAssert("player not exited", () => Player.IsCurrentScreen());
|
||||
|
||||
AddUntilStep("Time stopped progressing", () =>
|
||||
{
|
||||
double current = Player.GameplayClockContainer.CurrentTime;
|
||||
bool changed = lastTime != current;
|
||||
lastTime = current;
|
||||
|
||||
return !changed;
|
||||
});
|
||||
|
||||
AddWaitStep("wait some", 10);
|
||||
|
||||
AddAssert("Time still stopped", () => lastTime == Player.GameplayClockContainer.CurrentTime);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPauseViaSpaceWithSkip()
|
||||
{
|
||||
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
BeatmapInfo = { AudioLeadIn = 60000 }
|
||||
});
|
||||
|
||||
AddUntilStep("wait for skip overlay", () => Player.ChildrenOfType<SkipOverlay>().First().IsButtonVisible);
|
||||
|
||||
AddStep("Skip with space", () => InputManager.Key(Key.Space));
|
||||
|
||||
AddAssert("Player not paused", () => !Player.DrawableRuleset.IsPaused.Value);
|
||||
|
||||
double? lastTime = null;
|
||||
|
||||
AddUntilStep("wait for first hit", () => Player.ScoreProcessor.TotalScore.Value > 0);
|
||||
@ -52,6 +84,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestPauseViaMiddleMouse()
|
||||
{
|
||||
loadPlayerWithBeatmap();
|
||||
|
||||
double? lastTime = null;
|
||||
|
||||
AddUntilStep("wait for first hit", () => Player.ScoreProcessor.TotalScore.Value > 0);
|
||||
@ -77,6 +111,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestSeekBackwards()
|
||||
{
|
||||
loadPlayerWithBeatmap();
|
||||
|
||||
double? lastTime = null;
|
||||
|
||||
AddUntilStep("wait for first hit", () => Player.ScoreProcessor.TotalScore.Value > 0);
|
||||
@ -93,6 +129,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestSeekForwards()
|
||||
{
|
||||
loadPlayerWithBeatmap();
|
||||
|
||||
double? lastTime = null;
|
||||
|
||||
AddUntilStep("wait for first hit", () => Player.ScoreProcessor.TotalScore.Value > 0);
|
||||
@ -106,12 +144,26 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("Jumped forwards", () => Player.GameplayClockContainer.CurrentTime - lastTime > 500);
|
||||
}
|
||||
|
||||
protected TestReplayPlayer CreatePlayer(Ruleset ruleset)
|
||||
private void loadPlayerWithBeatmap(IBeatmap? beatmap = null)
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(ruleset.RulesetInfo);
|
||||
AddStep("create player", () =>
|
||||
{
|
||||
CreatePlayer(new OsuRuleset(), beatmap);
|
||||
});
|
||||
|
||||
AddStep("Load player", () => LoadScreen(Player));
|
||||
AddUntilStep("player loaded", () => Player.IsLoaded);
|
||||
}
|
||||
|
||||
protected void CreatePlayer(Ruleset ruleset, IBeatmap? beatmap = null)
|
||||
{
|
||||
Beatmap.Value = beatmap != null
|
||||
? CreateWorkingBeatmap(beatmap)
|
||||
: CreateWorkingBeatmap(ruleset.RulesetInfo);
|
||||
|
||||
SelectedMods.Value = new[] { ruleset.GetAutoplayMod() };
|
||||
|
||||
return new TestReplayPlayer(false);
|
||||
Player = new TestReplayPlayer(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ namespace osu.Game.Input.Bindings
|
||||
// It is used to decide the order of precedence, with the earlier items having higher precedence.
|
||||
public override IEnumerable<IKeyBinding> DefaultKeyBindings => GlobalKeyBindings
|
||||
.Concat(EditorKeyBindings)
|
||||
.Concat(ReplayKeyBindings)
|
||||
.Concat(InGameKeyBindings)
|
||||
.Concat(ReplayKeyBindings)
|
||||
.Concat(SongSelectKeyBindings)
|
||||
.Concat(AudioControlKeyBindings)
|
||||
// Overlay bindings may conflict with more local cases like the editor so they are checked last.
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user