1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Merge pull request #18747 from ggliv/skin-editor-transform-fix

Clear selected components on SkinEditor hide
This commit is contained in:
Dean Herbert 2022-06-20 14:47:28 +09:00 committed by GitHub
commit 2edd56ad17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 99 additions and 24 deletions

View File

@ -8,7 +8,9 @@ using NUnit.Framework;
using osu.Framework.Extensions;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Framework.Threading;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
@ -16,6 +18,7 @@ using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
using osu.Game.Skinning.Editor;
using osu.Game.Tests.Beatmaps.IO;
using osuTK;
using osuTK.Input;
using static osu.Game.Tests.Visual.Navigation.TestSceneScreenNavigation;
@ -26,29 +29,6 @@ namespace osu.Game.Tests.Visual.Navigation
private TestPlaySongSelect songSelect;
private SkinEditor skinEditor => Game.ChildrenOfType<SkinEditor>().FirstOrDefault();
private void advanceToSongSelect()
{
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);
InputManager.PressKey(Key.ShiftLeft);
InputManager.Key(Key.S);
InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.ShiftLeft);
});
AddUntilStep("skin editor loaded", () => skinEditor != null);
}
[Test]
public void TestEditComponentDuringGameplay()
{
@ -88,6 +68,68 @@ namespace osu.Game.Tests.Visual.Navigation
AddAssert("value is less than default", () => hitErrorMeter.JudgementLineThickness.Value < hitErrorMeter.JudgementLineThickness.Default);
}
[Test]
public void TestComponentsDeselectedOnSkinEditorHide()
{
advanceToSongSelect();
openSkinEditor();
switchToGameplayScene();
AddUntilStep("wait for components", () => skinEditor.ChildrenOfType<SkinBlueprint>().Any());
AddStep("select all components", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.Key(Key.A);
InputManager.ReleaseKey(Key.ControlLeft);
});
AddUntilStep("components selected", () => skinEditor.SelectedComponents.Count > 0);
toggleSkinEditor();
AddUntilStep("no components selected", () => skinEditor.SelectedComponents.Count == 0);
}
[Test]
public void TestSwitchScreenWhileDraggingComponent()
{
Vector2 firstBlueprintCentre = Vector2.Zero;
ScheduledDelegate movementDelegate = null;
advanceToSongSelect();
openSkinEditor();
AddStep("add skinnable component", () =>
{
skinEditor.ChildrenOfType<SkinComponentToolbox.ToolboxComponentButton>().First().TriggerClick();
});
AddUntilStep("newly added component selected", () => skinEditor.SelectedComponents.Count == 1);
AddStep("start drag", () =>
{
firstBlueprintCentre = skinEditor.ChildrenOfType<SkinBlueprint>().First().ScreenSpaceDrawQuad.Centre;
InputManager.MoveMouseTo(firstBlueprintCentre);
InputManager.PressButton(MouseButton.Left);
});
AddStep("start movement", () => movementDelegate = Scheduler.AddDelayed(() => { InputManager.MoveMouseTo(firstBlueprintCentre += new Vector2(1)); }, 10, true));
toggleSkinEditor();
AddStep("exit song select", () => songSelect.Exit());
AddUntilStep("wait for blueprints removed", () => !skinEditor.ChildrenOfType<SkinBlueprint>().Any());
AddStep("stop drag", () =>
{
InputManager.ReleaseButton(MouseButton.Left);
movementDelegate?.Cancel();
});
}
[Test]
public void TestAutoplayCompatibleModsRetainedOnEnteringGameplay()
{
@ -146,8 +188,35 @@ namespace osu.Game.Tests.Visual.Navigation
AddUntilStep("mod overlay closed", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
}
private void advanceToSongSelect()
{
PushAndConfirm(() => songSelect = new TestPlaySongSelect());
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
}
private void openSkinEditor()
{
toggleSkinEditor();
AddUntilStep("skin editor loaded", () => skinEditor != null);
}
private void toggleSkinEditor()
{
AddStep("toggle skin editor", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.ShiftLeft);
InputManager.Key(Key.S);
InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.ShiftLeft);
});
}
private void switchToGameplayScene()
{
AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
AddStep("Click gameplay scene button", () =>
{
InputManager.MoveMouseTo(skinEditor.ChildrenOfType<SkinEditorSceneLibrary.SceneButton>().First(b => b.Text == "Gameplay"));

View File

@ -88,7 +88,7 @@ namespace osu.Game.Skinning.Editor
}
}
private class ToolboxComponentButton : OsuButton
public class ToolboxComponentButton : OsuButton
{
protected override bool ShouldBeConsideredForInput(Drawable child) => false;

View File

@ -322,6 +322,12 @@ namespace osu.Game.Skinning.Editor
protected override bool OnMouseDown(MouseDownEvent e) => true;
public override void Hide()
{
base.Hide();
SelectedComponents.Clear();
}
protected override void PopIn()
{
this