Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable pausing music during intro sequence #26411

Merged
merged 7 commits into from
Jan 8, 2024
Merged
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
39 changes: 39 additions & 0 deletions osu.Game.Tests/Visual/Menus/TestSceneIntroMusicActionHandling.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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.Testing;
using osu.Game.Input.Bindings;
using osu.Game.Screens.Menu;

namespace osu.Game.Tests.Visual.Menus
{
public partial class TestSceneIntroMusicActionHandling : OsuGameTestScene
{
private GlobalActionContainer globalActionContainer => Game.ChildrenOfType<GlobalActionContainer>().First();

public override void SetUpSteps()
{
CreateNewGame();
// we do not want to progress to main menu immediately, hence the override and lack of `ConfirmAtMainMenu()` call here.
}

[Test]
public void TestPauseDuringIntro()
{
AddUntilStep("Wait for music", () => Game?.MusicController.IsPlaying == true);

// Check that pause doesn't work during intro sequence.
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
AddAssert("Still playing before menu", () => Game?.MusicController.IsPlaying == true);
AddUntilStep("Wait for main menu", () => Game?.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);

// Check that toggling after intro still works.
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
AddUntilStep("Music paused", () => Game?.MusicController.IsPlaying == false && Game?.MusicController.UserPauseRequested == true);
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
AddUntilStep("Music resumed", () => Game?.MusicController.IsPlaying == true && Game?.MusicController.UserPauseRequested == false);
}
}
}
2 changes: 2 additions & 0 deletions osu.Game/Screens/Menu/IntroScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public abstract partial class IntroScreen : StartupScreen
Colour = Color4.Black
};

public override bool? AllowGlobalTrackControl => false;

protected IntroScreen([CanBeNull] Func<MainMenu> createNextScreen = null)
{
this.createNextScreen = createNextScreen;
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Screens/Menu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public partial class MainMenu : OsuScreen, IHandlePresentBeatmap, IKeyBindingHan

public override bool AllowExternalScreenChange => true;

public override bool? AllowGlobalTrackControl => true;

private Screen songSelect;

private MenuSideFlashes sideFlashes;
Expand Down
8 changes: 6 additions & 2 deletions osu.Game/Tests/Visual/OsuGameTestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ private void load()

[SetUpSteps]
public virtual void SetUpSteps()
{
CreateNewGame();
ConfirmAtMainMenu();
}

protected void CreateNewGame()
{
AddStep("Create new game instance", () =>
{
Expand All @@ -71,8 +77,6 @@ public virtual void SetUpSteps()

AddUntilStep("Wait for load", () => Game.IsLoaded);
AddUntilStep("Wait for intro", () => Game.ScreenStack.CurrentScreen is IntroScreen);

ConfirmAtMainMenu();
}

[TearDownSteps]
Expand Down
Loading