1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 14:23:02 +08:00

add sound to dropdowns

This commit is contained in:
Jamie Taylor 2021-06-18 18:57:40 +09:00
parent 4feb7c848f
commit d462394635
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C
2 changed files with 25 additions and 7 deletions

View File

@ -13,9 +13,6 @@ namespace osu.Game.Graphics.UserInterface
[Description("button")]
Button,
[Description("softer")]
Soft,
[Description("toolbar")]
Toolbar,

View File

@ -4,6 +4,8 @@
using System.Linq;
using osuTK.Graphics;
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;
@ -57,6 +59,9 @@ namespace osu.Game.Graphics.UserInterface
{
public override bool HandleNonPositionalInput => State == MenuState.Open;
private Sample sampleOpen;
private Sample sampleClose;
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
public OsuDropdownMenu()
{
@ -69,9 +74,25 @@ namespace osu.Game.Graphics.UserInterface
ItemsContainer.Padding = new MarginPadding(5);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
}
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint);
protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint);
protected override void AnimateOpen()
{
this.FadeIn(300, Easing.OutQuint);
sampleOpen?.Play();
}
protected override void AnimateClose()
{
this.FadeOut(300, Easing.OutQuint);
sampleClose?.Play();
}
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
protected override void UpdateSize(Vector2 newSize)
@ -155,7 +176,7 @@ namespace osu.Game.Graphics.UserInterface
nonAccentSelectedColour = Color4.Black.Opacity(0.5f);
updateColours();
AddInternal(new HoverClickSounds(HoverSampleSet.Soft));
AddInternal(new HoverSounds());
}
protected override void UpdateForegroundColour()
@ -262,7 +283,7 @@ namespace osu.Game.Graphics.UserInterface
},
};
AddInternal(new HoverClickSounds());
AddInternal(new HoverSounds());
}
[BackgroundDependencyLoader]