From 0985cb3327421220f0634d567a07f3a2688ed0a7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 13 Nov 2020 14:08:08 +0900 Subject: [PATCH] Fix perform from menu not hiding overlays if already on target screen --- .../Navigation/TestScenePerformFromScreen.cs | 19 +++++++++++++++++++ osu.Game/PerformFromMenuRunner.cs | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Navigation/TestScenePerformFromScreen.cs b/osu.Game.Tests/Visual/Navigation/TestScenePerformFromScreen.cs index a4190e0b84..21d3bdaae3 100644 --- a/osu.Game.Tests/Visual/Navigation/TestScenePerformFromScreen.cs +++ b/osu.Game.Tests/Visual/Navigation/TestScenePerformFromScreen.cs @@ -1,9 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Graphics.Containers; using osu.Framework.Screens; +using osu.Framework.Testing; using osu.Game.Overlays; using osu.Game.Screens; using osu.Game.Screens.Menu; @@ -73,6 +76,22 @@ namespace osu.Game.Tests.Visual.Navigation AddAssert("did perform", () => actionPerformed); } + [Test] + public void TestOverlaysAlwaysClosed() + { + ChatOverlay chat = null; + AddUntilStep("is at menu", () => Game.ScreenStack.CurrentScreen is MainMenu); + AddUntilStep("wait for chat load", () => (chat = Game.ChildrenOfType().SingleOrDefault()) != null); + + AddStep("show chat", () => InputManager.Key(Key.F8)); + + AddStep("try to perform", () => Game.PerformFromScreen(_ => actionPerformed = true)); + + AddUntilStep("still at menu", () => Game.ScreenStack.CurrentScreen is MainMenu); + AddAssert("did perform", () => actionPerformed); + AddAssert("chat closed", () => chat.State.Value == Visibility.Hidden); + } + [TestCase(true)] [TestCase(false)] public void TestPerformBlockedByDialog(bool confirmed) diff --git a/osu.Game/PerformFromMenuRunner.cs b/osu.Game/PerformFromMenuRunner.cs index 9afe87f74f..5898c116dd 100644 --- a/osu.Game/PerformFromMenuRunner.cs +++ b/osu.Game/PerformFromMenuRunner.cs @@ -76,6 +76,8 @@ namespace osu.Game // a dialog may be blocking the execution for now. if (checkForDialog(current)) return; + game.CloseAllOverlays(false); + // we may already be at the target screen type. if (validScreens.Contains(getCurrentScreen().GetType()) && !beatmap.Disabled) { @@ -83,8 +85,6 @@ namespace osu.Game return; } - game.CloseAllOverlays(false); - while (current != null) { if (validScreens.Contains(current.GetType()))