1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Display customisation header in disabled state when no customisable mod selected

This commit is contained in:
Salman Ahmed 2024-07-02 14:40:00 +03:00
parent 901663b3ff
commit 1d94c96a8e
5 changed files with 30 additions and 5 deletions

View File

@ -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<ModCustomisationPanel>().Single().State.Value == (disabled ? Visibility.Hidden : Visibility.Visible));
AddUntilStep($"customisation panel is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Enabled.Value == !disabled);
AddAssert($"customisation panel is {(active ? "" : "not ")}active", () => modSelectOverlay.ChildrenOfType<ModCustomisationPanel>().Single().Expanded.Value == active);
}

View File

@ -80,6 +80,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString CustomisationPanelHeader => new TranslatableString(getKey(@"customisation_panel_header"), @"Customise");
/// <summary>
/// "No mod selected which can be customised."
/// </summary>
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}";
}
}

View File

@ -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;
}
}
}

View File

@ -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<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
@ -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);

View File

@ -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;
}
}