Merge pull request #18142 from bdach/mod-overlay/skin-editor-breakage

Fix skin editor overlay showing behind mod select overlay
This commit is contained in:
Salman Ahmed 2022-05-08 00:30:31 +03:00 committed by GitHub
commit 834e7b4323
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 8 deletions

View File

@ -4,6 +4,7 @@
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
@ -18,22 +19,23 @@ using static osu.Game.Tests.Visual.Navigation.TestSceneScreenNavigation;
namespace osu.Game.Tests.Visual.Navigation namespace osu.Game.Tests.Visual.Navigation
{ {
public class TestSceneSkinEditorSceneLibrary : OsuGameTestScene public class TestSceneSkinEditorNavigation : OsuGameTestScene
{ {
private SkinEditor skinEditor; private TestPlaySongSelect songSelect;
private SkinEditor skinEditor => Game.ChildrenOfType<SkinEditor>().FirstOrDefault();
public override void SetUpSteps() private void advanceToSongSelect()
{ {
base.SetUpSteps();
Screens.Select.SongSelect songSelect = null;
PushAndConfirm(() => songSelect = new TestPlaySongSelect()); PushAndConfirm(() => songSelect = new TestPlaySongSelect());
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded); AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely()); AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault); AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
}
private void openSkinEditor()
{
AddStep("open skin editor", () => AddStep("open skin editor", () =>
{ {
InputManager.PressKey(Key.ControlLeft); InputManager.PressKey(Key.ControlLeft);
@ -42,13 +44,15 @@ namespace osu.Game.Tests.Visual.Navigation
InputManager.ReleaseKey(Key.ControlLeft); InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.ShiftLeft); InputManager.ReleaseKey(Key.ShiftLeft);
}); });
AddUntilStep("skin editor loaded", () => skinEditor != null);
AddUntilStep("get skin editor", () => (skinEditor = Game.ChildrenOfType<SkinEditor>().FirstOrDefault()) != null);
} }
[Test] [Test]
public void TestEditComponentDuringGameplay() public void TestEditComponentDuringGameplay()
{ {
advanceToSongSelect();
openSkinEditor();
switchToGameplayScene(); switchToGameplayScene();
BarHitErrorMeter hitErrorMeter = null; BarHitErrorMeter hitErrorMeter = null;
@ -85,6 +89,8 @@ namespace osu.Game.Tests.Visual.Navigation
[Test] [Test]
public void TestAutoplayCompatibleModsRetainedOnEnteringGameplay() public void TestAutoplayCompatibleModsRetainedOnEnteringGameplay()
{ {
advanceToSongSelect();
openSkinEditor();
AddStep("select DT", () => Game.SelectedMods.Value = new Mod[] { new OsuModDoubleTime() }); AddStep("select DT", () => Game.SelectedMods.Value = new Mod[] { new OsuModDoubleTime() });
switchToGameplayScene(); switchToGameplayScene();
@ -95,6 +101,8 @@ namespace osu.Game.Tests.Visual.Navigation
[Test] [Test]
public void TestAutoplayIncompatibleModsRemovedOnEnteringGameplay() public void TestAutoplayIncompatibleModsRemovedOnEnteringGameplay()
{ {
advanceToSongSelect();
openSkinEditor();
AddStep("select no fail and spun out", () => Game.SelectedMods.Value = new Mod[] { new OsuModNoFail(), new OsuModSpunOut() }); AddStep("select no fail and spun out", () => Game.SelectedMods.Value = new Mod[] { new OsuModNoFail(), new OsuModSpunOut() });
switchToGameplayScene(); switchToGameplayScene();
@ -105,6 +113,8 @@ namespace osu.Game.Tests.Visual.Navigation
[Test] [Test]
public void TestDuplicateAutoplayModRemovedOnEnteringGameplay() public void TestDuplicateAutoplayModRemovedOnEnteringGameplay()
{ {
advanceToSongSelect();
openSkinEditor();
AddStep("select autoplay", () => Game.SelectedMods.Value = new Mod[] { new OsuModAutoplay() }); AddStep("select autoplay", () => Game.SelectedMods.Value = new Mod[] { new OsuModAutoplay() });
switchToGameplayScene(); switchToGameplayScene();
@ -115,6 +125,8 @@ namespace osu.Game.Tests.Visual.Navigation
[Test] [Test]
public void TestCinemaModRemovedOnEnteringGameplay() public void TestCinemaModRemovedOnEnteringGameplay()
{ {
advanceToSongSelect();
openSkinEditor();
AddStep("select cinema", () => Game.SelectedMods.Value = new Mod[] { new OsuModCinema() }); AddStep("select cinema", () => Game.SelectedMods.Value = new Mod[] { new OsuModCinema() });
switchToGameplayScene(); switchToGameplayScene();
@ -122,6 +134,16 @@ namespace osu.Game.Tests.Visual.Navigation
AddAssert("no mod selected", () => !((Player)Game.ScreenStack.CurrentScreen).Mods.Value.Any()); 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() private void switchToGameplayScene()
{ {
AddStep("Click gameplay scene button", () => skinEditor.ChildrenOfType<SkinEditorSceneLibrary.SceneButton>().First(b => b.Text == "Gameplay").TriggerClick()); AddStep("Click gameplay scene button", () => skinEditor.ChildrenOfType<SkinEditorSceneLibrary.SceneButton>().First(b => b.Text == "Gameplay").TriggerClick());

View File

@ -201,6 +201,10 @@ namespace osu.Game
externalOverlays.Add(overlayContainer); externalOverlays.Add(overlayContainer);
overlayContent.Add(overlayContainer); overlayContent.Add(overlayContainer);
if (overlayContainer is OsuFocusedOverlayContainer focusedOverlayContainer)
focusedOverlays.Add(focusedOverlayContainer);
return new InvokeOnDisposal(() => unregisterBlockingOverlay(overlayContainer)); return new InvokeOnDisposal(() => unregisterBlockingOverlay(overlayContainer));
} }
@ -223,6 +227,10 @@ namespace osu.Game
private void unregisterBlockingOverlay(OverlayContainer overlayContainer) private void unregisterBlockingOverlay(OverlayContainer overlayContainer)
{ {
externalOverlays.Remove(overlayContainer); externalOverlays.Remove(overlayContainer);
if (overlayContainer is OsuFocusedOverlayContainer focusedOverlayContainer)
focusedOverlays.Remove(focusedOverlayContainer);
overlayContainer.Expire(); overlayContainer.Expire();
} }