Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MultiplayerSkipOverlay.Button>().Single().TriggerClick());

startGameplay();

AddAssert("gameplay clock skipped to intro", () =>
{
GameplayClockContainer clock = player.ChildrenOfType<GameplayClockContainer>().Single();
return clock.CurrentTime >= clock.GameplayStartTime - MasterGameplayClockContainer.MINIMUM_SKIP_TIME;
});
}

private void setup(Func<IReadOnlyList<Mod>>? mods = null)
{
setupBeforeGameplayStart(mods);
startGameplay();
}

private void setupBeforeGameplayStart(Func<IReadOnlyList<Mod>>? mods = null)
{
AddStep("set beatmap", () =>
{
Expand All @@ -69,7 +93,7 @@ private void setup(Func<IReadOnlyList<Mod>>? 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()));
Expand All @@ -79,7 +103,10 @@ private void setup(Func<IReadOnlyList<Mod>>? mods = null)

AddAssert("gameplay clock is paused", () => player.ChildrenOfType<GameplayClockContainer>().Single().IsPaused.Value);
AddAssert("gameplay clock is not running", () => !player.ChildrenOfType<GameplayClockContainer>().Single().IsRunning);
}

private void startGameplay()
{
AddStep("start gameplay", () => ((IMultiplayerClient)MultiplayerClient).GameplayStarted());

AddUntilStep("gameplay clock is not paused", () => !player.ChildrenOfType<GameplayClockContainer>().Single().IsPaused.Value);
Expand Down
8 changes: 8 additions & 0 deletions osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading