1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:42:55 +08:00

Fix pause loop sound not working because paused

This commit is contained in:
Dean Herbert 2020-09-29 14:20:41 +09:00
parent c5f6b77bba
commit 74e74e1c31
2 changed files with 15 additions and 3 deletions

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Play
AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke()); AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop")) AddInternal(pauseLoop = new UnpausableSkinnableSound(new SampleInfo("pause-loop"))
{ {
Looping = true, Looping = true,
Volume = { Value = 0 } Volume = { Value = 0 }
@ -54,5 +54,15 @@ namespace osu.Game.Screens.Play
pauseLoop.VolumeTo(0, TRANSITION_DURATION, Easing.OutQuad).Finally(_ => pauseLoop.Stop()); pauseLoop.VolumeTo(0, TRANSITION_DURATION, Easing.OutQuad).Finally(_ => pauseLoop.Stop());
} }
private class UnpausableSkinnableSound : SkinnableSound
{
protected override bool PlayWhenPaused => true;
public UnpausableSkinnableSound(SampleInfo sampleInfo)
: base(sampleInfo)
{
}
}
} }
} }

View File

@ -37,6 +37,8 @@ namespace osu.Game.Skinning
/// </remarks> /// </remarks>
protected bool PlayWhenZeroVolume => Looping; protected bool PlayWhenZeroVolume => Looping;
protected virtual bool PlayWhenPaused => false;
private readonly AudioContainer<DrawableSample> samplesContainer; private readonly AudioContainer<DrawableSample> samplesContainer;
public SkinnableSound(ISampleInfo hitSamples) public SkinnableSound(ISampleInfo hitSamples)
@ -63,7 +65,7 @@ namespace osu.Game.Skinning
{ {
if (requestedPlaying) if (requestedPlaying)
{ {
if (disabled.NewValue) if (disabled.NewValue && !PlayWhenPaused)
stop(); stop();
// it's not easy to know if a sample has finished playing (to end). // it's not easy to know if a sample has finished playing (to end).
// to keep things simple only resume playing looping samples. // to keep things simple only resume playing looping samples.
@ -97,7 +99,7 @@ namespace osu.Game.Skinning
private void play() private void play()
{ {
if (samplePlaybackDisabled.Value) if (samplePlaybackDisabled.Value && !PlayWhenPaused)
return; return;
samplesContainer.ForEach(c => samplesContainer.ForEach(c =>