mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:02:57 +08:00
Update stand-alone usage of hover/select sounds in DrawableOsuMenuItem
This commit is contained in:
parent
97bb3de1c9
commit
5887b4a27c
@ -3,7 +3,6 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -23,9 +22,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private const int text_size = 17;
|
||||
private const int transition_length = 80;
|
||||
|
||||
private Sample sampleClick;
|
||||
private Sample sampleHover;
|
||||
|
||||
private TextContainer text;
|
||||
|
||||
public DrawableOsuMenuItem(MenuItem item)
|
||||
@ -36,12 +32,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sampleHover = audio.Samples.Get(@"UI/generic-hover");
|
||||
sampleClick = audio.Samples.Get(@"UI/generic-select");
|
||||
|
||||
BackgroundColour = Color4.Transparent;
|
||||
BackgroundColourHover = Color4Extensions.FromHex(@"172023");
|
||||
|
||||
AddInternal(new HoverClickSounds());
|
||||
|
||||
updateTextColour();
|
||||
|
||||
Item.Action.BindDisabledChanged(_ => updateState(), true);
|
||||
@ -84,7 +79,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
if (IsHovered && !Item.Action.Disabled)
|
||||
{
|
||||
sampleHover.Play();
|
||||
text.BoldText.FadeIn(transition_length, Easing.OutQuint);
|
||||
text.NormalText.FadeOut(transition_length, Easing.OutQuint);
|
||||
}
|
||||
@ -95,12 +89,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
sampleClick.Play();
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
protected sealed override Drawable CreateContent() => text = CreateTextContainer();
|
||||
protected virtual TextContainer CreateTextContainer() => new TextContainer();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user