From 983cabdb9820ca6488140229697a1e6ff4f01ef6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 25 Jun 2019 22:27:50 +0900 Subject: [PATCH 1/5] Disallow back button on disclaimer screen --- osu.Game/Screens/Menu/Disclaimer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 0130a5143b..8cf232af81 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -31,6 +31,8 @@ namespace osu.Game.Screens.Menu public override bool HideOverlaysOnEnter => true; public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; + public override bool AllowBackButton => false; + public override bool CursorVisible => false; private Drawable heart; From 40cf573368c0e513427512f495cb0c1f0ca68347 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 25 Jun 2019 23:15:58 +0900 Subject: [PATCH 2/5] Fix pause not correctly showing pause screen --- osu.Game/Screens/Play/Player.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 8c2c653c5b..957498dc44 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -184,7 +184,7 @@ namespace osu.Game.Screens.Play if (!this.IsCurrentScreen()) return; fadeOut(true); - performUserRequestedExit(); + performImmediateExit(); }, }, failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, } @@ -251,15 +251,20 @@ namespace osu.Game.Screens.Play return working; } - private void performUserRequestedExit() + private void performImmediateExit() { - if (!this.IsCurrentScreen()) return; - // if a restart has been requested, cancel any pending completion (user has shown intent to restart). onCompletionEvent = null; ValidForResume = false; + performUserRequestedExit(); + } + + private void performUserRequestedExit() + { + if (!this.IsCurrentScreen()) return; + this.Exit(); } From a4214db39ea1e710eaee14332fa2b5a77ce91fd6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 25 Jun 2019 23:48:42 +0900 Subject: [PATCH 3/5] Add test for pause via hold --- .../Visual/Gameplay/TestScenePause.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs index ac10c77a78..97a4a90c33 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs @@ -5,6 +5,7 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.UserInterface; using osu.Framework.Screens; using osu.Framework.Testing; using osu.Game.Graphics.Containers; @@ -137,6 +138,22 @@ namespace osu.Game.Tests.Visual.Gameplay exitAndConfirm(); } + [Test] + public void TestExitViaHoldToExit() + { + AddStep("exit", () => + { + InputManager.MoveMouseTo(Player.HUDOverlay.HoldToQuit.First(c => c is HoldToConfirmContainer)); + InputManager.PressButton(MouseButton.Left); + }); + + confirmPaused(); + + AddStep("release", () => InputManager.ReleaseButton(MouseButton.Left)); + + exitAndConfirm(); + } + [Test] public void TestExitFromPause() { From c04f14a1e34c3740eea750f50e912b74efc0c249 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 26 Jun 2019 00:23:39 +0900 Subject: [PATCH 4/5] Remove unused using statement --- osu.Game.Tests/Visual/Gameplay/TestScenePause.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs index 97a4a90c33..5808a78056 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs @@ -5,7 +5,6 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.UserInterface; using osu.Framework.Screens; using osu.Framework.Testing; using osu.Game.Graphics.Containers; From 446fbce81c34fd849bc8de08fdddf22cfe92a4c4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 26 Jun 2019 01:36:17 +0900 Subject: [PATCH 5/5] Add base class for startup screens Avoids missing adding changes to screens like Disclaimer, which may not be shown in debug builds. --- osu.Game/Screens/Loader.cs | 11 +---------- osu.Game/Screens/Menu/Disclaimer.cs | 10 +--------- osu.Game/Screens/Menu/Intro.cs | 10 +--------- osu.Game/Screens/StartupScreen.cs | 21 +++++++++++++++++++++ 4 files changed, 24 insertions(+), 28 deletions(-) create mode 100644 osu.Game/Screens/StartupScreen.cs diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index e4956bc8ab..8add730c4e 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -9,22 +9,13 @@ using osu.Framework.Graphics.Shaders; using osu.Game.Screens.Menu; using osuTK; using osu.Framework.Screens; -using osu.Game.Overlays; namespace osu.Game.Screens { - public class Loader : OsuScreen + public class Loader : StartupScreen { private bool showDisclaimer; - public override bool HideOverlaysOnEnter => true; - - public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; - - public override bool CursorVisible => false; - - public override bool AllowBackButton => false; - public Loader() { ValidForResume = false; diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 8cf232af81..97231a1331 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -15,12 +15,11 @@ using osu.Game.Graphics.Containers; using osu.Game.Online.API; using osuTK; using osuTK.Graphics; -using osu.Game.Overlays; using osu.Game.Users; namespace osu.Game.Screens.Menu { - public class Disclaimer : OsuScreen + public class Disclaimer : StartupScreen { private Intro intro; private SpriteIcon icon; @@ -28,13 +27,6 @@ namespace osu.Game.Screens.Menu private LinkFlowContainer textFlow; private LinkFlowContainer supportFlow; - public override bool HideOverlaysOnEnter => true; - public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; - - public override bool AllowBackButton => false; - - public override bool CursorVisible => false; - private Drawable heart; private const float icon_y = -85; diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index eec92e3080..c52e8541c5 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -15,11 +15,10 @@ using osu.Game.IO.Archives; using osu.Game.Screens.Backgrounds; using osuTK; using osuTK.Graphics; -using osu.Game.Overlays; namespace osu.Game.Screens.Menu { - public class Intro : OsuScreen + public class Intro : StartupScreen { private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; @@ -32,13 +31,6 @@ namespace osu.Game.Screens.Menu private SampleChannel welcome; private SampleChannel seeya; - public override bool AllowBackButton => false; - - public override bool HideOverlaysOnEnter => true; - public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; - - public override bool CursorVisible => false; - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBlack(); private Bindable menuVoice; diff --git a/osu.Game/Screens/StartupScreen.cs b/osu.Game/Screens/StartupScreen.cs new file mode 100644 index 0000000000..797f185a37 --- /dev/null +++ b/osu.Game/Screens/StartupScreen.cs @@ -0,0 +1,21 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Overlays; + +namespace osu.Game.Screens +{ + /// + /// A screen which is shown once as part of the startup procedure. + /// + public abstract class StartupScreen : OsuScreen + { + public override bool AllowBackButton => false; + + public override bool HideOverlaysOnEnter => true; + + public override bool CursorVisible => false; + + public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; + } +}