mirror of
https://github.com/ppy/osu.git
synced 2025-03-19 09:07:18 +08:00
Add open/close sounds to menus
This commit is contained in:
parent
f1ea830828
commit
3f06ecdd48
@ -1,6 +1,9 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -13,6 +16,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuMenu : Menu
|
||||
{
|
||||
private Sample sampleOpen;
|
||||
private Sample sampleClose;
|
||||
|
||||
// todo: this shouldn't be required after https://github.com/ppy/osu-framework/issues/4519 is fixed.
|
||||
private bool wasOpened;
|
||||
|
||||
public OsuMenu(Direction direction, bool topLevelMenu = false)
|
||||
: base(direction, topLevelMenu)
|
||||
{
|
||||
@ -22,8 +31,30 @@ namespace osu.Game.Graphics.UserInterface
|
||||
ItemsContainer.Padding = new MarginPadding(5);
|
||||
}
|
||||
|
||||
protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint);
|
||||
protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint);
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
|
||||
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
|
||||
}
|
||||
|
||||
protected override void AnimateOpen()
|
||||
{
|
||||
if (!wasOpened)
|
||||
sampleOpen?.Play();
|
||||
|
||||
this.FadeIn(300, Easing.OutQuint);
|
||||
wasOpened = true;
|
||||
}
|
||||
|
||||
protected override void AnimateClose()
|
||||
{
|
||||
if (wasOpened)
|
||||
sampleClose?.Play();
|
||||
|
||||
this.FadeOut(300, Easing.OutQuint);
|
||||
wasOpened = false;
|
||||
}
|
||||
|
||||
protected override void UpdateSize(Vector2 newSize)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user