1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Merge pull request #24576 from nekodex/new-overlay-sfx

Update overlay pop-in/pop-out sample usage
This commit is contained in:
Dean Herbert 2023-08-25 01:47:55 +09:00 committed by GitHub
commit 1efd557b96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 89 additions and 13 deletions

View File

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

View File

@ -24,6 +24,7 @@ namespace osu.Game.Graphics.Containers
private Sample samplePopOut;
protected virtual string PopInSampleName => "UI/overlay-pop-in";
protected virtual string PopOutSampleName => "UI/overlay-pop-out";
protected virtual double PopInOutSampleBalance => 0;
protected override bool BlockNonPositionalInput => true;
@ -133,15 +134,21 @@ namespace osu.Game.Graphics.Containers
return;
}
if (didChange)
samplePopIn?.Play();
if (didChange && samplePopIn != null)
{
samplePopIn.Balance.Value = PopInOutSampleBalance;
samplePopIn.Play();
}
if (BlockScreenWideMouse && DimMainContent) overlayManager?.ShowBlockingOverlay(this);
break;
case Visibility.Hidden:
if (didChange)
samplePopOut?.Play();
if (didChange && samplePopOut != null)
{
samplePopOut.Balance.Value = PopInOutSampleBalance;
samplePopOut.Play();
}
if (BlockScreenWideMouse) overlayManager?.HideBlockingOverlay(this);
break;

View File

@ -2,6 +2,9 @@
// See the LICENCE file in the repository root for full licence text.
using System;
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;
@ -32,6 +35,12 @@ namespace osu.Game.Graphics.Containers
protected override bool StartHidden => true;
private Sample? samplePopIn;
private Sample? samplePopOut;
// required due to LoadAsyncComplete() in `VisibilityContainer` calling PopOut() during load - similar workaround to `OsuDropdownMenu`
private bool wasShown;
public Color4 FirstWaveColour
{
get => firstWave.Colour;
@ -56,6 +65,13 @@ namespace osu.Game.Graphics.Containers
set => fourthWave.Colour = value;
}
[BackgroundDependencyLoader(true)]
private void load(AudioManager audio)
{
samplePopIn = audio.Samples.Get("UI/wave-pop-in");
samplePopOut = audio.Samples.Get("UI/overlay-big-pop-out");
}
public WaveContainer()
{
Masking = true;
@ -110,6 +126,8 @@ namespace osu.Game.Graphics.Containers
w.Show();
contentContainer.MoveToY(0, APPEAR_DURATION, Easing.OutQuint);
samplePopIn?.Play();
wasShown = true;
}
protected override void PopOut()
@ -118,6 +136,9 @@ namespace osu.Game.Graphics.Containers
w.Hide();
contentContainer.MoveToY(2, DISAPPEAR_DURATION, Easing.In);
if (wasShown)
samplePopOut?.Play();
}
protected override void UpdateAfterChildren()

View File

@ -46,8 +46,8 @@ namespace osu.Game.Graphics.UserInterface
private readonly Container content;
private readonly Box hover;
public OsuAnimatedButton()
: base(HoverSampleSet.Button)
public OsuAnimatedButton(HoverSampleSet sampleSet = HoverSampleSet.Button)
: base(sampleSet)
{
base.Content.Add(content = new Container
{

View File

@ -14,6 +14,12 @@ namespace osu.Game.Graphics.UserInterface
private Sample? sampleOff;
private Sample? sampleOn;
/// <summary>
/// Sheared toggle buttons by default play two samples when toggled: a click and a toggle (on/off).
/// Sometimes this might be too much. Setting this to <c>false</c> will silence the toggle sound.
/// </summary>
protected virtual bool PlayToggleSamples => true;
/// <summary>
/// Whether this button is currently toggled to an active state.
/// </summary>
@ -68,10 +74,13 @@ namespace osu.Game.Graphics.UserInterface
{
sampleClick?.Play();
if (Active.Value)
sampleOn?.Play();
else
sampleOff?.Play();
if (PlayToggleSamples)
{
if (Active.Value)
sampleOn?.Play();
else
sampleOff?.Play();
}
}
}
}

View File

@ -2,6 +2,8 @@
// 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 osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -21,6 +23,14 @@ namespace osu.Game.Graphics.UserInterfaceV2
private const float fade_duration = 250;
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() in `VisibilityContainer` calling PopOut() during load - similar workaround to `OsuDropdownMenu`
private bool wasOpened;
public OsuPopover(bool withPadding = true)
{
Content.Padding = withPadding ? new MarginPadding(20) : new MarginPadding();
@ -38,9 +48,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
}
[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;
samplePopIn = audio.Samples.Get(PopInSampleName);
samplePopOut = audio.Samples.Get(PopOutSampleName);
}
protected override Drawable CreateArrow() => Empty();
@ -49,12 +61,18 @@ namespace osu.Game.Graphics.UserInterfaceV2
{
this.ScaleTo(1, scale_duration, Easing.OutElasticHalf);
this.FadeIn(fade_duration, Easing.OutQuint);
samplePopIn?.Play();
wasOpened = true;
}
protected override void PopOut()
{
this.ScaleTo(0.7f, scale_duration, Easing.OutQuint);
this.FadeOut(fade_duration, Easing.OutQuint);
if (wasOpened)
samplePopOut?.Play();
}
protected override bool OnKeyDown(KeyDownEvent e)

View File

@ -55,6 +55,9 @@ namespace osu.Game.Overlays
private const float side_bar_width = 190;
private const float chat_bar_height = 60;
protected override string PopInSampleName => @"UI/overlay-big-pop-in";
protected override string PopOutSampleName => @"UI/overlay-big-pop-out";
[Resolved]
private OsuConfigManager config { get; set; } = null!;

View File

@ -20,6 +20,8 @@ namespace osu.Game.Overlays
private const float transition_time = 400;
protected override double PopInOutSampleBalance => OsuGameBase.SFX_STEREO_STRENGTH;
[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);

View File

@ -18,6 +18,8 @@ namespace osu.Game.Overlays.Mods
{
public partial class AddPresetButton : ShearedToggleButton, IHasPopover
{
protected override bool PlayToggleSamples => false;
[Resolved]
private OsuColour colours { get; set; } = null!;

View File

@ -31,6 +31,8 @@ namespace osu.Game.Overlays
public LocalisableString Title => NotificationsStrings.HeaderTitle;
public LocalisableString Description => NotificationsStrings.HeaderDescription;
protected override double PopInOutSampleBalance => OsuGameBase.SFX_STEREO_STRENGTH;
public const float WIDTH = 320;
public const float TRANSITION_LENGTH = 600;

View File

@ -56,6 +56,7 @@ namespace osu.Game.Overlays
private SeekLimitedSearchTextBox searchTextBox;
protected override string PopInSampleName => "UI/settings-pop-in";
protected override double PopInOutSampleBalance => -OsuGameBase.SFX_STEREO_STRENGTH;
private readonly bool showSidebar;

View File

@ -18,7 +18,9 @@ namespace osu.Game.Overlays
protected override bool StartHidden => true;
protected override string PopInSampleName => "UI/wave-pop-in";
// `WaveContainer` plays PopIn/PopOut samples, so we disable the overlay-level one as to not double-up sample playback.
protected override string PopInSampleName => string.Empty;
protected override string PopOutSampleName => string.Empty;
public const float HORIZONTAL_PADDING = 50;

View File

@ -262,6 +262,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
private readonly OsuSpriteText divisorText;
public DivisorDisplay()
: base(HoverSampleSet.Default)
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;

View File

@ -114,6 +114,9 @@ namespace osu.Game.Screens.Edit.Setup
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)
{
Child = new Container

View File

@ -170,7 +170,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
if (Room.HasPassword.Value)
{
sampleJoin?.Play();
this.ShowPopover();
return true;
}

View File

@ -32,6 +32,9 @@ namespace osu.Game.Screens.Select.Options
public override bool BlockScreenWideMouse => false;
protected override string PopInSampleName => "SongSelect/options-pop-in";
protected override string PopOutSampleName => "SongSelect/options-pop-out";
public BeatmapOptionsOverlay()
{
AutoSizeAxes = Axes.Y;