From b692abd3c2574cacd5d41033e979f431069187e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 22 Jan 2021 20:17:21 +0100 Subject: [PATCH] Simplify condition from two to one operand --- osu.Game/Skinning/PausableSkinnableSound.cs | 13 ++++++++----- .../Drawables/DrawableStoryboardSample.cs | 6 +++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/osu.Game/Skinning/PausableSkinnableSound.cs b/osu.Game/Skinning/PausableSkinnableSound.cs index 6245bcae02..d8149e76c0 100644 --- a/osu.Game/Skinning/PausableSkinnableSound.cs +++ b/osu.Game/Skinning/PausableSkinnableSound.cs @@ -18,7 +18,13 @@ namespace osu.Game.Skinning protected bool RequestedPlaying { get; private set; } - protected virtual bool AllowNonLoopingCutOff => false; + /// + /// Whether this is affected by + /// a higher-level 's state changes. + /// By default only looping samples are started/stopped on sample disable + /// to prevent one-time samples from cutting off abruptly. + /// + protected virtual bool AffectedBySamplePlaybackDisable => Looping; public PausableSkinnableSound() { @@ -48,10 +54,7 @@ namespace osu.Game.Skinning samplePlaybackDisabled.BindValueChanged(disabled => { if (!RequestedPlaying) return; - - // if the sample is non-looping, and non-looping cut off is not allowed, - // let the sample play out to completion (sounds better than abruptly cutting off). - if (!Looping && !AllowNonLoopingCutOff) return; + if (!AffectedBySamplePlaybackDisable) return; cancelPendingStart(); diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs index ebdf64e7ba..5a800a71fd 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSample.cs @@ -21,7 +21,11 @@ namespace osu.Game.Storyboards.Drawables public override bool RemoveWhenNotAlive => false; - protected override bool AllowNonLoopingCutOff => true; + /// + /// Contrary to , all s are affected + /// by sample disables, as they are oftentimes longer-running sound effects. This also matches stable behaviour. + /// + protected override bool AffectedBySamplePlaybackDisable => true; public DrawableStoryboardSample(StoryboardSampleInfo sampleInfo) : base(sampleInfo)