1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 00:02:56 +08:00

Refactor HoverSampleDebounceComponent to inherit Component

This commit is contained in:
Joseph Madamba 2023-02-03 00:29:25 -08:00
parent f27bf3ca20
commit 5a76c1ab9c
2 changed files with 17 additions and 9 deletions

View File

@ -5,7 +5,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Configuration; using osu.Game.Configuration;
using osuTK; using osuTK;
@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface
/// <summary> /// <summary>
/// Handles debouncing hover sounds at a global level to ensure the effects are not overwhelming. /// Handles debouncing hover sounds at a global level to ensure the effects are not overwhelming.
/// </summary> /// </summary>
public abstract partial class HoverSampleDebounceComponent : CompositeDrawable public abstract partial class HoverSampleDebounceComponent : Component
{ {
private Bindable<double?> lastPlaybackTime; private Bindable<double?> lastPlaybackTime;

View File

@ -46,7 +46,8 @@ namespace osu.Game.Screens.Select.Carousel
Children = new Drawable[] Children = new Drawable[]
{ {
Content, 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!; private Box box = null!;
public HoverLayer() public HoverLayer()
@ -103,7 +102,7 @@ namespace osu.Game.Screens.Select.Carousel
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, OsuColour colours) private void load(OsuColour colours)
{ {
InternalChild = box = new Box InternalChild = box = new Box
{ {
@ -112,8 +111,6 @@ namespace osu.Game.Screens.Select.Carousel
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}; };
sampleHover = audio.Samples.Get("UI/default-hover");
} }
public bool InsetForBorder public bool InsetForBorder
@ -147,6 +144,17 @@ namespace osu.Game.Screens.Select.Carousel
box.FadeOut(1000, Easing.OutQuint); box.FadeOut(1000, Easing.OutQuint);
base.OnHoverLost(e); 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() public override void PlayHoverSample()
{ {