From 44141a38b8579cc0e5a9571ad60dac1bf8ba6ff5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 10 Oct 2017 18:04:41 +0900 Subject: [PATCH] Make it possible to change colours before load() --- osu.Game/Graphics/UserInterface/IconButton.cs | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 5e5bfad662..099423938a 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -17,10 +17,15 @@ namespace osu.Game.Graphics.UserInterface { private const float button_size = 30; + private Color4? flashColour; /// /// The colour that should be flashed when the is clicked. /// - public Color4 FlashColour; + public Color4 FlashColour + { + get { return flashColour ?? Color4.White; } + set { flashColour = value; } + } /// /// The icon colour. This does not affect . @@ -31,6 +36,20 @@ namespace osu.Game.Graphics.UserInterface set { icon.Colour = value; } } + private Color4? hoverColour; + /// + /// The background colour of the while it is hovered. + /// + public Color4 HoverColour + { + get { return hoverColour ?? Color4.White; } + set + { + hoverColour = value; + hover.Colour = value; + } + } + /// /// The icon. /// @@ -58,16 +77,6 @@ namespace osu.Game.Graphics.UserInterface set { content.Size = value; } } - /// - /// The background colour of the while it is hovered. - /// - /// - public Color4 HoverColour - { - get { return hover.Colour; } - set { hover.Colour = value; } - } - private readonly Container content; private readonly SpriteIcon icon; private readonly Box hover; @@ -112,8 +121,11 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(OsuColour colours) { - HoverColour = colours.Yellow.Opacity(0.6f); - FlashColour = colours.Yellow; + if (hoverColour == null) + hoverColour = colours.Yellow.Opacity(0.6f); + + if (flashColour == null) + flashColour = colours.Yellow; Enabled.ValueChanged += enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint); }