From 87b8015e8f08a4836023382b5b5c024d7f3511d9 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 00:29:28 -0300 Subject: [PATCH] Cleanup --- .../UserInterface/OsuTabControlCheckBox.cs | 51 +++++++++++-------- osu.Game/Screens/Select/BeatmapDetailArea.cs | 10 ++-- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs index 7d86136fd5..dbdef991f7 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs @@ -22,22 +22,24 @@ namespace osu.Game.Graphics.UserInterface /// public class OsuTabControlCheckBox : CheckBox { - private const float transition_length = 500; + private Box box; + private SpriteText text; + private TextAwesome icon; public event EventHandler Action; - private Color4 accentColour; + private Color4? accentColour; public Color4 AccentColour { - get { return accentColour; } + get { return accentColour.GetValueOrDefault(); } set { accentColour = value; - if (State == CheckBoxState.Unchecked) + if (State != CheckBoxState.Checked) { - text.Colour = accentColour; - icon.Colour = accentColour; + text.Colour = AccentColour; + icon.Colour = AccentColour; } } } @@ -48,22 +50,6 @@ namespace osu.Game.Graphics.UserInterface set { text.Text = value; } } - private Box box; - private SpriteText text; - private TextAwesome icon; - - private void fadeIn() - { - box.FadeIn(transition_length, EasingTypes.OutQuint); - text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint); - } - - private void fadeOut() - { - box.FadeOut(transition_length, EasingTypes.OutQuint); - text.FadeColour(accentColour, transition_length, EasingTypes.OutQuint); - } - protected override void OnChecked() { fadeIn(); @@ -78,6 +64,20 @@ namespace osu.Game.Graphics.UserInterface Action?.Invoke(this, State); } + private const float transition_length = 500; + + private void fadeIn() + { + box.FadeIn(transition_length, EasingTypes.OutQuint); + text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint); + } + + private void fadeOut() + { + box.FadeOut(transition_length, EasingTypes.OutQuint); + text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint); + } + protected override bool OnHover(InputState state) { fadeIn(); @@ -92,6 +92,13 @@ namespace osu.Game.Graphics.UserInterface base.OnHoverLost(state); } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + if (accentColour == null) + AccentColour = colours.Blue; + } + public OsuTabControlCheckBox() { AutoSizeAxes = Axes.Both; diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index f576e47780..27706a4112 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -9,19 +9,23 @@ namespace osu.Game.Screens.Select { public class BeatmapDetailArea : Container { + private Container content; + protected override Container Content => content; + public BeatmapDetailArea() { - Children = new Drawable[] + AddInternal(new Drawable[] { new BeatmapDetailAreaTabControl { RelativeSizeAxes = Axes.X, }, - new Container + content = new Container { + RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT }, }, - }; + }); } } }