From 2feaf2c74a9e6ccdff263a597157abf483180229 Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Fri, 12 Jun 2020 19:17:52 +0200 Subject: [PATCH 01/21] added music during pause --- osu.Game/Screens/Play/Player.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 83991ad027..e37cf9a348 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -78,6 +78,8 @@ namespace osu.Game.Screens.Play private IAPIProvider api { get; set; } private SampleChannel sampleRestart; + + private SampleChannel samplePause; public BreakOverlay BreakOverlay; @@ -161,6 +163,9 @@ namespace osu.Game.Screens.Play return; sampleRestart = audio.Samples.Get(@"Gameplay/restart"); + + samplePause = audio.Samples.Get(@"Gameplay/pause-loop"); + samplePause.Looping = true; mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); @@ -407,7 +412,11 @@ namespace osu.Game.Screens.Play if (canPause) Pause(); else + { + samplePause?.Stop(); + Logger.LogPrint(@"_______sample stopped in performUserRequestedExit"); this.Exit(); + } } /// @@ -416,6 +425,8 @@ namespace osu.Game.Screens.Play /// public void Restart() { + Logger.LogPrint(@"_______sample stopped in Restart"); + samplePause?.Stop(); sampleRestart?.Play(); RestartRequested?.Invoke(); @@ -564,6 +575,8 @@ namespace osu.Game.Screens.Play GameplayClockContainer.Stop(); PauseOverlay.Show(); lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime; + + samplePause?.Play(); } public void Resume() @@ -583,6 +596,8 @@ namespace osu.Game.Screens.Play { GameplayClockContainer.Start(); IsResuming = false; + Logger.LogPrint(@"_______sample stopped in Resume"); + samplePause?.Stop(); } } From 6fd8548f79a772d90b08cefd4e508d32d92d3c5f Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Sat, 13 Jun 2020 10:13:41 +0200 Subject: [PATCH 02/21] no longer crash if the restart sample isn't found --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index e37cf9a348..4025bbd442 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -165,7 +165,7 @@ namespace osu.Game.Screens.Play sampleRestart = audio.Samples.Get(@"Gameplay/restart"); samplePause = audio.Samples.Get(@"Gameplay/pause-loop"); - samplePause.Looping = true; + if(samplePause != null) { samplePause.Looping = true; } mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); From 8b8f2dfda2ebfad979ce7fa148d824a80db7b418 Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Sat, 13 Jun 2020 10:31:54 +0200 Subject: [PATCH 03/21] Removed duplicate samplepause.stop() calls, removed test lines Since restart() always call perform immediate exit when the function lead to a restart, there is no need to stop the pause sample in restart --- osu.Game/Screens/Play/Player.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 4025bbd442..f9e18db581 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -414,7 +414,6 @@ namespace osu.Game.Screens.Play else { samplePause?.Stop(); - Logger.LogPrint(@"_______sample stopped in performUserRequestedExit"); this.Exit(); } } @@ -425,8 +424,6 @@ namespace osu.Game.Screens.Play /// public void Restart() { - Logger.LogPrint(@"_______sample stopped in Restart"); - samplePause?.Stop(); sampleRestart?.Play(); RestartRequested?.Invoke(); @@ -596,7 +593,7 @@ namespace osu.Game.Screens.Play { GameplayClockContainer.Start(); IsResuming = false; - Logger.LogPrint(@"_______sample stopped in Resume"); + samplePause?.Stop(); } } From 794b8673e21b7ccc60e7bac938426c48e3a6abc9 Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Sat, 13 Jun 2020 10:56:02 +0200 Subject: [PATCH 04/21] formated using dotnet format --- osu.Game/Screens/Play/Player.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index f9e18db581..ce7bb60048 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -78,7 +78,7 @@ namespace osu.Game.Screens.Play private IAPIProvider api { get; set; } private SampleChannel sampleRestart; - + private SampleChannel samplePause; public BreakOverlay BreakOverlay; @@ -163,9 +163,9 @@ namespace osu.Game.Screens.Play return; sampleRestart = audio.Samples.Get(@"Gameplay/restart"); - + samplePause = audio.Samples.Get(@"Gameplay/pause-loop"); - if(samplePause != null) { samplePause.Looping = true; } + if (samplePause != null) { samplePause.Looping = true; } mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); From 04c1efe298681c82da4b2342b9d0bb78e432d2ff Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Sat, 13 Jun 2020 14:33:55 +0200 Subject: [PATCH 05/21] resolved issues with inspect code script --- osu.Game/Screens/Play/Player.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ce7bb60048..d5e9c54e04 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -165,7 +165,8 @@ namespace osu.Game.Screens.Play sampleRestart = audio.Samples.Get(@"Gameplay/restart"); samplePause = audio.Samples.Get(@"Gameplay/pause-loop"); - if (samplePause != null) { samplePause.Looping = true; } + if (samplePause != null) + samplePause.Looping = true; mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); From a4eb6c81c5a90b15d298fe705cc0699c98da1772 Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Mon, 22 Jun 2020 13:40:31 +0200 Subject: [PATCH 06/21] undid changes to the file --- osu.Game/Screens/Play/Player.cs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index d5e9c54e04..b6d87e658b 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -5,11 +5,13 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Humanizer; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Graphics.Audio; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Framework.Logging; @@ -78,9 +80,7 @@ namespace osu.Game.Screens.Play private IAPIProvider api { get; set; } private SampleChannel sampleRestart; - - private SampleChannel samplePause; - + public BreakOverlay BreakOverlay; private BreakTracker breakTracker; @@ -164,10 +164,6 @@ namespace osu.Game.Screens.Play sampleRestart = audio.Samples.Get(@"Gameplay/restart"); - samplePause = audio.Samples.Get(@"Gameplay/pause-loop"); - if (samplePause != null) - samplePause.Looping = true; - mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value); @@ -414,7 +410,6 @@ namespace osu.Game.Screens.Play Pause(); else { - samplePause?.Stop(); this.Exit(); } } @@ -569,21 +564,20 @@ namespace osu.Game.Screens.Play DrawableRuleset.CancelResume(); IsResuming = false; } - GameplayClockContainer.Stop(); PauseOverlay.Show(); lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime; - - samplePause?.Play(); + } public void Resume() { if (!canResume) return; + IsResuming = true; PauseOverlay.Hide(); - + // breaks and time-based conditions may allow instant resume. if (breakTracker.IsBreakTime.Value) completeResume(); @@ -594,8 +588,6 @@ namespace osu.Game.Screens.Play { GameplayClockContainer.Start(); IsResuming = false; - - samplePause?.Stop(); } } @@ -672,7 +664,9 @@ namespace osu.Game.Screens.Play // as we are no longer the current screen, we cannot guarantee the track is still usable. GameplayClockContainer?.StopUsingBeatmapClock(); + fadeOut(); + return base.OnExiting(next); } @@ -717,7 +711,12 @@ namespace osu.Game.Screens.Play Background.EnableUserDim.Value = false; storyboardReplacesBackground.Value = false; } + #endregion + } + + + } From 9dea96e5fdff2a741af29b10948be6a65d63d634 Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Mon, 22 Jun 2020 14:02:21 +0200 Subject: [PATCH 07/21] added pause sound with fading --- osu.Game/Screens/Play/PauseOverlay.cs | 39 ++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 6cc6027a03..6cca0c47fd 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -3,9 +3,18 @@ using System; using System.Linq; +using System.Runtime.CompilerServices; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using NUnit.Framework.Internal; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Audio; using osu.Game.Graphics; using osuTK.Graphics; +using osu.Framework.Logging; + namespace osu.Game.Screens.Play { @@ -16,14 +25,42 @@ namespace osu.Game.Screens.Play public override string Header => "paused"; public override string Description => "you're not going to do what i think you're going to do, are ya?"; + private DrawableSample pauseLoop; + protected override Action BackAction => () => InternalButtons.Children.First().Click(); [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, AudioManager audio) { AddButton("Continue", colours.Green, () => OnResume?.Invoke()); AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); + + var sampleChannel = audio.Samples.Get(@"Gameplay/pause-loop"); + if (sampleChannel != null) + { + AddInternal(pauseLoop = new DrawableSample(sampleChannel) + { + Looping = true, + }); + pauseLoop?.VolumeTo(0.0f); + pauseLoop?.Play(); + } } + + + protected override void PopIn() + { + base.PopIn(); + pauseLoop?.VolumeTo(1.0f, 400, Easing.InQuint); + } + + protected override void PopOut() + { + base.PopOut(); + pauseLoop?.VolumeTo(0.0f); + } + + } } From 836386d03ba0da92f7b625d3cc361110512d15a8 Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Mon, 22 Jun 2020 15:22:13 +0200 Subject: [PATCH 08/21] removed duplicate lines --- osu.Game/Screens/Play/PauseOverlay.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 6cca0c47fd..fc4e509c2c 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -14,7 +14,7 @@ using osu.Framework.Graphics.Audio; using osu.Game.Graphics; using osuTK.Graphics; using osu.Framework.Logging; - +using SharpCompress.Common; namespace osu.Game.Screens.Play { @@ -43,7 +43,6 @@ namespace osu.Game.Screens.Play { Looping = true, }); - pauseLoop?.VolumeTo(0.0f); pauseLoop?.Play(); } } @@ -58,7 +57,7 @@ namespace osu.Game.Screens.Play protected override void PopOut() { base.PopOut(); - pauseLoop?.VolumeTo(0.0f); + pauseLoop.VolumeTo(0.0f); } From 624ad65806da84f82078cc188bc80c2feb4d0d54 Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Tue, 23 Jun 2020 13:09:24 +0200 Subject: [PATCH 09/21] formating --- osu.Game/Screens/Play/PauseOverlay.cs | 17 +++++------------ osu.Game/Screens/Play/Player.cs | 18 +++--------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index fc4e509c2c..191bf0d901 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -3,18 +3,12 @@ using System; using System.Linq; -using System.Runtime.CompilerServices; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using NUnit.Framework.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; using osu.Game.Graphics; using osuTK.Graphics; -using osu.Framework.Logging; -using SharpCompress.Common; namespace osu.Game.Screens.Play { @@ -37,17 +31,18 @@ namespace osu.Game.Screens.Play AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); var sampleChannel = audio.Samples.Get(@"Gameplay/pause-loop"); + if (sampleChannel != null) { - AddInternal(pauseLoop = new DrawableSample(sampleChannel) + pauseLoop = new DrawableSample(sampleChannel) { Looping = true, - }); + }; + AddInternal(pauseLoop); pauseLoop?.Play(); } } - protected override void PopIn() { base.PopIn(); @@ -57,9 +52,7 @@ namespace osu.Game.Screens.Play protected override void PopOut() { base.PopOut(); - pauseLoop.VolumeTo(0.0f); + pauseLoop?.VolumeTo(0.0f); } - - } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ce790e1315..d3b88e56ae 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -5,13 +5,11 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Humanizer; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Audio; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Framework.Logging; @@ -80,7 +78,7 @@ namespace osu.Game.Screens.Play private IAPIProvider api { get; set; } private SampleChannel sampleRestart; - + public BreakOverlay BreakOverlay; private BreakTracker breakTracker; @@ -412,9 +410,7 @@ namespace osu.Game.Screens.Play if (canPause) Pause(); else - { this.Exit(); - } } /// @@ -567,20 +563,19 @@ namespace osu.Game.Screens.Play DrawableRuleset.CancelResume(); IsResuming = false; } + GameplayClockContainer.Stop(); PauseOverlay.Show(); lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime; - } public void Resume() { if (!canResume) return; - IsResuming = true; PauseOverlay.Hide(); - + // breaks and time-based conditions may allow instant resume. if (breakTracker.IsBreakTime.Value) completeResume(); @@ -671,9 +666,7 @@ namespace osu.Game.Screens.Play // as we are no longer the current screen, we cannot guarantee the track is still usable. GameplayClockContainer?.StopUsingBeatmapClock(); - fadeOut(); - return base.OnExiting(next); } @@ -718,12 +711,7 @@ namespace osu.Game.Screens.Play Background.EnableUserDim.Value = false; storyboardReplacesBackground.Value = false; } - #endregion - } - - - } From 53107973a33a82bf5b1b70bb158d293b183536eb Mon Sep 17 00:00:00 2001 From: BananeVolante <42553638+BananeVolante@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:01:13 +0200 Subject: [PATCH 10/21] merged 2 lines Co-authored-by: Salman Ahmed --- osu.Game/Screens/Play/PauseOverlay.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 191bf0d901..2656ef1ebd 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -34,11 +34,10 @@ namespace osu.Game.Screens.Play if (sampleChannel != null) { - pauseLoop = new DrawableSample(sampleChannel) + AddInternal(pauseLoop = new DrawableSample(sampleChannel) { Looping = true, - }; - AddInternal(pauseLoop); + }); pauseLoop?.Play(); } } From 2e8f30461f63db8c651b20a463f8e4f34ae23c8a Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Wed, 24 Jun 2020 14:22:12 +0200 Subject: [PATCH 11/21] play/stops music when entering the pause overlay, instead of letting it play silently in the background --- osu.Game/Screens/Play/PauseOverlay.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 2656ef1ebd..8b35c69aa7 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -38,13 +38,13 @@ namespace osu.Game.Screens.Play { Looping = true, }); - pauseLoop?.Play(); } } protected override void PopIn() { base.PopIn(); + pauseLoop?.Play(); pauseLoop?.VolumeTo(1.0f, 400, Easing.InQuint); } @@ -52,6 +52,7 @@ namespace osu.Game.Screens.Play { base.PopOut(); pauseLoop?.VolumeTo(0.0f); + pauseLoop?.Stop(); } } } From 9e5cc1b7a2d19bc7974065d9ed515425acf559dc Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Thu, 25 Jun 2020 13:26:42 +0200 Subject: [PATCH 12/21] added skin support for the pause loop --- osu.Game/Screens/Play/PauseOverlay.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 8b35c69aa7..fc13743fe5 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -7,7 +7,9 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; +using osu.Game.Audio; using osu.Game.Graphics; +using osu.Game.Skinning; using osuTK.Graphics; namespace osu.Game.Screens.Play @@ -24,13 +26,13 @@ namespace osu.Game.Screens.Play protected override Action BackAction => () => InternalButtons.Children.First().Click(); [BackgroundDependencyLoader] - private void load(OsuColour colours, AudioManager audio) + private void load(OsuColour colours, AudioManager audio, SkinManager skins) { AddButton("Continue", colours.Green, () => OnResume?.Invoke()); AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); - var sampleChannel = audio.Samples.Get(@"Gameplay/pause-loop"); + var sampleChannel = skins.GetSample(new SampleInfo("pause-loop")) ?? audio.Samples.Get(@"Gameplay/pause-loop"); if (sampleChannel != null) { From 7d2d6a52c92a6871d9443f1700721eb837716d0e Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Thu, 25 Jun 2020 18:58:04 +0200 Subject: [PATCH 13/21] now uses SkinnableSample instead of Drawable sample Still does not support switching skins after Pause overlay loading, there will be no sound for the first pause (works fine the the nexts) Also, the pause loop seems to play for approximately 1 second when exiting the screens via restart or quit finally, since SkinnableSound does not play a sound if its aggregate volume is at 0, i had turn up the volume a bit before playing the loop --- osu.Game/Screens/Play/PauseOverlay.cs | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index fc13743fe5..990d85b1cf 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -3,8 +3,11 @@ using System; using System.Linq; +using Humanizer; +using NUnit.Framework.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; using osu.Game.Audio; @@ -21,40 +24,40 @@ namespace osu.Game.Screens.Play public override string Header => "paused"; public override string Description => "you're not going to do what i think you're going to do, are ya?"; - private DrawableSample pauseLoop; + private SkinnableSound pauseLoop; protected override Action BackAction => () => InternalButtons.Children.First().Click(); [BackgroundDependencyLoader] - private void load(OsuColour colours, AudioManager audio, SkinManager skins) + private void load(OsuColour colours) { AddButton("Continue", colours.Green, () => OnResume?.Invoke()); AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); - var sampleChannel = skins.GetSample(new SampleInfo("pause-loop")) ?? audio.Samples.Get(@"Gameplay/pause-loop"); - - if (sampleChannel != null) + AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop")) { - AddInternal(pauseLoop = new DrawableSample(sampleChannel) - { - Looping = true, - }); - } + Looping = true, + }); + } protected override void PopIn() { base.PopIn(); + + //SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it + pauseLoop?.TransformBindableTo(pauseLoop.Volume, 0.00001); + pauseLoop?.TransformBindableTo(pauseLoop.Volume, 1.0f, 400, Easing.InQuint); pauseLoop?.Play(); - pauseLoop?.VolumeTo(1.0f, 400, Easing.InQuint); } protected override void PopOut() { base.PopOut(); - pauseLoop?.VolumeTo(0.0f); - pauseLoop?.Stop(); + pauseLoop?.Stop(); + pauseLoop?.TransformBindableTo(pauseLoop.Volume, 0.0f); } + } } From a4bb238c4534c4bce43404c79b2e2402fb78b3d1 Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Fri, 26 Jun 2020 14:07:27 +0200 Subject: [PATCH 14/21] fixed bug preventing the pause loop from playing during the first pause after changing a skin --- osu.Game/Screens/Play/PauseOverlay.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 990d85b1cf..81c288f928 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -3,13 +3,8 @@ using System; using System.Linq; -using Humanizer; -using NUnit.Framework.Internal; using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; using osu.Framework.Graphics; -using osu.Framework.Graphics.Audio; using osu.Game.Audio; using osu.Game.Graphics; using osu.Game.Skinning; @@ -39,7 +34,9 @@ namespace osu.Game.Screens.Play { Looping = true, }); - + // PopIn is called before updating the skin, and when a sample is updated, its "playing" value is reset + // the sample must be played again(and if it plays when it shouldn't, the volume will be at 0) + pauseLoop.OnSkinChanged += () => pauseLoop.Play(); } protected override void PopIn() @@ -55,9 +52,9 @@ namespace osu.Game.Screens.Play protected override void PopOut() { base.PopOut(); - pauseLoop?.Stop(); + + pauseLoop?.Stop(); pauseLoop?.TransformBindableTo(pauseLoop.Volume, 0.0f); } - } } From ab134c0ed7f92a2c83a503c679a18d1af1e8a1bc Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Wed, 1 Jul 2020 13:27:33 +0200 Subject: [PATCH 15/21] removed unneeded information in a comment --- osu.Game/Screens/Play/PauseOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 81c288f928..56d0e2d958 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play Looping = true, }); // PopIn is called before updating the skin, and when a sample is updated, its "playing" value is reset - // the sample must be played again(and if it plays when it shouldn't, the volume will be at 0) + // the sample must be played again pauseLoop.OnSkinChanged += () => pauseLoop.Play(); } From ab1eb469af357ecde23288cd14294e91c54dbe7e Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Wed, 1 Jul 2020 13:30:23 +0200 Subject: [PATCH 16/21] removed unneeded null checks --- osu.Game/Screens/Play/PauseOverlay.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 56d0e2d958..022183d82b 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -44,17 +44,17 @@ namespace osu.Game.Screens.Play base.PopIn(); //SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it - pauseLoop?.TransformBindableTo(pauseLoop.Volume, 0.00001); - pauseLoop?.TransformBindableTo(pauseLoop.Volume, 1.0f, 400, Easing.InQuint); - pauseLoop?.Play(); + pauseLoop.TransformBindableTo(pauseLoop.Volume, 0.00001); + pauseLoop.TransformBindableTo(pauseLoop.Volume, 1.0f, 400, Easing.InQuint); + pauseLoop.Play(); } protected override void PopOut() { base.PopOut(); - pauseLoop?.Stop(); - pauseLoop?.TransformBindableTo(pauseLoop.Volume, 0.0f); + pauseLoop.Stop(); + pauseLoop.TransformBindableTo(pauseLoop.Volume, 0.0f); } } } From e8f23e35a572d658536a19e083e451d29dc610fa Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Fri, 3 Jul 2020 14:33:42 +0200 Subject: [PATCH 17/21] WIP : replaced TransformBindableTo by VolumeTo Currently, the VolumeTO calls taht use a fading does not do anything. calling VolumeTo calls pauseLoop.samplesContainer.TransformBindableTo(....), while i used to call pauseLoop.TransformBindableTo(....) --- osu.Game/Screens/Play/PauseOverlay.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 022183d82b..a8d291d6c3 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -3,8 +3,10 @@ using System; using System.Linq; +using NUnit.Framework.Internal; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Audio; using osu.Game.Audio; using osu.Game.Graphics; using osu.Game.Skinning; @@ -44,8 +46,8 @@ namespace osu.Game.Screens.Play base.PopIn(); //SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it - pauseLoop.TransformBindableTo(pauseLoop.Volume, 0.00001); - pauseLoop.TransformBindableTo(pauseLoop.Volume, 1.0f, 400, Easing.InQuint); + pauseLoop.VolumeTo(0.00001f); + pauseLoop.VolumeTo(1.0f, 400, Easing.InQuint); pauseLoop.Play(); } @@ -53,8 +55,9 @@ namespace osu.Game.Screens.Play { base.PopOut(); - pauseLoop.Stop(); - pauseLoop.TransformBindableTo(pauseLoop.Volume, 0.0f); + var transformSeq = pauseLoop.VolumeTo(0.0f, 190, Easing.OutQuad ); + transformSeq.Finally(_ => pauseLoop.Stop()); + } } } From f03303573ef1bd2fe972b670d0f7ea4a9eedfb83 Mon Sep 17 00:00:00 2001 From: BananeVolante Date: Wed, 8 Jul 2020 13:54:22 +0200 Subject: [PATCH 18/21] formating --- osu.Game/Screens/Play/PauseOverlay.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index a8d291d6c3..7b3fba7ddf 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -3,10 +3,8 @@ using System; using System.Linq; -using NUnit.Framework.Internal; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Audio; using osu.Game.Audio; using osu.Game.Graphics; using osu.Game.Skinning; @@ -55,9 +53,8 @@ namespace osu.Game.Screens.Play { base.PopOut(); - var transformSeq = pauseLoop.VolumeTo(0.0f, 190, Easing.OutQuad ); + var transformSeq = pauseLoop.VolumeTo(0.0f, 190, Easing.OutQuad); transformSeq.Finally(_ => pauseLoop.Stop()); - } } } From a39c4236c7d8bdaaa7e86f50de4eb8282c4e0999 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Jul 2020 19:08:50 +0900 Subject: [PATCH 19/21] Fix multiple issues and standardise transforms --- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 7 ++++--- osu.Game/Screens/Play/PauseOverlay.cs | 15 ++++++++++----- osu.Game/Skinning/SkinnableSound.cs | 6 ++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index 6b37135c86..57403a0987 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -24,7 +24,8 @@ namespace osu.Game.Screens.Play { public abstract class GameplayMenuOverlay : OverlayContainer, IKeyBindingHandler { - private const int transition_duration = 200; + protected const int TRANSITION_DURATION = 200; + private const int button_height = 70; private const float background_alpha = 0.75f; @@ -156,8 +157,8 @@ namespace osu.Game.Screens.Play } } - protected override void PopIn() => this.FadeIn(transition_duration, Easing.In); - protected override void PopOut() => this.FadeOut(transition_duration, Easing.In); + protected override void PopIn() => this.FadeIn(TRANSITION_DURATION, Easing.In); + protected override void PopOut() => this.FadeOut(TRANSITION_DURATION, Easing.In); // Don't let mouse down events through the overlay or people can click circles while paused. protected override bool OnMouseDown(MouseDownEvent e) => true; diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 7b3fba7ddf..e74585990a 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -16,6 +16,8 @@ namespace osu.Game.Screens.Play { public Action OnResume; + public override bool IsPresent => base.IsPresent || pauseLoop.IsPlaying; + public override string Header => "paused"; public override string Description => "you're not going to do what i think you're going to do, are ya?"; @@ -23,6 +25,8 @@ namespace osu.Game.Screens.Play protected override Action BackAction => () => InternalButtons.Children.First().Click(); + private const float minimum_volume = 0.0001f; + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -34,18 +38,20 @@ namespace osu.Game.Screens.Play { Looping = true, }); + // PopIn is called before updating the skin, and when a sample is updated, its "playing" value is reset // the sample must be played again pauseLoop.OnSkinChanged += () => pauseLoop.Play(); + + // SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it + pauseLoop.VolumeTo(minimum_volume); } protected override void PopIn() { base.PopIn(); - //SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it - pauseLoop.VolumeTo(0.00001f); - pauseLoop.VolumeTo(1.0f, 400, Easing.InQuint); + pauseLoop.VolumeTo(1.0f, TRANSITION_DURATION, Easing.InQuint); pauseLoop.Play(); } @@ -53,8 +59,7 @@ namespace osu.Game.Screens.Play { base.PopOut(); - var transformSeq = pauseLoop.VolumeTo(0.0f, 190, Easing.OutQuad); - transformSeq.Finally(_ => pauseLoop.Stop()); + pauseLoop.VolumeTo(minimum_volume, TRANSITION_DURATION, Easing.OutQuad).Finally(_ => pauseLoop.Stop()); } } } diff --git a/osu.Game/Skinning/SkinnableSound.cs b/osu.Game/Skinning/SkinnableSound.cs index 24d6648273..fb27ba0550 100644 --- a/osu.Game/Skinning/SkinnableSound.cs +++ b/osu.Game/Skinning/SkinnableSound.cs @@ -45,6 +45,10 @@ namespace osu.Game.Skinning public BindableNumber Tempo => samplesContainer.Tempo; + public override bool IsPresent => Scheduler.HasPendingTasks || IsPlaying; + + public bool IsPlaying => samplesContainer.Any(s => s.Playing); + /// /// Smoothly adjusts over time. /// @@ -94,8 +98,6 @@ namespace osu.Game.Skinning public void Stop() => samplesContainer.ForEach(c => c.Stop()); - public override bool IsPresent => Scheduler.HasPendingTasks; - protected override void SkinChanged(ISkinSource skin, bool allowFallback) { var channels = hitSamples.Select(s => From 77143952a91da519665c0a13a19abe01fb97275a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Jul 2020 19:17:48 +0900 Subject: [PATCH 20/21] Add test coverage --- .../Visual/Gameplay/TestScenePause.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs index 1961a224c1..420bf29429 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs @@ -11,6 +11,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; using osu.Game.Rulesets; using osu.Game.Screens.Play; +using osu.Game.Skinning; using osuTK; using osuTK.Input; @@ -221,6 +222,31 @@ namespace osu.Game.Tests.Visual.Gameplay confirmExited(); } + [Test] + public void TestPauseSoundLoop() + { + AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000)); + + SkinnableSound getLoop() => Player.ChildrenOfType().FirstOrDefault()?.ChildrenOfType().FirstOrDefault(); + + pauseAndConfirm(); + AddAssert("loop is playing", () => getLoop().IsPlaying); + + resumeAndConfirm(); + AddUntilStep("loop is stopped", () => !getLoop().IsPlaying); + + AddUntilStep("pause again", () => + { + Player.Pause(); + return !Player.GameplayClockContainer.GameplayClock.IsRunning; + }); + + AddAssert("loop is playing", () => getLoop().IsPlaying); + + resumeAndConfirm(); + AddUntilStep("loop is stopped", () => !getLoop().IsPlaying); + } + private void pauseAndConfirm() { pause(); From ee05d5cb14b7d946a0335f9f7208b6213da6ed57 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Jul 2020 09:06:15 +0900 Subject: [PATCH 21/21] Remove no-longer-necessary play trigger on skin change --- osu.Game/Screens/Play/PauseOverlay.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index e74585990a..fa917cda32 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -39,10 +39,6 @@ namespace osu.Game.Screens.Play Looping = true, }); - // PopIn is called before updating the skin, and when a sample is updated, its "playing" value is reset - // the sample must be played again - pauseLoop.OnSkinChanged += () => pauseLoop.Play(); - // SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it pauseLoop.VolumeTo(minimum_volume); }