From b19405c98773152b02c636f03b67085748933067 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 7 Mar 2017 19:52:51 +0800 Subject: [PATCH] Allow null in mod list to generate a placeholder ModButton. --- osu.Game/Overlays/Mods/ModButton.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 9e810a52f9..49a9da868d 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -54,7 +54,8 @@ private int selectedIndex iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); foregroundIcon.Colour = Selected ? SelectedColour : ButtonColour; - displaySelectedMod(); + if (mod != null) + displayMod(SelectedMod ?? Mods[0]); } } @@ -102,10 +103,18 @@ public Mod Mod } set { - if (mod == value) return; mod = value; - Mods = (mod as MultiMod)?.Mods ?? new[] { mod }; + if (mod == null) + { + Mods = new Mod[0]; + Alpha = 0; + } + else + { + Mods = (mod as MultiMod)?.Mods ?? new[] { mod }; + Alpha = 1; + } createIcons(); if (Mods.Length > 0) @@ -165,8 +174,6 @@ private void displayMod(Mod mod) text.Text = mod.Name; } - private void displaySelectedMod() => displayMod(SelectedMod ?? Mods[0]); - private void createIcons() { iconsContainer.Clear(); @@ -216,6 +223,7 @@ public ModButton(Mod m) Direction = FillDirection.Vertical; Spacing = new Vector2(0f, -5f); Size = new Vector2(100f); + AlwaysPresent = true; Children = new Drawable[] {