mirror of
https://github.com/ppy/osu
synced 2024-12-25 16:22:23 +00:00
Merge pull request #22505 from Joehuu/fix-hover-click-sounds
Fix some clickable elements having no hover and click sounds
This commit is contained in:
commit
ddcc02fdfe
@ -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) =>
|
||||
|
@ -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();
|
||||
|
||||
|
@ -5,19 +5,22 @@
|
||||
|
||||
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;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles debouncing hover sounds at a global level to ensure the effects are not overwhelming.
|
||||
/// </summary>
|
||||
public abstract partial class HoverSampleDebounceComponent : CompositeDrawable
|
||||
public abstract partial class HoverSampleDebounceComponent : Component
|
||||
{
|
||||
private Bindable<double?> lastPlaybackTime;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) == true;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(SessionStatics statics)
|
||||
{
|
||||
|
@ -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]
|
||||
|
@ -121,7 +121,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user