From be0e2efda2b37a31abc5318303b418709856ceb1 Mon Sep 17 00:00:00 2001 From: Fabep Date: Wed, 28 Aug 2024 09:51:17 +0200 Subject: [PATCH 1/8] Removed on click event for expanding the Mod Customisation Header. --- osu.Game/Overlays/Mods/ModCustomisationHeader.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs index abd48a0dcb27..57fe99ce4ae5 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs @@ -112,20 +112,6 @@ 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) From 6adaf6a41faeeb09e9f53993c6ac2b91e9c9a0bf Mon Sep 17 00:00:00 2001 From: Fabep Date: Wed, 28 Aug 2024 10:09:47 +0200 Subject: [PATCH 2/8] Changed ModCustomisationPanelState names --- .../Visual/UserInterface/TestSceneModCustomisationPanel.cs | 6 +++--- osu.Game/Overlays/Mods/ModCustomisationHeader.cs | 2 +- osu.Game/Overlays/Mods/ModCustomisationPanel.cs | 6 +++--- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs index 0d8ea0561200..d93f62935a1a 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs @@ -58,19 +58,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", () => { diff --git a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs index 57fe99ce4ae5..5ddcf01b88be 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs @@ -130,7 +130,7 @@ protected override bool OnHover(HoverEvent e) if (Enabled.Value) { if (!touchedThisFrame && panel.ExpandedState.Value == ModCustomisationPanelState.Collapsed) - panel.ExpandedState.Value = ModCustomisationPanelState.ExpandedByHover; + 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 { From 10901075bef07ba3abba1a22c0166a5bcd23c6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 2 Sep 2024 11:27:44 +0200 Subject: [PATCH 3/8] Modify existing test coverage to demonstrate failure with touch --- .../TestSceneModCustomisationPanel.cs | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModCustomisationPanel.cs index d93f62935a1a..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; @@ -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); } From 5211e606b5b0c9919a2675c09a263ec88acb8c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 2 Sep 2024 11:33:43 +0200 Subject: [PATCH 4/8] Fix mod customisation header being non-functional on mobile As expected the previous touch handling would prevent the header from working entirely when click handling was removed from the header. --- .../Overlays/Mods/ModCustomisationHeader.cs | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs index 5ddcf01b88be..32fd5a37aa54 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs @@ -112,26 +112,10 @@ protected override void LoadComplete() }, true); } - 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.Expanded; - } + if (Enabled.Value && panel.ExpandedState.Value == ModCustomisationPanelState.Collapsed) + panel.ExpandedState.Value = ModCustomisationPanelState.Expanded; return base.OnHover(e); } From 16c2c140377286c2a90430d23a37e5c7da43cc34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 2 Sep 2024 14:45:29 +0200 Subject: [PATCH 5/8] Adjust tests further to match new UX --- .../TestSceneModSelectOverlay.cs | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) 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)); From e3457d850157808928b7ef912b8ecc562826f5a2 Mon Sep 17 00:00:00 2001 From: Fabep Date: Mon, 2 Sep 2024 19:14:08 +0200 Subject: [PATCH 6/8] Mod customisation header's color is now based on the state of the panel rather than the hover of the container. --- .../Overlays/Mods/ModCustomisationHeader.cs | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs index 32fd5a37aa54..d8191f5ba5b8 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; @@ -20,7 +19,7 @@ namespace osu.Game.Overlays.Mods { - public partial class ModCustomisationHeader : OsuHoverContainer + public partial class ModCustomisationHeader : OsuClickableContainer { private Box background = null!; private Box backgroundFlash = null!; @@ -29,8 +28,6 @@ public partial class ModCustomisationHeader : OsuHoverContainer [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; - protected override IEnumerable EffectTargets => new[] { background }; - public readonly Bindable ExpandedState = new Bindable(ModCustomisationPanelState.Collapsed); private readonly ModCustomisationPanel panel; @@ -52,6 +49,7 @@ private void load() background = new Box { RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Dark3, }, backgroundFlash = new Box { @@ -84,9 +82,6 @@ private void load() } } }; - - IdleColour = colourProvider.Dark3; - HoverColour = colourProvider.Light4; } protected override void LoadComplete() @@ -110,6 +105,20 @@ protected override void LoadComplete() { icon.ScaleTo(v.NewValue > ModCustomisationPanelState.Collapsed ? new Vector2(1, -1) : Vector2.One, 300, Easing.OutQuint); }, true); + + panel.ExpandedState.BindValueChanged(v => + { + switch (v.NewValue) + { + case ModCustomisationPanelState.Expanded: + case ModCustomisationPanelState.ExpandedByMod: + fadeBackgroundColor(colourProvider.Light4); + break; + default: + fadeBackgroundColor(colourProvider.Dark3); + break; + }; + }, false); } protected override bool OnHover(HoverEvent e) @@ -119,5 +128,10 @@ protected override bool OnHover(HoverEvent e) return base.OnHover(e); } + + private void fadeBackgroundColor(Color4 color) + { + background.FadeColour(color, 500, Easing.OutQuint); + } } } From 582ffcfc9722342f73d83778fc950cacc1bb9439 Mon Sep 17 00:00:00 2001 From: Fabep Date: Mon, 2 Sep 2024 19:17:07 +0200 Subject: [PATCH 7/8] Woopsie! I accidentally added one too many semi-colons, so I moved it here into the commit instead ; --- osu.Game/Overlays/Mods/ModCustomisationHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs index d8191f5ba5b8..da77d8dac8cb 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs @@ -117,7 +117,7 @@ protected override void LoadComplete() default: fadeBackgroundColor(colourProvider.Dark3); break; - }; + } }, false); } From 86309f4b4605b7ac82853006acf08bec8cb2a84f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 4 Sep 2024 17:25:36 +0900 Subject: [PATCH 8/8] Revert "Woopsie! I accidentally added one too many semi-colons, so I moved it here into the commit instead ;" This reverts commit 582ffcfc9722342f73d83778fc950cacc1bb9439. Revert "Mod customisation header's color is now based on the state of the panel rather than the hover of the container." This reverts commit e3457d850157808928b7ef912b8ecc562826f5a2. --- .../Overlays/Mods/ModCustomisationHeader.cs | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs index da77d8dac8cb..32fd5a37aa54 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; @@ -19,7 +20,7 @@ namespace osu.Game.Overlays.Mods { - public partial class ModCustomisationHeader : OsuClickableContainer + public partial class ModCustomisationHeader : OsuHoverContainer { private Box background = null!; private Box backgroundFlash = null!; @@ -28,6 +29,8 @@ public partial class ModCustomisationHeader : OsuClickableContainer [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; + protected override IEnumerable EffectTargets => new[] { background }; + public readonly Bindable ExpandedState = new Bindable(ModCustomisationPanelState.Collapsed); private readonly ModCustomisationPanel panel; @@ -49,7 +52,6 @@ private void load() background = new Box { RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Dark3, }, backgroundFlash = new Box { @@ -82,6 +84,9 @@ private void load() } } }; + + IdleColour = colourProvider.Dark3; + HoverColour = colourProvider.Light4; } protected override void LoadComplete() @@ -105,20 +110,6 @@ protected override void LoadComplete() { icon.ScaleTo(v.NewValue > ModCustomisationPanelState.Collapsed ? new Vector2(1, -1) : Vector2.One, 300, Easing.OutQuint); }, true); - - panel.ExpandedState.BindValueChanged(v => - { - switch (v.NewValue) - { - case ModCustomisationPanelState.Expanded: - case ModCustomisationPanelState.ExpandedByMod: - fadeBackgroundColor(colourProvider.Light4); - break; - default: - fadeBackgroundColor(colourProvider.Dark3); - break; - } - }, false); } protected override bool OnHover(HoverEvent e) @@ -128,10 +119,5 @@ protected override bool OnHover(HoverEvent e) return base.OnHover(e); } - - private void fadeBackgroundColor(Color4 color) - { - background.FadeColour(color, 500, Easing.OutQuint); - } } }