diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index 884834ebe8..fea33bfa9d 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -42,18 +42,20 @@ namespace osu.Game.Graphics.UserInterface this.buttons = buttons ?? new[] { MouseButton.Left }; } + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + 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"); + } + protected override bool OnClick(ClickEvent e) { if (buttons.Contains(e.Button)) - { - var channel = Enabled.Value ? sampleClick?.GetChannel() : sampleClickDisabled?.GetChannel(); - - if (channel != null) - { - channel.Frequency.Value = 0.99 + RNG.NextDouble(0.02); - channel.Play(); - } - } + PlayClickSample(); return base.OnClick(e); } @@ -66,14 +68,15 @@ namespace osu.Game.Graphics.UserInterface base.PlayHoverSample(); } - [BackgroundDependencyLoader] - private void load(AudioManager audio) + public void PlayClickSample() { - sampleClick = audio.Samples.Get($@"UI/{SampleSet.GetDescription()}-select") - ?? audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select"); + var channel = Enabled.Value ? sampleClick?.GetChannel() : sampleClickDisabled?.GetChannel(); - sampleClickDisabled = audio.Samples.Get($@"UI/{SampleSet.GetDescription()}-select-disabled") - ?? audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select-disabled"); + if (channel != null) + { + channel.Frequency.Value = 0.99 + RNG.NextDouble(0.02); + channel.Play(); + } } } } diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/MatchmakingPoolSelector.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/MatchmakingPoolSelector.cs index 8e4d1e8d2b..3a7f57eb40 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/MatchmakingPoolSelector.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/MatchmakingPoolSelector.cs @@ -27,6 +27,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking public readonly Bindable SelectedPool = new Bindable(); private FillFlowContainer poolFlow = null!; + private HoverClickSounds clickSounds = null!; public MatchmakingPoolSelector() { @@ -36,11 +37,19 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking [BackgroundDependencyLoader] private void load() { - InternalChild = poolFlow = new FillFlowContainer + InternalChildren = new Drawable[] { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(3) + poolFlow = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(3) + }, + clickSounds = new HoverClickSounds(HoverSampleSet.TabSelect) + { + // Click samples are played manually + Alpha = 0 + } }; } @@ -61,6 +70,8 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking if (e.Key != Key.Left && e.Key != Key.Right) return false; + clickSounds.PlayClickSample(); + if (SelectedPool.Value == null) { SelectedPool.Value = AvailablePools.Value[0]; diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/Screens/MatchmakingQueueScreen.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/Screens/MatchmakingQueueScreen.cs index d90943fdb4..a52528bf93 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/Screens/MatchmakingQueueScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/Screens/MatchmakingQueueScreen.cs @@ -458,6 +458,8 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Screens private partial class SelectionButton : ShearedButton, IKeyBindingHandler { + private HoverClickSounds clickSounds = null!; + public SelectionButton(float? width = null, float height = DEFAULT_HEIGHT) : base(width, height) { @@ -471,6 +473,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Screens if (e.Repeat) return true; + clickSounds.PlayClickSample(); Action(); return true; } @@ -478,6 +481,8 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Screens public void OnReleased(KeyBindingReleaseEvent e) { } + + protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => clickSounds = (HoverClickSounds)base.CreateHoverSounds(sampleSet); } } }