From 6135db6bd720eaa92be7204a6dc57dc138100c89 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 2 Feb 2023 23:43:08 -0800 Subject: [PATCH 1/5] Revert moving hover sounds to content container --- osu.Game/Graphics/Containers/OsuClickableContainer.cs | 7 +++++-- osu.Game/Graphics/UserInterface/OsuButton.cs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuClickableContainer.cs b/osu.Game/Graphics/Containers/OsuClickableContainer.cs index ce50dbdc39..6fe1de2216 100644 --- a/osu.Game/Graphics/Containers/OsuClickableContainer.cs +++ b/osu.Game/Graphics/Containers/OsuClickableContainer.cs @@ -44,8 +44,11 @@ namespace osu.Game.Graphics.Containers content.AutoSizeAxes = AutoSizeAxes; } - AddInternal(content); - Add(CreateHoverSounds(sampleSet)); + AddRangeInternal(new Drawable[] + { + content, + CreateHoverSounds(sampleSet) + }); } protected override void ClearInternal(bool disposeChildren = true) => diff --git a/osu.Game/Graphics/UserInterface/OsuButton.cs b/osu.Game/Graphics/UserInterface/OsuButton.cs index 805dfcaa95..6467ae5783 100644 --- a/osu.Game/Graphics/UserInterface/OsuButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuButton.cs @@ -116,7 +116,7 @@ namespace osu.Game.Graphics.UserInterface }); if (hoverSounds.HasValue) - Add(new HoverClickSounds(hoverSounds.Value) { Enabled = { BindTarget = Enabled } }); + AddInternal(new HoverClickSounds(hoverSounds.Value) { Enabled = { BindTarget = Enabled } }); } [BackgroundDependencyLoader] From 77569058cb415970e2fba96c3b174c3dbdcdfbae Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 2 Feb 2023 23:45:54 -0800 Subject: [PATCH 2/5] Alternatively fix hover sounds playing out of clicking bounds --- .../Graphics/UserInterface/HoverSampleDebounceComponent.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs b/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs index 53f1c06a67..959b0c6bd4 100644 --- a/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs +++ b/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs @@ -8,6 +8,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Game.Configuration; +using osuTK; namespace osu.Game.Graphics.UserInterface { @@ -18,6 +19,8 @@ namespace osu.Game.Graphics.UserInterface { private Bindable lastPlaybackTime; + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false; + [BackgroundDependencyLoader] private void load(SessionStatics statics) { From f27bf3ca20d7cf1a8b8d11326e33108795da0f34 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 2 Feb 2023 23:54:57 -0800 Subject: [PATCH 3/5] Fix click sounds potentially not working --- osu.Game/Graphics/UserInterface/HoverClickSounds.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index ed1838abd0..884834ebe8 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -44,7 +44,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnClick(ClickEvent e) { - if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition)) + if (buttons.Contains(e.Button)) { var channel = Enabled.Value ? sampleClick?.GetChannel() : sampleClickDisabled?.GetChannel(); From 5a76c1ab9c0278bf4323fb222b906de901d874b1 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 3 Feb 2023 00:29:25 -0800 Subject: [PATCH 4/5] Refactor `HoverSampleDebounceComponent` to inherit `Component` --- .../HoverSampleDebounceComponent.cs | 4 ++-- .../Screens/Select/Carousel/CarouselHeader.cs | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs b/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs index 959b0c6bd4..81f146b9ce 100644 --- a/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs +++ b/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs @@ -5,7 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; using osu.Framework.Input.Events; using osu.Game.Configuration; using osuTK; @@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface /// /// Handles debouncing hover sounds at a global level to ensure the effects are not overwhelming. /// - public abstract partial class HoverSampleDebounceComponent : CompositeDrawable + public abstract partial class HoverSampleDebounceComponent : Component { private Bindable lastPlaybackTime; diff --git a/osu.Game/Screens/Select/Carousel/CarouselHeader.cs b/osu.Game/Screens/Select/Carousel/CarouselHeader.cs index e46f0da45d..7e668fcd87 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselHeader.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselHeader.cs @@ -46,7 +46,8 @@ namespace osu.Game.Screens.Select.Carousel Children = new Drawable[] { Content, - hoverLayer = new HoverLayer() + hoverLayer = new HoverLayer(), + new HeaderSounds(), } }; } @@ -91,10 +92,8 @@ namespace osu.Game.Screens.Select.Carousel } } - public partial class HoverLayer : HoverSampleDebounceComponent + public partial class HoverLayer : CompositeDrawable { - private Sample? sampleHover; - private Box box = null!; public HoverLayer() @@ -103,7 +102,7 @@ namespace osu.Game.Screens.Select.Carousel } [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) + private void load(OsuColour colours) { InternalChild = box = new Box { @@ -112,8 +111,6 @@ namespace osu.Game.Screens.Select.Carousel Blending = BlendingParameters.Additive, RelativeSizeAxes = Axes.Both, }; - - sampleHover = audio.Samples.Get("UI/default-hover"); } public bool InsetForBorder @@ -147,6 +144,17 @@ namespace osu.Game.Screens.Select.Carousel box.FadeOut(1000, Easing.OutQuint); base.OnHoverLost(e); } + } + + private partial class HeaderSounds : HoverSampleDebounceComponent + { + private Sample? sampleHover; + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + sampleHover = audio.Samples.Get("UI/default-hover"); + } public override void PlayHoverSample() { From 191259c05029ce5b37e4157f2bbbf3dad16214c7 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 4 Feb 2023 19:58:48 -0800 Subject: [PATCH 5/5] Use equals instead and update other usage --- osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs | 2 +- osu.Game/Rulesets/Edit/PlacementBlueprint.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs b/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs index 81f146b9ce..fee81e0e22 100644 --- a/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs +++ b/osu.Game/Graphics/UserInterface/HoverSampleDebounceComponent.cs @@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface { private Bindable lastPlaybackTime; - public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false; + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) == true; [BackgroundDependencyLoader] private void load(SessionStatics statics) diff --git a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs index dd8dd93d66..f810f51027 100644 --- a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs +++ b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs @@ -121,7 +121,7 @@ namespace osu.Game.Rulesets.Edit /// protected void ApplyDefaultsToHitObject() => HitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.Difficulty); - public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false; + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) == true; protected override bool Handle(UIEvent e) {