From 1d94c96a8efef24d5ae54aa7159f6e7a615a50a8 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 2 Jul 2024 14:40:00 +0300 Subject: [PATCH] Display customisation header in disabled state when no customisable mod selected --- .../UserInterface/TestSceneModSelectOverlay.cs | 2 +- osu.Game/Localisation/ModSelectOverlayStrings.cs | 5 +++++ osu.Game/Overlays/Mods/ModCustomisationHeader.cs | 15 +++++++++++++-- osu.Game/Overlays/Mods/ModCustomisationPanel.cs | 8 ++++++++ osu.Game/Overlays/Mods/ModSelectOverlay.cs | 5 +++-- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index 9f48b06bb6..21a5e3082b 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -1003,7 +1003,7 @@ namespace osu.Game.Tests.Visual.UserInterface private void assertCustomisationToggleState(bool disabled, bool active) { - AddUntilStep($"customisation panel is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.ChildrenOfType().Single().State.Value == (disabled ? Visibility.Hidden : Visibility.Visible)); + AddUntilStep($"customisation panel is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.ChildrenOfType().Single().Enabled.Value == !disabled); AddAssert($"customisation panel is {(active ? "" : "not ")}active", () => modSelectOverlay.ChildrenOfType().Single().Expanded.Value == active); } diff --git a/osu.Game/Localisation/ModSelectOverlayStrings.cs b/osu.Game/Localisation/ModSelectOverlayStrings.cs index a2e1df42c6..10037d30c3 100644 --- a/osu.Game/Localisation/ModSelectOverlayStrings.cs +++ b/osu.Game/Localisation/ModSelectOverlayStrings.cs @@ -80,6 +80,11 @@ namespace osu.Game.Localisation /// public static LocalisableString CustomisationPanelHeader => new TranslatableString(getKey(@"customisation_panel_header"), @"Customise"); + /// + /// "No mod selected which can be customised." + /// + public static LocalisableString CustomisationPanelDisabledReason => new TranslatableString(getKey(@"customisation_panel_disabled_reason"), @"No mod selected which can be customised."); + private static string getKey(string key) => $@"{prefix}:{key}"; } } diff --git a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs index e6534921f6..2887b53548 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationHeader.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationHeader.cs @@ -30,6 +30,12 @@ namespace osu.Game.Overlays.Mods public readonly BindableBool Expanded = new BindableBool(); + public ModCustomisationHeader() + { + Action = Expanded.Toggle; + Enabled.Value = false; + } + [BackgroundDependencyLoader] private void load() { @@ -75,12 +81,17 @@ namespace osu.Game.Overlays.Mods { base.LoadComplete(); + Enabled.BindValueChanged(e => + { + TooltipText = e.NewValue + ? string.Empty + : ModSelectOverlayStrings.CustomisationPanelDisabledReason; + }, true); + Expanded.BindValueChanged(v => { icon.RotateTo(v.NewValue ? 180 : 0); }, true); - - Action = Expanded.Toggle; } } } diff --git a/osu.Game/Overlays/Mods/ModCustomisationPanel.cs b/osu.Game/Overlays/Mods/ModCustomisationPanel.cs index a5a524e109..240569031c 100644 --- a/osu.Game/Overlays/Mods/ModCustomisationPanel.cs +++ b/osu.Game/Overlays/Mods/ModCustomisationPanel.cs @@ -33,6 +33,8 @@ namespace osu.Game.Overlays.Mods [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; + public readonly BindableBool Enabled = new BindableBool(); + public readonly BindableBool Expanded = new BindableBool(); public Bindable> SelectedMods { get; } = new Bindable>(Array.Empty()); @@ -55,6 +57,7 @@ namespace osu.Game.Overlays.Mods Depth = float.MinValue, RelativeSizeAxes = Axes.X, Height = header_height, + Enabled = { BindTarget = Enabled }, Expanded = { BindTarget = Expanded }, }, content = new FocusGrabbingContainer @@ -107,6 +110,11 @@ namespace osu.Game.Overlays.Mods { base.LoadComplete(); + Enabled.BindValueChanged(e => + { + this.FadeColour(OsuColour.Gray(e.NewValue ? 1f : 0.6f), 300, Easing.OutQuint); + }, true); + Expanded.BindValueChanged(_ => updateDisplay(), true); SelectedMods.BindValueChanged(_ => updateMods(), true); diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index b0d58480db..d5a4d27237 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -219,6 +219,7 @@ namespace osu.Game.Overlays.Mods Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Width = 400, + State = { Value = Visibility.Visible }, } } } @@ -493,7 +494,7 @@ namespace osu.Game.Overlays.Mods if (anyCustomisableModActive) { - customisationPanel.Show(); + customisationPanel.Enabled.Value = true; if (anyModPendingConfiguration) customisationPanel.Expanded.Value = true; @@ -501,7 +502,7 @@ namespace osu.Game.Overlays.Mods else { customisationPanel.Expanded.Value = false; - customisationPanel.Hide(); + customisationPanel.Enabled.Value = false; } }