diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlayer.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlayer.cs index 99bec1e71414..12b12027d593 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlayer.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlayer.cs @@ -54,7 +54,31 @@ public void TestFail() AddUntilStep("score changed", () => player.GameplayState.ScoreProcessor.TotalScore.Value > 0); } + [Test] + public void TestSkipBeforeGameplayStartsWhenAutoSkipEnabled() + { + AddStep("enable auto skip", () => MultiplayerClient.ChangeSettings(autoSkip: true)); + + setupBeforeGameplayStart(); + + AddStep("click skip overlay", () => this.ChildrenOfType().Single().TriggerClick()); + + startGameplay(); + + AddAssert("gameplay clock skipped to intro", () => + { + GameplayClockContainer clock = player.ChildrenOfType().Single(); + return clock.CurrentTime >= clock.GameplayStartTime - MasterGameplayClockContainer.MINIMUM_SKIP_TIME; + }); + } + private void setup(Func>? mods = null) + { + setupBeforeGameplayStart(mods); + startGameplay(); + } + + private void setupBeforeGameplayStart(Func>? mods = null) { AddStep("set beatmap", () => { @@ -69,7 +93,7 @@ private void setup(Func>? mods = null) AddStep("initialise gameplay", () => { - Stack.Push(player = new MultiplayerPlayer(MultiplayerClient.ServerAPIRoom!, new PlaylistItem(Beatmap.Value.BeatmapInfo) + Stack.Push(player = new MultiplayerPlayer(MultiplayerClient.ClientAPIRoom!, new PlaylistItem(Beatmap.Value.BeatmapInfo) { RulesetID = Beatmap.Value.BeatmapInfo.Ruleset.OnlineID, }, MultiplayerClient.ServerRoom!.Users.ToArray())); @@ -79,7 +103,10 @@ private void setup(Func>? mods = null) AddAssert("gameplay clock is paused", () => player.ChildrenOfType().Single().IsPaused.Value); AddAssert("gameplay clock is not running", () => !player.ChildrenOfType().Single().IsRunning); + } + private void startGameplay() + { AddStep("start gameplay", () => ((IMultiplayerClient)MultiplayerClient).GameplayStarted()); AddUntilStep("gameplay clock is not paused", () => !player.ChildrenOfType().Single().IsPaused.Value); diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs index 66e98d1c322e..f6033a8ebfc0 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs @@ -197,6 +197,14 @@ private void onGameplayStarted() => Scheduler.Add(() => loadingDisplay.Hide(); base.StartGameplay(); + + // It is possible that the skip overlay has been clicked before `onGameplayStarted()'. + // If so, the intro-skipped clock will reset as gameplay starts, leaving the player unable to skip. + // This ensures the intro is properly skipped regardless of the overlay. + if (Configuration.AutomaticallySkipIntro) + { + RequestIntroSkip(); + } }); private void onResultsReady()