mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add open/close sounds to menus
This commit is contained in:
@ -1,6 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// 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 osuTK.Graphics;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -13,6 +16,12 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
public class OsuMenu : Menu
|
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)
|
public OsuMenu(Direction direction, bool topLevelMenu = false)
|
||||||
: base(direction, topLevelMenu)
|
: base(direction, topLevelMenu)
|
||||||
{
|
{
|
||||||
@ -22,8 +31,30 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
ItemsContainer.Padding = new MarginPadding(5);
|
ItemsContainer.Padding = new MarginPadding(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint);
|
[BackgroundDependencyLoader]
|
||||||
protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint);
|
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)
|
protected override void UpdateSize(Vector2 newSize)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user