From 2e49b4ffcd8b6b03d2d8cc1e5db898f1db7081c2 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 26 Jun 2019 18:56:40 +0300 Subject: [PATCH] Update the component with an abstract RulesetSelector class --- .../Components/ProfileRulesetSelector.cs | 11 +---- .../Header/Components/RulesetTabItem.cs | 46 ++++++++++++------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs index b189878b0d..95065f2c72 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs @@ -12,10 +12,8 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Header.Components { - public class ProfileRulesetSelector : TabControl + public class ProfileRulesetSelector : RulesetSelector { - protected override Dropdown CreateDropdown() => null; - protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value) { AccentColour = AccentColour @@ -48,13 +46,8 @@ namespace osu.Game.Overlays.Profile.Header.Components } [BackgroundDependencyLoader] - private void load(RulesetStore rulesets, OsuColour colours) + private void load(OsuColour colours) { - foreach (var r in rulesets.AvailableRulesets) - { - AddItem(r); - } - AccentColour = colours.Seafoam; } diff --git a/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs index 0a6f2f5123..0c49b3179c 100644 --- a/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs @@ -94,7 +94,8 @@ namespace osu.Game.Overlays.Profile.Header.Components { base.OnHover(e); - updateState(); + if (!Active.Value) + hoverAction(); return true; } @@ -103,29 +104,40 @@ namespace osu.Game.Overlays.Profile.Header.Components { base.OnHoverLost(e); - updateState(); + if (!Active.Value) + unhoverAction(); } - protected override void OnActivated() => updateState(); + protected override void OnActivated() + { + hoverAction(); + text.Font = text.Font.With(weight: FontWeight.Bold); + } - protected override void OnDeactivated() => updateState(); + protected override void OnDeactivated() + { + unhoverAction(); + text.Font = text.Font.With(weight: FontWeight.Medium); + } private void updateState() { - if (Active.Value || IsHovered) - { - text.FadeColour(Color4.White, 120, Easing.InQuad); - icon.FadeColour(Color4.White, 120, Easing.InQuad); - - if (Active.Value) - text.Font = text.Font.With(weight: FontWeight.Bold); - } + if (Active.Value) + OnActivated(); else - { - text.FadeColour(AccentColour, 120, Easing.InQuad); - icon.FadeColour(AccentColour, 120, Easing.InQuad); - text.Font = text.Font.With(weight: FontWeight.Medium); - } + OnDeactivated(); + } + + private void hoverAction() + { + text.FadeColour(Color4.White, 120, Easing.InQuad); + icon.FadeColour(Color4.White, 120, Easing.InQuad); + } + + private void unhoverAction() + { + text.FadeColour(AccentColour, 120, Easing.InQuad); + icon.FadeColour(AccentColour, 120, Easing.InQuad); } } }