From b220939650672b6e2056464f32082a31b8f0c531 Mon Sep 17 00:00:00 2001 From: Mysfit <8022806+Mysfit@users.noreply.github.com> Date: Thu, 21 Jan 2021 17:10:11 -0500 Subject: [PATCH] Fix storyboard samples continuing to play when the beatmap is paused or the intro is skipped. --- osu.Game/Screens/Play/Player.cs | 13 ++++++++++++- osu.Game/Skinning/PausableSkinnableSound.cs | 8 ++++---- .../Drawables/DrawableStoryboardSample.cs | 10 ++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 1fcbed7ef7..b622f11775 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -353,7 +353,7 @@ namespace osu.Game.Screens.Play }, skipOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime) { - RequestSkip = GameplayClockContainer.Skip + RequestSkip = performUserRequestedSkip }, FailOverlay = new FailOverlay { @@ -488,6 +488,17 @@ namespace osu.Game.Screens.Play this.Exit(); } + private void performUserRequestedSkip() + { + // user requested skip + // disable sample playback to stop currently playing samples and perform skip + samplePlaybackDisabled.Value = true; + GameplayClockContainer.Skip(); + + // return samplePlaybackDisabled.Value to what is defined by the beatmap's current state + updateSampleDisabledState(); + } + private void performUserRequestedExit() { if (ValidForResume && HasFailed && !FailOverlay.IsPresent) diff --git a/osu.Game/Skinning/PausableSkinnableSound.cs b/osu.Game/Skinning/PausableSkinnableSound.cs index cb5234c847..e0891fbda2 100644 --- a/osu.Game/Skinning/PausableSkinnableSound.cs +++ b/osu.Game/Skinning/PausableSkinnableSound.cs @@ -32,7 +32,7 @@ namespace osu.Game.Skinning { } - private readonly IBindable samplePlaybackDisabled = new Bindable(); + protected readonly IBindable SamplePlaybackDisabled = new Bindable(); private ScheduledDelegate scheduledStart; @@ -42,8 +42,8 @@ namespace osu.Game.Skinning // if in a gameplay context, pause sample playback when gameplay is paused. if (samplePlaybackDisabler != null) { - samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled); - samplePlaybackDisabled.BindValueChanged(disabled => + SamplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled); + SamplePlaybackDisabled.BindValueChanged(disabled => { if (!RequestedPlaying) return; @@ -72,7 +72,7 @@ namespace osu.Game.Skinning cancelPendingStart(); RequestedPlaying = true; - if (samplePlaybackDisabled.Value) + if (SamplePlaybackDisabled.Value) return; base.Play(restart); diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs index 218f051bf0..5b49e71daa 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs @@ -40,6 +40,16 @@ namespace osu.Game.Storyboards.Drawables foreach (var sample in DrawableSamples) mod.ApplyToSample(sample); } + + SamplePlaybackDisabled.BindValueChanged(disabled => + { + if (!RequestedPlaying) return; + + // Since storyboard samples can be very long we want to stop the playback regardless of + // whether or not the sample is looping or not + if (disabled.NewValue) + Stop(); + }); } protected override void Update()