From e5548a12161afb7bf77c67f3cb68bcd662b61998 Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Mon, 12 Oct 2020 00:16:18 +0200 Subject: [PATCH 1/9] Move ModSettingsContainer class inside ModSelectOverlay --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 4eb4fc6501..3b158ee98d 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -284,7 +284,7 @@ namespace osu.Game.Overlays.Mods }, }, }, - ModSettingsContainer = new Container + ModSettingsContainer = new CModSettingsContainer { RelativeSizeAxes = Axes.Both, Anchor = Anchor.BottomRight, @@ -495,5 +495,19 @@ namespace osu.Game.Overlays.Mods } #endregion + + protected class CModSettingsContainer : Container + { + protected override bool OnMouseDown(MouseDownEvent e) + { + return true; + } + + protected override bool OnHover(HoverEvent e) + { + return true; + } + } + } } From 8768891b12a34c0473f460dea604ddb3d1747d2d Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Mon, 12 Oct 2020 14:41:05 +0200 Subject: [PATCH 2/9] Add testing for clicking mods through customisation menu --- .../UserInterface/TestSceneModSettings.cs | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs index c5ce3751ef..d4c8b850d3 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs @@ -18,10 +18,11 @@ using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.UI; +using osuTK.Input; namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneModSettings : OsuTestScene + public class TestSceneModSettings : OsuManualInputManagerTestScene { private TestModSelectOverlay modSelect; @@ -29,6 +30,8 @@ namespace osu.Game.Tests.Visual.UserInterface private readonly Mod testCustomisableAutoOpenMod = new TestModCustomisable2(); + private readonly Mod testCustomisableMenuCoveredMod = new TestModCustomisable1(); + [SetUp] public void SetUp() => Schedule(() => { @@ -95,6 +98,30 @@ namespace osu.Game.Tests.Visual.UserInterface AddAssert("copy has original value", () => Precision.AlmostEquals(1.5, copy.SpeedChange.Value)); } + [Test] + public void TestCustomisationMenuNoClickthrough() + { + + createModSelect(); + openModSelect(); + + AddStep("change mod settings menu width to full screen", () => modSelect.SetModSettingsWidth(1.0f)); + AddStep("select cm2", () => modSelect.SelectMod(testCustomisableAutoOpenMod)); + AddAssert("Customisation opened", () => modSelect.ModSettingsContainer.Alpha == 1); + AddStep("hover over mod behind settings menu", () => InputManager.MoveMouseTo(modSelect.GetModButton(testCustomisableMenuCoveredMod))); + AddAssert("Mod is not considered hovered over", () => !modSelect.GetModButton(testCustomisableMenuCoveredMod).IsHovered); + AddStep("left click mod", () => InputManager.Click(MouseButton.Left)); + AddAssert("only cm2 is active", () => SelectedMods.Value.Count == 1); + AddStep("right click mod", () => InputManager.Click(MouseButton.Right)); + AddAssert("only cm2 is active", () => SelectedMods.Value.Count == 1); + } + + + + private void clickPosition(int x, int y) { + //Move cursor to coordinates + //Click coordinates + } private void createModSelect() { AddStep("create mod select", () => @@ -124,6 +151,19 @@ namespace osu.Game.Tests.Visual.UserInterface public void SelectMod(Mod mod) => ModSectionsContainer.Children.Single(s => s.ModType == mod.Type) .ButtonsContainer.OfType().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())).SelectNext(1); + + public ModButton GetModButton(Mod mod) + { + return ModSectionsContainer.Children.Single(s => s.ModType == mod.Type). + ButtonsContainer.OfType().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())); + } + + public float SetModSettingsWidth(float NewWidth) + { + float oldWidth = ModSettingsContainer.Width; + ModSettingsContainer.Width = NewWidth; + return oldWidth; + } } public class TestRulesetInfo : RulesetInfo From 7df9282727c6997ccccc0df7ee55e930ffb674fe Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Mon, 12 Oct 2020 15:58:34 +0200 Subject: [PATCH 3/9] CodeAnalysis fixes --- .../UserInterface/TestSceneModSettings.cs | 22 ++++++------------- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 1 - 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs index d4c8b850d3..a31e244ca5 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs @@ -101,7 +101,6 @@ namespace osu.Game.Tests.Visual.UserInterface [Test] public void TestCustomisationMenuNoClickthrough() { - createModSelect(); openModSelect(); @@ -116,12 +115,6 @@ namespace osu.Game.Tests.Visual.UserInterface AddAssert("only cm2 is active", () => SelectedMods.Value.Count == 1); } - - - private void clickPosition(int x, int y) { - //Move cursor to coordinates - //Click coordinates - } private void createModSelect() { AddStep("create mod select", () => @@ -148,20 +141,19 @@ namespace osu.Game.Tests.Visual.UserInterface public bool ButtonsLoaded => ModSectionsContainer.Children.All(c => c.ModIconsLoaded); - public void SelectMod(Mod mod) => - ModSectionsContainer.Children.Single(s => s.ModType == mod.Type) - .ButtonsContainer.OfType().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())).SelectNext(1); - public ModButton GetModButton(Mod mod) { - return ModSectionsContainer.Children.Single(s => s.ModType == mod.Type). - ButtonsContainer.OfType().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())); + return ModSectionsContainer.Children.Single(s => s.ModType == mod.Type) + .ButtonsContainer.OfType().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())); } - public float SetModSettingsWidth(float NewWidth) + public void SelectMod(Mod mod) => + GetModButton(mod).SelectNext(1); + + public float SetModSettingsWidth(float newWidth) { float oldWidth = ModSettingsContainer.Width; - ModSettingsContainer.Width = NewWidth; + ModSettingsContainer.Width = newWidth; return oldWidth; } } diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 3b158ee98d..37541358b8 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -508,6 +508,5 @@ namespace osu.Game.Overlays.Mods return true; } } - } } From 1a85123b890c8630459561c80095bba22e1df7de Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Mon, 12 Oct 2020 21:24:42 +0200 Subject: [PATCH 4/9] rename container class to be more descriptive --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 37541358b8..f74f40b9b4 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -284,7 +284,7 @@ namespace osu.Game.Overlays.Mods }, }, }, - ModSettingsContainer = new CModSettingsContainer + ModSettingsContainer = new MouseInputAbsorbingContainer { RelativeSizeAxes = Axes.Both, Anchor = Anchor.BottomRight, @@ -496,17 +496,11 @@ namespace osu.Game.Overlays.Mods #endregion - protected class CModSettingsContainer : Container + protected class MouseInputAbsorbingContainer : Container { - protected override bool OnMouseDown(MouseDownEvent e) - { - return true; - } + protected override bool OnMouseDown(MouseDownEvent e) => true; - protected override bool OnHover(HoverEvent e) - { - return true; - } + protected override bool OnHover(HoverEvent e) => true; } } } From 663b8069746a5b79c1acc0b276a31be0e8710825 Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Tue, 13 Oct 2020 17:45:40 +0200 Subject: [PATCH 5/9] move ModSettingsContainer to seperate component --- .../Overlays/Mods/CModSettingsContainer.cs | 71 +++++++++++++++++++ osu.Game/Overlays/Mods/ModSelectOverlay.cs | 56 +-------------- 2 files changed, 74 insertions(+), 53 deletions(-) create mode 100644 osu.Game/Overlays/Mods/CModSettingsContainer.cs diff --git a/osu.Game/Overlays/Mods/CModSettingsContainer.cs b/osu.Game/Overlays/Mods/CModSettingsContainer.cs new file mode 100644 index 0000000000..a5f33e46c4 --- /dev/null +++ b/osu.Game/Overlays/Mods/CModSettingsContainer.cs @@ -0,0 +1,71 @@ +// 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 System.Linq; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; +using osu.Game.Configuration; +using osu.Game.Graphics.Containers; +using osu.Game.Rulesets.Mods; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.Mods +{ + public class CModSettingsContainer : Container + { + private readonly FillFlowContainer modSettingsContent; + + public CModSettingsContainer() + { + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(0, 0, 0, 192) + }, + new OsuScrollContainer + { + RelativeSizeAxes = Axes.Both, + Child = modSettingsContent = new FillFlowContainer + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(0f, 10f), + Padding = new MarginPadding(20), + } + } + }; + } + + ///Bool indicating whether any settings are listed + public bool UpdateModSettings(ValueChangedEvent> mods) + { + modSettingsContent.Clear(); + + foreach (var mod in mods.NewValue) + { + var settings = mod.CreateSettingsControls().ToList(); + if (settings.Count > 0) + modSettingsContent.Add(new ModControlSection(mod, settings)); + } + + bool hasSettings = modSettingsContent.Count > 0; + + if (!hasSettings) + Hide(); + + return hasSettings; + } + + protected override bool OnMouseDown(MouseDownEvent e) => true; + protected override bool OnHover(HoverEvent e) => true; + } +} diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index f74f40b9b4..b9a37094d7 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -13,7 +13,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; -using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; @@ -45,9 +44,7 @@ namespace osu.Game.Overlays.Mods protected readonly FillFlowContainer ModSectionsContainer; - protected readonly FillFlowContainer ModSettingsContent; - - protected readonly Container ModSettingsContainer; + protected readonly CModSettingsContainer ModSettingsContainer; public readonly Bindable> SelectedMods = new Bindable>(Array.Empty()); @@ -284,7 +281,7 @@ namespace osu.Game.Overlays.Mods }, }, }, - ModSettingsContainer = new MouseInputAbsorbingContainer + ModSettingsContainer = new CModSettingsContainer { RelativeSizeAxes = Axes.Both, Anchor = Anchor.BottomRight, @@ -292,27 +289,6 @@ namespace osu.Game.Overlays.Mods Width = 0.25f, Alpha = 0, X = -100, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = new Color4(0, 0, 0, 192) - }, - new OsuScrollContainer - { - RelativeSizeAxes = Axes.Both, - Child = ModSettingsContent = new FillFlowContainer - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(0f, 10f), - Padding = new MarginPadding(20), - } - } - } } }; } @@ -424,7 +400,7 @@ namespace osu.Game.Overlays.Mods updateMods(); - updateModSettings(mods); + CustomiseButton.Enabled.Value = ModSettingsContainer.UpdateModSettings(mods); } private void updateMods() @@ -445,25 +421,6 @@ namespace osu.Game.Overlays.Mods MultiplierLabel.FadeColour(Color4.White, 200); } - private void updateModSettings(ValueChangedEvent> selectedMods) - { - ModSettingsContent.Clear(); - - foreach (var mod in selectedMods.NewValue) - { - var settings = mod.CreateSettingsControls().ToList(); - if (settings.Count > 0) - ModSettingsContent.Add(new ModControlSection(mod, settings)); - } - - bool hasSettings = ModSettingsContent.Count > 0; - - CustomiseButton.Enabled.Value = hasSettings; - - if (!hasSettings) - ModSettingsContainer.Hide(); - } - private void modButtonPressed(Mod selectedMod) { if (selectedMod != null) @@ -495,12 +452,5 @@ namespace osu.Game.Overlays.Mods } #endregion - - protected class MouseInputAbsorbingContainer : Container - { - protected override bool OnMouseDown(MouseDownEvent e) => true; - - protected override bool OnHover(HoverEvent e) => true; - } } } From 28d3295f9f25df1cf60f77dd42353ef736390d6f Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Tue, 13 Oct 2020 19:20:15 +0200 Subject: [PATCH 6/9] Test Class Fixes --- .../Visual/UserInterface/TestSceneModSettings.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs index a31e244ca5..6a46ff2666 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs @@ -9,6 +9,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Utils; +using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; @@ -30,8 +31,6 @@ namespace osu.Game.Tests.Visual.UserInterface private readonly Mod testCustomisableAutoOpenMod = new TestModCustomisable2(); - private readonly Mod testCustomisableMenuCoveredMod = new TestModCustomisable1(); - [SetUp] public void SetUp() => Schedule(() => { @@ -107,8 +106,8 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("change mod settings menu width to full screen", () => modSelect.SetModSettingsWidth(1.0f)); AddStep("select cm2", () => modSelect.SelectMod(testCustomisableAutoOpenMod)); AddAssert("Customisation opened", () => modSelect.ModSettingsContainer.Alpha == 1); - AddStep("hover over mod behind settings menu", () => InputManager.MoveMouseTo(modSelect.GetModButton(testCustomisableMenuCoveredMod))); - AddAssert("Mod is not considered hovered over", () => !modSelect.GetModButton(testCustomisableMenuCoveredMod).IsHovered); + AddStep("hover over mod behind settings menu", () => InputManager.MoveMouseTo(modSelect.GetModButton(testCustomisableMod))); + AddAssert("Mod is not considered hovered over", () => !modSelect.GetModButton(testCustomisableMod).IsHovered); AddStep("left click mod", () => InputManager.Click(MouseButton.Left)); AddAssert("only cm2 is active", () => SelectedMods.Value.Count == 1); AddStep("right click mod", () => InputManager.Click(MouseButton.Right)); @@ -143,19 +142,14 @@ namespace osu.Game.Tests.Visual.UserInterface public ModButton GetModButton(Mod mod) { - return ModSectionsContainer.Children.Single(s => s.ModType == mod.Type) - .ButtonsContainer.OfType().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())); + return ModSectionsContainer.ChildrenOfType().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType())); } public void SelectMod(Mod mod) => GetModButton(mod).SelectNext(1); - public float SetModSettingsWidth(float newWidth) - { - float oldWidth = ModSettingsContainer.Width; + public void SetModSettingsWidth(float newWidth) => ModSettingsContainer.Width = newWidth; - return oldWidth; - } } public class TestRulesetInfo : RulesetInfo From 3fd913b13f5a4b317aa5edd45b5cf00de6d45b21 Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Tue, 13 Oct 2020 19:25:42 +0200 Subject: [PATCH 7/9] rename customisation container class --- ...{CModSettingsContainer.cs => ModCustomisationContainer.cs} | 4 ++-- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename osu.Game/Overlays/Mods/{CModSettingsContainer.cs => ModCustomisationContainer.cs} (95%) diff --git a/osu.Game/Overlays/Mods/CModSettingsContainer.cs b/osu.Game/Overlays/Mods/ModCustomisationContainer.cs similarity index 95% rename from osu.Game/Overlays/Mods/CModSettingsContainer.cs rename to osu.Game/Overlays/Mods/ModCustomisationContainer.cs index a5f33e46c4..487d92882a 100644 --- a/osu.Game/Overlays/Mods/CModSettingsContainer.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationContainer.cs @@ -16,11 +16,11 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Mods { - public class CModSettingsContainer : Container + public class ModCustomisationContainer : Container { private readonly FillFlowContainer modSettingsContent; - public CModSettingsContainer() + public ModCustomisationContainer() { Children = new Drawable[] { diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index b9a37094d7..b1ffd26bb9 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Mods protected readonly FillFlowContainer ModSectionsContainer; - protected readonly CModSettingsContainer ModSettingsContainer; + protected readonly ModCustomisationContainer ModSettingsContainer; public readonly Bindable> SelectedMods = new Bindable>(Array.Empty()); @@ -281,7 +281,7 @@ namespace osu.Game.Overlays.Mods }, }, }, - ModSettingsContainer = new CModSettingsContainer + ModSettingsContainer = new ModCustomisationContainer { RelativeSizeAxes = Axes.Both, Anchor = Anchor.BottomRight, From 24eff8c66d8aab85a6509f9ea095c13cd5e8a09e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 14 Oct 2020 15:13:49 +0900 Subject: [PATCH 8/9] Rename container to match "settings" term used everywhere --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 4 ++-- .../{ModCustomisationContainer.cs => ModSettingsContainer.cs} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename osu.Game/Overlays/Mods/{ModCustomisationContainer.cs => ModSettingsContainer.cs} (95%) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index b1ffd26bb9..2d8b4dba7c 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Mods protected readonly FillFlowContainer ModSectionsContainer; - protected readonly ModCustomisationContainer ModSettingsContainer; + protected readonly ModSettingsContainer ModSettingsContainer; public readonly Bindable> SelectedMods = new Bindable>(Array.Empty()); @@ -281,7 +281,7 @@ namespace osu.Game.Overlays.Mods }, }, }, - ModSettingsContainer = new ModCustomisationContainer + ModSettingsContainer = new ModSettingsContainer { RelativeSizeAxes = Axes.Both, Anchor = Anchor.BottomRight, diff --git a/osu.Game/Overlays/Mods/ModCustomisationContainer.cs b/osu.Game/Overlays/Mods/ModSettingsContainer.cs similarity index 95% rename from osu.Game/Overlays/Mods/ModCustomisationContainer.cs rename to osu.Game/Overlays/Mods/ModSettingsContainer.cs index 487d92882a..0521bc35b8 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationContainer.cs +++ b/osu.Game/Overlays/Mods/ModSettingsContainer.cs @@ -16,11 +16,11 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Mods { - public class ModCustomisationContainer : Container + public class ModSettingsContainer : Container { private readonly FillFlowContainer modSettingsContent; - public ModCustomisationContainer() + public ModSettingsContainer() { Children = new Drawable[] { From 3e326a9234cb99d743f8ae80de42d85b4a43428c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 14 Oct 2020 15:21:28 +0900 Subject: [PATCH 9/9] Use bindable flow for event propagation --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 5 +++-- .../Overlays/Mods/ModSettingsContainer.cs | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 2d8b4dba7c..31adf47456 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -289,8 +289,11 @@ namespace osu.Game.Overlays.Mods Width = 0.25f, Alpha = 0, X = -100, + SelectedMods = { BindTarget = SelectedMods }, } }; + + ((IBindable)CustomiseButton.Enabled).BindTo(ModSettingsContainer.HasSettingsForSelection); } [BackgroundDependencyLoader(true)] @@ -399,8 +402,6 @@ namespace osu.Game.Overlays.Mods section.SelectTypes(mods.NewValue.Select(m => m.GetType()).ToList()); updateMods(); - - CustomiseButton.Enabled.Value = ModSettingsContainer.UpdateModSettings(mods); } private void updateMods() diff --git a/osu.Game/Overlays/Mods/ModSettingsContainer.cs b/osu.Game/Overlays/Mods/ModSettingsContainer.cs index 0521bc35b8..b185b56ecd 100644 --- a/osu.Game/Overlays/Mods/ModSettingsContainer.cs +++ b/osu.Game/Overlays/Mods/ModSettingsContainer.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; using System.Collections.Generic; using System.Linq; using osu.Framework.Bindables; @@ -18,6 +19,12 @@ namespace osu.Game.Overlays.Mods { public class ModSettingsContainer : Container { + public readonly IBindable> SelectedMods = new Bindable>(Array.Empty()); + + public IBindable HasSettingsForSelection => hasSettingsForSelection; + + private readonly Bindable hasSettingsForSelection = new Bindable(); + private readonly FillFlowContainer modSettingsContent; public ModSettingsContainer() @@ -45,8 +52,14 @@ namespace osu.Game.Overlays.Mods }; } - ///Bool indicating whether any settings are listed - public bool UpdateModSettings(ValueChangedEvent> mods) + protected override void LoadComplete() + { + base.LoadComplete(); + + SelectedMods.BindValueChanged(modsChanged, true); + } + + private void modsChanged(ValueChangedEvent> mods) { modSettingsContent.Clear(); @@ -62,7 +75,7 @@ namespace osu.Game.Overlays.Mods if (!hasSettings) Hide(); - return hasSettings; + hasSettingsForSelection.Value = hasSettings; } protected override bool OnMouseDown(MouseDownEvent e) => true;