mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 23:43:03 +08:00
Add more resilient logic for whether to avoid playing SkinnableSound on no volume
This commit is contained in:
parent
c68fb92d00
commit
e3105fd4c8
@ -82,8 +82,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
private SkinnableSound spinningSample;
|
private SkinnableSound spinningSample;
|
||||||
|
|
||||||
private const float minimum_volume = 0.0001f;
|
|
||||||
|
|
||||||
protected override void LoadSamples()
|
protected override void LoadSamples()
|
||||||
{
|
{
|
||||||
base.LoadSamples();
|
base.LoadSamples();
|
||||||
@ -100,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
AddInternal(spinningSample = new SkinnableSound(clone)
|
AddInternal(spinningSample = new SkinnableSound(clone)
|
||||||
{
|
{
|
||||||
Volume = { Value = minimum_volume },
|
Volume = { Value = 0 },
|
||||||
Looping = true,
|
Looping = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -118,7 +116,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spinningSample?.VolumeTo(minimum_volume, 200).Finally(_ => spinningSample.Stop());
|
spinningSample?.VolumeTo(0, 200).Finally(_ => spinningSample.Stop());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,6 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
protected override Action BackAction => () => InternalButtons.Children.First().Click();
|
protected override Action BackAction => () => InternalButtons.Children.First().Click();
|
||||||
|
|
||||||
private const float minimum_volume = 0.0001f;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
@ -37,10 +35,8 @@ namespace osu.Game.Screens.Play
|
|||||||
AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop"))
|
AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop"))
|
||||||
{
|
{
|
||||||
Looping = true,
|
Looping = true,
|
||||||
|
Volume = { Value = 0 }
|
||||||
});
|
});
|
||||||
|
|
||||||
// SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it
|
|
||||||
pauseLoop.VolumeTo(minimum_volume);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
@ -55,7 +51,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.PopOut();
|
base.PopOut();
|
||||||
|
|
||||||
pauseLoop.VolumeTo(minimum_volume, TRANSITION_DURATION, Easing.OutQuad).Finally(_ => pauseLoop.Stop());
|
pauseLoop.VolumeTo(0, TRANSITION_DURATION, Easing.OutQuad).Finally(_ => pauseLoop.Stop());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,16 @@ namespace osu.Game.Skinning
|
|||||||
public override bool RemoveWhenNotAlive => false;
|
public override bool RemoveWhenNotAlive => false;
|
||||||
public override bool RemoveCompletedTransforms => false;
|
public override bool RemoveCompletedTransforms => false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to play the underlying sample when aggregate volume is zero.
|
||||||
|
/// Note that this is checked at the point of calling <see cref="Play"/>; changing the volume post-play will not begin playback.
|
||||||
|
/// Defaults to false unless <see cref="Looping"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Can serve as an optimisation if it is known ahead-of-time that this behaviour will not negatively affect behaviour.
|
||||||
|
/// </remarks>
|
||||||
|
protected bool SkipPlayWhenZeroVolume => !Looping;
|
||||||
|
|
||||||
private readonly AudioContainer<DrawableSample> samplesContainer;
|
private readonly AudioContainer<DrawableSample> samplesContainer;
|
||||||
|
|
||||||
public SkinnableSound(ISampleInfo hitSamples)
|
public SkinnableSound(ISampleInfo hitSamples)
|
||||||
@ -87,7 +97,7 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
samplesContainer.ForEach(c =>
|
samplesContainer.ForEach(c =>
|
||||||
{
|
{
|
||||||
if (c.AggregateVolume.Value > 0)
|
if (!SkipPlayWhenZeroVolume || c.AggregateVolume.Value > 0)
|
||||||
c.Play();
|
c.Play();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user