From 836de491353212ed8acc533437ac72b1c349af38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 7 May 2022 22:41:48 +0200 Subject: [PATCH 1/4] Adjust skin editor scene library test for extensibility --- .../TestSceneSkinEditorSceneLibrary.cs | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorSceneLibrary.cs b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorSceneLibrary.cs index d3aeba2c0f..3e6cf325df 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorSceneLibrary.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorSceneLibrary.cs @@ -20,20 +20,21 @@ namespace osu.Game.Tests.Visual.Navigation { public class TestSceneSkinEditorSceneLibrary : OsuGameTestScene { - private SkinEditor skinEditor; + private TestPlaySongSelect songSelect; + private SkinEditor skinEditor => Game.ChildrenOfType().FirstOrDefault(); - public override void SetUpSteps() + private void advanceToSongSelect() { - base.SetUpSteps(); - - Screens.Select.SongSelect songSelect = null; PushAndConfirm(() => songSelect = new TestPlaySongSelect()); AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded); AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely()); AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault); + } + private void openSkinEditor() + { AddStep("open skin editor", () => { InputManager.PressKey(Key.ControlLeft); @@ -42,13 +43,15 @@ namespace osu.Game.Tests.Visual.Navigation InputManager.ReleaseKey(Key.ControlLeft); InputManager.ReleaseKey(Key.ShiftLeft); }); - - AddUntilStep("get skin editor", () => (skinEditor = Game.ChildrenOfType().FirstOrDefault()) != null); + AddUntilStep("skin editor loaded", () => skinEditor != null); } [Test] public void TestEditComponentDuringGameplay() { + advanceToSongSelect(); + openSkinEditor(); + switchToGameplayScene(); BarHitErrorMeter hitErrorMeter = null; @@ -85,6 +88,8 @@ namespace osu.Game.Tests.Visual.Navigation [Test] public void TestAutoplayCompatibleModsRetainedOnEnteringGameplay() { + advanceToSongSelect(); + openSkinEditor(); AddStep("select DT", () => Game.SelectedMods.Value = new Mod[] { new OsuModDoubleTime() }); switchToGameplayScene(); @@ -95,6 +100,8 @@ namespace osu.Game.Tests.Visual.Navigation [Test] public void TestAutoplayIncompatibleModsRemovedOnEnteringGameplay() { + advanceToSongSelect(); + openSkinEditor(); AddStep("select no fail and spun out", () => Game.SelectedMods.Value = new Mod[] { new OsuModNoFail(), new OsuModSpunOut() }); switchToGameplayScene(); @@ -105,6 +112,8 @@ namespace osu.Game.Tests.Visual.Navigation [Test] public void TestDuplicateAutoplayModRemovedOnEnteringGameplay() { + advanceToSongSelect(); + openSkinEditor(); AddStep("select autoplay", () => Game.SelectedMods.Value = new Mod[] { new OsuModAutoplay() }); switchToGameplayScene(); @@ -115,6 +124,8 @@ namespace osu.Game.Tests.Visual.Navigation [Test] public void TestCinemaModRemovedOnEnteringGameplay() { + advanceToSongSelect(); + openSkinEditor(); AddStep("select cinema", () => Game.SelectedMods.Value = new Mod[] { new OsuModCinema() }); switchToGameplayScene(); From a3e61fddcb06c21ed7e12d7af61bd9a7d03a260c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 7 May 2022 22:43:45 +0200 Subject: [PATCH 2/4] Rename skin editor scene library test scene to be more general --- ...inEditorSceneLibrary.cs => TestSceneSkinEditorNavigation.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename osu.Game.Tests/Visual/Navigation/{TestSceneSkinEditorSceneLibrary.cs => TestSceneSkinEditorNavigation.cs} (98%) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorSceneLibrary.cs b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs similarity index 98% rename from osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorSceneLibrary.cs rename to osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs index 3e6cf325df..5359d992a1 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorSceneLibrary.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs @@ -18,7 +18,7 @@ using static osu.Game.Tests.Visual.Navigation.TestSceneScreenNavigation; namespace osu.Game.Tests.Visual.Navigation { - public class TestSceneSkinEditorSceneLibrary : OsuGameTestScene + public class TestSceneSkinEditorNavigation : OsuGameTestScene { private TestPlaySongSelect songSelect; private SkinEditor skinEditor => Game.ChildrenOfType().FirstOrDefault(); From bdea6d865443e51e2ae927b01d3f347473364907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 7 May 2022 22:47:19 +0200 Subject: [PATCH 3/4] Add failing test for mod overlay not closing on entering skin editor --- .../Navigation/TestSceneSkinEditorNavigation.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs index 5359d992a1..68c44f49cc 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneSkinEditorNavigation.cs @@ -4,6 +4,7 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Extensions; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing; using osu.Game.Overlays.Settings; @@ -133,6 +134,16 @@ namespace osu.Game.Tests.Visual.Navigation AddAssert("no mod selected", () => !((Player)Game.ScreenStack.CurrentScreen).Mods.Value.Any()); } + [Test] + public void TestModOverlayClosesOnOpeningSkinEditor() + { + advanceToSongSelect(); + AddStep("open mod overlay", () => songSelect.ModSelectOverlay.Show()); + + openSkinEditor(); + AddUntilStep("mod overlay closed", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden); + } + private void switchToGameplayScene() { AddStep("Click gameplay scene button", () => skinEditor.ChildrenOfType().First(b => b.Text == "Gameplay").TriggerClick()); From a45ca2ad101957b9e00560a0b66a01508e724168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 7 May 2022 22:50:10 +0200 Subject: [PATCH 4/4] Fix focused overlays not registering as such Also fixes bug wherein opening skin editor at song select with mod select open would show mod select on top of the skin editor. --- osu.Game/OsuGame.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index c2a96a9082..54c4231b06 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -201,6 +201,10 @@ namespace osu.Game externalOverlays.Add(overlayContainer); overlayContent.Add(overlayContainer); + + if (overlayContainer is OsuFocusedOverlayContainer focusedOverlayContainer) + focusedOverlays.Add(focusedOverlayContainer); + return new InvokeOnDisposal(() => unregisterBlockingOverlay(overlayContainer)); } @@ -223,6 +227,10 @@ namespace osu.Game private void unregisterBlockingOverlay(OverlayContainer overlayContainer) { externalOverlays.Remove(overlayContainer); + + if (overlayContainer is OsuFocusedOverlayContainer focusedOverlayContainer) + focusedOverlays.Remove(focusedOverlayContainer); + overlayContainer.Expire(); }