mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Add support for 'disabled' sample variation to HoverClickSounds
This commit is contained in:
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Utils;
|
||||
@ -21,6 +22,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
public class HoverClickSounds : HoverSounds
|
||||
{
|
||||
private Sample sampleClick;
|
||||
private Sample sampleClickDisabled;
|
||||
public Bindable<bool> Enabled = new Bindable<bool>(true);
|
||||
private readonly MouseButton[] buttons;
|
||||
|
||||
/// <summary>
|
||||
@ -41,8 +44,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition))
|
||||
{
|
||||
sampleClick.Frequency.Value = 0.99 + RNG.NextDouble(0.02);
|
||||
sampleClick.Play();
|
||||
var channel = Enabled.Value ? sampleClick?.GetChannel() : sampleClickDisabled?.GetChannel();
|
||||
|
||||
if (channel != null)
|
||||
{
|
||||
channel.Frequency.Value = 0.99 + RNG.NextDouble(0.02);
|
||||
channel.Play();
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnClick(e);
|
||||
@ -53,6 +61,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
sampleClick = audio.Samples.Get($@"UI/{SampleSet.GetDescription()}-select")
|
||||
?? audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select");
|
||||
|
||||
sampleClickDisabled = audio.Samples.Get($@"UI/{SampleSet.GetDescription()}-select-disabled")
|
||||
?? audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select-disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user