diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs index 0d8ea0561200..04cb12963024 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs @@ -7,6 +7,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Input; using osu.Framework.Testing; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; @@ -58,19 +59,19 @@ public void TestDisplay() { SelectedMods.Value = new[] { new OsuModDoubleTime() }; panel.Enabled.Value = true; - panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded; + panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.ExpandedByMod; }); AddStep("set DA", () => { SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() }; panel.Enabled.Value = true; - panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded; + panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.ExpandedByMod; }); AddStep("set FL+WU+DA+AD", () => { SelectedMods.Value = new Mod[] { new OsuModFlashlight(), new ModWindUp(), new OsuModDifficultyAdjust(), new OsuModApproachDifferent() }; panel.Enabled.Value = true; - panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded; + panel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.ExpandedByMod; }); AddStep("set empty", () => { @@ -120,7 +121,7 @@ public void TestHoverExpandsWithCustomisableMods() } [Test] - public void TestExpandedStatePersistsWhenClicked() + public void TestHoverExpandsAndCollapsesWhenHeaderTouched() { AddStep("add customisable mod", () => { @@ -128,34 +129,20 @@ public void TestExpandedStatePersistsWhenClicked() panel.Enabled.Value = true; }); - AddStep("hover header", () => InputManager.MoveMouseTo(header)); - checkExpanded(true); - - AddStep("click", () => InputManager.Click(MouseButton.Left)); - checkExpanded(false); - AddStep("click", () => InputManager.Click(MouseButton.Left)); - checkExpanded(true); - - AddStep("move away", () => InputManager.MoveMouseTo(Vector2.One)); - checkExpanded(true); - - AddStep("click", () => InputManager.Click(MouseButton.Left)); - checkExpanded(false); - } - - [Test] - public void TestHoverExpandsAndCollapsesWhenHeaderClicked() - { - AddStep("add customisable mod", () => + AddStep("touch header", () => { - SelectedMods.Value = new[] { new OsuModDoubleTime() }; - panel.Enabled.Value = true; + var touch = new Touch(TouchSource.Touch1, header.ScreenSpaceDrawQuad.Centre); + InputManager.BeginTouch(touch); + Schedule(() => InputManager.EndTouch(touch)); }); - - AddStep("hover header", () => InputManager.MoveMouseTo(header)); checkExpanded(true); - AddStep("click", () => InputManager.Click(MouseButton.Left)); + AddStep("touch away from header", () => + { + var touch = new Touch(TouchSource.Touch1, header.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)); + InputManager.BeginTouch(touch); + Schedule(() => InputManager.EndTouch(touch)); + }); checkExpanded(false); } diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index f21c64f7fea7..280497e861d9 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -241,12 +241,8 @@ public void TestCustomisationToggleState() AddStep("select difficulty adjust via panel", () => getPanelForMod(typeof(OsuModDifficultyAdjust)).TriggerClick()); assertCustomisationToggleState(disabled: false, active: true); - AddStep("dismiss mod customisation via toggle", () => - { - InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType().Single()); - InputManager.Click(MouseButton.Left); - }); - assertCustomisationToggleState(disabled: false, active: false); + AddStep("move mouse away", () => InputManager.MoveMouseTo(Vector2.Zero)); + assertCustomisationToggleState(disabled: false, active: true); AddStep("reset mods", () => SelectedMods.SetDefault()); AddStep("select difficulty adjust via panel", () => getPanelForMod(typeof(OsuModDifficultyAdjust)).TriggerClick()); @@ -664,7 +660,7 @@ public void TestTextSearchDoesNotBlockCustomisationPanelKeyboardInteractions() AddStep("select DT", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime() }); AddAssert("DT selected", () => modSelectOverlay.ChildrenOfType().Count(panel => panel.Active.Value), () => Is.EqualTo(1)); - AddStep("open customisation area", () => modSelectOverlay.ChildrenOfType().Single().TriggerClick()); + AddStep("open customisation area", () => InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType().Single())); assertCustomisationToggleState(disabled: false, active: true); AddStep("hover over mod settings slider", () => @@ -976,7 +972,7 @@ public void TestCustomisationPanelAbsorbsInput([Values] bool textSearchStartsAct createScreen(); AddStep("select DT", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime() }); - AddStep("open customisation panel", () => this.ChildrenOfType().Single().TriggerClick()); + AddStep("open customisation panel", () => InputManager.MoveMouseTo(this.ChildrenOfType().Single())); AddAssert("search lost focus", () => !this.ChildrenOfType().Single().HasFocus); AddStep("press tab", () => InputManager.Key(Key.Tab)); @@ -991,15 +987,13 @@ public void TestCustomisationPanelAbsorbsInput([Values] bool textSearchStartsAct AddStep("press backspace", () => InputManager.Key(Key.BackSpace)); AddAssert("mods not deselected", () => SelectedMods.Value.Single() is OsuModDoubleTime); - AddStep("move mouse to scroll bar", () => InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType().Single().ScreenSpaceDrawQuad.BottomLeft + new Vector2(10f, -5f))); + AddStep("move mouse to customisation panel", () => InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType().First())); AddStep("scroll down", () => InputManager.ScrollVerticalBy(-10f)); AddAssert("column not scrolled", () => modSelectOverlay.ChildrenOfType().Single().IsScrolledToStart()); - AddStep("press mouse", () => InputManager.PressButton(MouseButton.Left)); - AddAssert("search still not focused", () => !this.ChildrenOfType().Single().HasFocus); - AddStep("release mouse", () => InputManager.ReleaseButton(MouseButton.Left)); - AddAssert("customisation panel closed by click", + AddStep("move mouse away", () => InputManager.MoveMouseTo(Vector2.Zero)); + AddAssert("customisation panel closed", () => this.ChildrenOfType().Single().ExpandedState.Value, () => Is.EqualTo(ModCustomisationPanel.ModCustomisationPanelState.Collapsed)); diff --git a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs index abd48a0dcb27..32fd5a37aa54 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs @@ -112,40 +112,10 @@ protected override void LoadComplete() }, true); } - protected override bool OnClick(ClickEvent e) - { - if (Enabled.Value) - { - ExpandedState.Value = ExpandedState.Value switch - { - ModCustomisationPanelState.Collapsed => ModCustomisationPanelState.Expanded, - _ => ModCustomisationPanelState.Collapsed - }; - } - - return base.OnClick(e); - } - - private bool touchedThisFrame; - - protected override bool OnTouchDown(TouchDownEvent e) - { - if (Enabled.Value) - { - touchedThisFrame = true; - Schedule(() => touchedThisFrame = false); - } - - return base.OnTouchDown(e); - } - protected override bool OnHover(HoverEvent e) { - if (Enabled.Value) - { - if (!touchedThisFrame && panel.ExpandedState.Value == ModCustomisationPanelState.Collapsed) - panel.ExpandedState.Value = ModCustomisationPanelState.ExpandedByHover; - } + if (Enabled.Value && panel.ExpandedState.Value == ModCustomisationPanelState.Collapsed) + panel.ExpandedState.Value = ModCustomisationPanelState.Expanded; return base.OnHover(e); } diff --git a/osu.Game/Overlays/Mods/ModCustomisationPanel.cs b/osu.Game/Overlays/Mods/ModCustomisationPanel.cs index 522481bc6bb5..03a1b3d0dd5a 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationPanel.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationPanel.cs @@ -227,7 +227,7 @@ protected override void Update() { base.Update(); - if (ExpandedState.Value == ModCustomisationPanelState.ExpandedByHover + if (ExpandedState.Value == ModCustomisationPanelState.Expanded && !ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position) && inputManager.DraggedDrawable == null) { @@ -239,8 +239,8 @@ protected override void Update() public enum ModCustomisationPanelState { Collapsed = 0, - ExpandedByHover = 1, - Expanded = 2, + Expanded = 1, + ExpandedByMod = 2, } } } diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 74890df5d937..cdc0fbbd964e 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -368,7 +368,7 @@ private void updateCustomisation() customisationPanel.Enabled.Value = true; if (anyModPendingConfiguration) - customisationPanel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.Expanded; + customisationPanel.ExpandedState.Value = ModCustomisationPanel.ModCustomisationPanelState.ExpandedByMod; } else {