mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Simplify sound debounce logic
This commit is contained in:
parent
daf7ab9422
commit
4bfe3aabdc
@ -496,17 +496,12 @@ namespace osu.Game.Overlays.Mods
|
||||
MultiplierLabel.FadeColour(Color4.White, 200);
|
||||
}
|
||||
|
||||
private ScheduledDelegate sampleOnDelegate;
|
||||
private ScheduledDelegate sampleOffDelegate;
|
||||
|
||||
private void modButtonPressed(Mod selectedMod)
|
||||
{
|
||||
if (selectedMod != null)
|
||||
{
|
||||
// Fixes buzzing when multiple mods are selected in the same frame.
|
||||
sampleOnDelegate?.Cancel();
|
||||
if (State.Value == Visibility.Visible)
|
||||
sampleOnDelegate = Scheduler.Add(() => sampleOn?.Play());
|
||||
Scheduler.AddOnce(playSelectedSound);
|
||||
|
||||
OnModSelected(selectedMod);
|
||||
|
||||
@ -514,15 +509,16 @@ namespace osu.Game.Overlays.Mods
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fixes buzzing when multiple mods are deselected in the same frame.
|
||||
sampleOffDelegate?.Cancel();
|
||||
if (State.Value == Visibility.Visible)
|
||||
sampleOffDelegate = Scheduler.Add(() => sampleOff?.Play());
|
||||
Scheduler.AddOnce(playDeselectedSound);
|
||||
}
|
||||
|
||||
refreshSelectedMods();
|
||||
}
|
||||
|
||||
private void playSelectedSound() => sampleOn?.Play();
|
||||
private void playDeselectedSound() => sampleOff?.Play();
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a new <see cref="Mod"/> has been selected.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user