mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
DrawableStoryboardSample event method override for SamplePlaybackDisabledChanged
This commit is contained in:
parent
304264046b
commit
3307e8357f
@ -18,14 +18,6 @@ namespace osu.Game.Skinning
|
||||
|
||||
protected bool RequestedPlaying { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this <see cref="PausableSkinnableSound"/> is affected by
|
||||
/// a higher-level <see cref="ISamplePlaybackDisabler"/>'s state changes.
|
||||
/// By default only looping samples are started/stopped on sample disable
|
||||
/// to prevent one-time samples from cutting off abruptly.
|
||||
/// </summary>
|
||||
protected virtual bool AffectedBySamplePlaybackDisable => Looping;
|
||||
|
||||
public PausableSkinnableSound()
|
||||
{
|
||||
}
|
||||
@ -51,24 +43,28 @@ namespace osu.Game.Skinning
|
||||
if (samplePlaybackDisabler != null)
|
||||
{
|
||||
samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
|
||||
samplePlaybackDisabled.BindValueChanged(disabled =>
|
||||
samplePlaybackDisabled.BindValueChanged(SamplePlaybackDisabledChanged);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void SamplePlaybackDisabledChanged(ValueChangedEvent<bool> disabled)
|
||||
{
|
||||
if (!RequestedPlaying) return;
|
||||
|
||||
// let non-looping samples that have already been started play out to completion (sounds better than abruptly cutting off).
|
||||
if (!Looping) return;
|
||||
|
||||
cancelPendingStart();
|
||||
|
||||
if (disabled.NewValue)
|
||||
base.Stop();
|
||||
else
|
||||
{
|
||||
// schedule so we don't start playing a sample which is no longer alive.
|
||||
scheduledStart = Schedule(() =>
|
||||
{
|
||||
if (!RequestedPlaying) return;
|
||||
if (!AffectedBySamplePlaybackDisable) return;
|
||||
|
||||
cancelPendingStart();
|
||||
|
||||
if (disabled.NewValue)
|
||||
base.Stop();
|
||||
else
|
||||
{
|
||||
// schedule so we don't start playing a sample which is no longer alive.
|
||||
scheduledStart = Schedule(() =>
|
||||
{
|
||||
if (RequestedPlaying)
|
||||
base.Play();
|
||||
});
|
||||
}
|
||||
if (RequestedPlaying)
|
||||
base.Play();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -21,12 +21,6 @@ namespace osu.Game.Storyboards.Drawables
|
||||
|
||||
public override bool RemoveWhenNotAlive => false;
|
||||
|
||||
/// <remarks>
|
||||
/// Contrary to <see cref="PausableSkinnableSound"/>, all <see cref="DrawableStoryboardSample"/>s are affected
|
||||
/// by sample disables, as they are oftentimes longer-running sound effects. This also matches stable behaviour.
|
||||
/// </remarks>
|
||||
protected override bool AffectedBySamplePlaybackDisable => true;
|
||||
|
||||
public DrawableStoryboardSample(StoryboardSampleInfo sampleInfo)
|
||||
: base(sampleInfo)
|
||||
{
|
||||
@ -48,6 +42,14 @@ namespace osu.Game.Storyboards.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SamplePlaybackDisabledChanged(ValueChangedEvent<bool> disabled)
|
||||
{
|
||||
if (!RequestedPlaying) return;
|
||||
|
||||
if (disabled.NewValue)
|
||||
Stop();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
Loading…
Reference in New Issue
Block a user