diff --git a/osu.Game/Overlays/OverlayRulesetSelector.cs b/osu.Game/Overlays/OverlayRulesetSelector.cs index 0c87686f6f..b73d38eeb3 100644 --- a/osu.Game/Overlays/OverlayRulesetSelector.cs +++ b/osu.Game/Overlays/OverlayRulesetSelector.cs @@ -1,44 +1,21 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Rulesets; using osuTK; -using osuTK.Graphics; -using System.Linq; namespace osu.Game.Overlays { public class OverlayRulesetSelector : RulesetSelector { - private Color4 accentColour; - - public Color4 AccentColour - { - get => accentColour; - set - { - accentColour = value; - foreach (var i in TabContainer.Children.OfType()) - i.AccentColour = value; - } - } - public OverlayRulesetSelector() { AutoSizeAxes = Axes.Both; } - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - AccentColour = colourProvider.Highlight1; - } - protected override TabItem CreateTabItem(RulesetInfo value) => new OverlayRulesetTabItem(value); protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index 91cf2d6b96..5b53d9d1fa 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -11,27 +11,31 @@ using osu.Game.Rulesets; using osuTK.Graphics; using osuTK; -using osu.Framework.Bindables; +using osu.Framework.Allocation; namespace osu.Game.Overlays { - public class OverlayRulesetTabItem : TabItem, IHasAccentColour + public class OverlayRulesetTabItem : TabItem { protected readonly OsuSpriteText Text; private readonly FillFlowContainer content; - public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree; + protected override Container Content => content; - private readonly Bindable accentColour = new Bindable(); - private readonly Bindable currentColour = new Bindable(); + private Color4 accentColour; - public Color4 AccentColour + protected virtual Color4 AccentColour { - get => accentColour.Value; - set => accentColour.Value = value; + get => accentColour; + set + { + accentColour = value; + Text.FadeColour(value, 120, Easing.OutQuint); + } } - protected override Container Content => content; + [Resolved] + private OverlayColourProvider colourProvider { get; set; } public OverlayRulesetTabItem(RulesetInfo value) : base(value) @@ -58,13 +62,10 @@ public OverlayRulesetTabItem(RulesetInfo value) Enabled.Value = true; } - protected override void LoadComplete() + [BackgroundDependencyLoader] + private void load() { - base.LoadComplete(); - - currentColour.BindValueChanged(OnCurrentColourChanged); - accentColour.BindValueChanged(_ => updateState()); - Enabled.BindValueChanged(_ => updateState(), true); + updateState(); } protected override bool OnHover(HoverEvent e) @@ -87,14 +88,7 @@ protected override void OnHoverLost(HoverLostEvent e) private void updateState() { Text.Font = Text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); - - currentColour.Value = IsHovered || Active.Value - ? Color4.White - : Enabled.Value - ? AccentColour - : Color4.DimGray; + AccentColour = IsHovered || Active.Value ? Color4.White : colourProvider.Highlight1; } - - protected virtual void OnCurrentColourChanged(ValueChangedEvent colour) => Text.FadeColour(colour.NewValue, 120, Easing.OutQuint); } } diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs index 038509d371..3d20fba542 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets; @@ -28,6 +27,16 @@ public bool IsDefault } } + protected override Color4 AccentColour + { + get => base.AccentColour; + set + { + base.AccentColour = value; + icon.FadeColour(value, 120, Easing.OutQuint); + } + } + private readonly SpriteIcon icon; public ProfileRulesetTabItem(RulesetInfo value) @@ -43,11 +52,5 @@ public ProfileRulesetTabItem(RulesetInfo value) Size = new Vector2(12), }); } - - protected override void OnCurrentColourChanged(ValueChangedEvent colour) - { - base.OnCurrentColourChanged(colour); - icon.FadeColour(colour.NewValue, 120, Easing.OutQuint); - } } }