1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:57:24 +08:00

Add pop-in/pop-out sfx to more overlays

This commit is contained in:
Jamie Taylor 2023-08-17 17:03:45 +09:00
parent 04a1f6a508
commit 3d7ba0e18c
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C
4 changed files with 32 additions and 1 deletions

View File

@ -23,6 +23,9 @@ namespace osu.Game.Collections
private AudioFilter lowPassFilter = null!; private AudioFilter lowPassFilter = null!;
protected override string PopInSampleName => @"UI/overlay-big-pop-in";
protected override string PopOutSampleName => @"UI/overlay-big-pop-out";
public ManageCollectionsDialog() public ManageCollectionsDialog()
{ {
Anchor = Anchor.Centre; Anchor = Anchor.Centre;

View File

@ -2,6 +2,8 @@
// 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.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -21,6 +23,16 @@ namespace osu.Game.Graphics.UserInterfaceV2
private const float fade_duration = 250; private const float fade_duration = 250;
private const double scale_duration = 500; private const double scale_duration = 500;
private Sample? samplePopIn;
private Sample? samplePopOut;
protected virtual string PopInSampleName => "UI/overlay-pop-in";
protected virtual string PopOutSampleName => "UI/overlay-pop-out";
// required due to LoadAsyncComplete() calling PopOut() during load - similar workaround to `OsuDropdownMenu`
private bool wasOpened;
protected virtual bool PlayPopInOutSamples => true;
public OsuPopover(bool withPadding = true) public OsuPopover(bool withPadding = true)
{ {
Content.Padding = withPadding ? new MarginPadding(20) : new MarginPadding(); Content.Padding = withPadding ? new MarginPadding(20) : new MarginPadding();
@ -38,9 +50,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(OverlayColourProvider? colourProvider, OsuColour colours) private void load(OverlayColourProvider? colourProvider, OsuColour colours, AudioManager audio)
{ {
Background.Colour = Arrow.Colour = colourProvider?.Background4 ?? colours.GreySeaFoamDarker; Background.Colour = Arrow.Colour = colourProvider?.Background4 ?? colours.GreySeaFoamDarker;
samplePopIn = audio.Samples.Get(PopInSampleName);
samplePopOut = audio.Samples.Get(PopOutSampleName);
} }
protected override Drawable CreateArrow() => Empty(); protected override Drawable CreateArrow() => Empty();
@ -49,12 +63,21 @@ namespace osu.Game.Graphics.UserInterfaceV2
{ {
this.ScaleTo(1, scale_duration, Easing.OutElasticHalf); this.ScaleTo(1, scale_duration, Easing.OutElasticHalf);
this.FadeIn(fade_duration, Easing.OutQuint); this.FadeIn(fade_duration, Easing.OutQuint);
if (PlayPopInOutSamples)
{
samplePopIn?.Play();
wasOpened = true;
}
} }
protected override void PopOut() protected override void PopOut()
{ {
this.ScaleTo(0.7f, scale_duration, Easing.OutQuint); this.ScaleTo(0.7f, scale_duration, Easing.OutQuint);
this.FadeOut(fade_duration, Easing.OutQuint); this.FadeOut(fade_duration, Easing.OutQuint);
if (wasOpened && PlayPopInOutSamples)
samplePopOut?.Play();
} }
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)

View File

@ -114,6 +114,9 @@ namespace osu.Game.Screens.Edit.Setup
private partial class FileChooserPopover : OsuPopover private partial class FileChooserPopover : OsuPopover
{ {
protected override string PopInSampleName => "UI/overlay-big-pop-in";
protected override string PopOutSampleName => "UI/overlay-big-pop-out";
public FileChooserPopover(string[] handledExtensions, Bindable<FileInfo?> currentFile, string? chooserPath) public FileChooserPopover(string[] handledExtensions, Bindable<FileInfo?> currentFile, string? chooserPath)
{ {
Child = new Container Child = new Container

View File

@ -191,6 +191,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
protected override bool BlockNonPositionalInput => true; protected override bool BlockNonPositionalInput => true;
protected override bool PlayPopInOutSamples => false;
public PasswordEntryPopover(Room room) public PasswordEntryPopover(Room room)
{ {
this.room = room; this.room = room;