From 7ef5a71e91a56a3e8340393376a97973ceb3e266 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Thu, 24 Aug 2023 18:13:23 +0900 Subject: [PATCH] Move PopIn/PopOut sample playback from `WaveOverlayContainer` to `WaveContainer` (so Multiplayer/Lounge plays the samples) --- osu.Game/Graphics/Containers/WaveContainer.cs | 22 +++++++++++++++++++ osu.Game/Overlays/WaveOverlayContainer.cs | 5 +++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/WaveContainer.cs b/osu.Game/Graphics/Containers/WaveContainer.cs index 9fd3d103c9..0b1d44ccba 100644 --- a/osu.Game/Graphics/Containers/WaveContainer.cs +++ b/osu.Game/Graphics/Containers/WaveContainer.cs @@ -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,13 @@ namespace osu.Game.Graphics.Containers protected override bool StartHidden => true; + private Sample? samplePopIn; + private Sample? samplePopOut; + protected virtual string PopInSampleName => "UI/wave-pop-in"; + protected virtual string PopOutSampleName => "UI/overlay-big-pop-out"; + + private bool wasShown = false; + public Color4 FirstWaveColour { get => firstWave.Colour; @@ -56,6 +66,13 @@ namespace osu.Game.Graphics.Containers set => fourthWave.Colour = value; } + [BackgroundDependencyLoader(true)] + private void load(AudioManager audio) + { + samplePopIn = audio.Samples.Get(PopInSampleName); + samplePopOut = audio.Samples.Get(PopOutSampleName); + } + public WaveContainer() { Masking = true; @@ -110,6 +127,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 +137,9 @@ namespace osu.Game.Graphics.Containers w.Hide(); contentContainer.MoveToY(2, DISAPPEAR_DURATION, Easing.In); + + if (wasShown) + samplePopOut?.Play(); } protected override void UpdateAfterChildren() diff --git a/osu.Game/Overlays/WaveOverlayContainer.cs b/osu.Game/Overlays/WaveOverlayContainer.cs index 848d9e60b7..b0ddef5c2b 100644 --- a/osu.Game/Overlays/WaveOverlayContainer.cs +++ b/osu.Game/Overlays/WaveOverlayContainer.cs @@ -18,8 +18,9 @@ namespace osu.Game.Overlays protected override bool StartHidden => true; - protected override string PopInSampleName => "UI/wave-pop-in"; - protected override string PopOutSampleName => "UI/overlay-big-pop-out"; + // `WaveContainer` plays PopIn/PopOut samples, so we disable the overlay-level one as to not double-up sample playback. + protected override string PopInSampleName => ""; + protected override string PopOutSampleName => ""; public const float HORIZONTAL_PADDING = 50;