diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs index 1a9dca51c9..826624f686 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs @@ -11,7 +11,8 @@ using osu.Game.Rulesets.Taiko; using osu.Game.Users; using osu.Framework.Bindables; -using osu.Game.Graphics; +using osu.Game.Overlays; +using osu.Framework.Allocation; namespace osu.Game.Tests.Visual.Online { @@ -23,12 +24,15 @@ public class TestSceneProfileRulesetSelector : OsuTestScene typeof(ProfileRulesetTabItem), }; + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green); + public TestSceneProfileRulesetSelector() { ProfileRulesetSelector selector; var user = new Bindable(); - Child = selector = new ProfileRulesetSelector(OverlayColourScheme.Green) + Child = selector = new ProfileRulesetSelector { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs index bc5f66da0b..8a98127793 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs @@ -12,9 +12,9 @@ using osu.Game.Overlays; using osu.Game.Rulesets; using NUnit.Framework; -using osu.Game.Graphics; using osu.Framework.Graphics.Containers; using osuTK; +using osu.Framework.Allocation; namespace osu.Game.Tests.Visual.UserInterface { @@ -40,16 +40,29 @@ public TestSceneOverlayRulesetSelector() Spacing = new Vector2(0, 5), Children = new[] { - selector = new OverlayRulesetSelector(OverlayColourScheme.Green) { Current = ruleset }, - new OverlayRulesetSelector(OverlayColourScheme.Blue) { Current = ruleset }, - new OverlayRulesetSelector(OverlayColourScheme.Orange) { Current = ruleset }, - new OverlayRulesetSelector(OverlayColourScheme.Pink) { Current = ruleset }, - new OverlayRulesetSelector(OverlayColourScheme.Purple) { Current = ruleset }, - new OverlayRulesetSelector(OverlayColourScheme.Red) { Current = ruleset } + new ColourProvidedContainer(OverlayColourScheme.Green, selector = new OverlayRulesetSelector { Current = ruleset }), + new ColourProvidedContainer(OverlayColourScheme.Blue, new OverlayRulesetSelector { Current = ruleset }), + new ColourProvidedContainer(OverlayColourScheme.Orange, new OverlayRulesetSelector { Current = ruleset }), + new ColourProvidedContainer(OverlayColourScheme.Pink, new OverlayRulesetSelector { Current = ruleset }), + new ColourProvidedContainer(OverlayColourScheme.Purple, new OverlayRulesetSelector { Current = ruleset }), + new ColourProvidedContainer(OverlayColourScheme.Red, new OverlayRulesetSelector { Current = ruleset }), } }); } + private class ColourProvidedContainer : Container + { + [Cached] + private readonly OverlayColourProvider colourProvider; + + public ColourProvidedContainer(OverlayColourScheme colourScheme, OverlayRulesetSelector rulesetSelector) + { + colourProvider = new OverlayColourProvider(colourScheme); + AutoSizeAxes = Axes.Both; + Add(rulesetSelector); + } + } + [Test] public void TestSelection() { diff --git a/osu.Game/Overlays/OverlayRulesetSelector.cs b/osu.Game/Overlays/OverlayRulesetSelector.cs index b70d6a08f2..0c87686f6f 100644 --- a/osu.Game/Overlays/OverlayRulesetSelector.cs +++ b/osu.Game/Overlays/OverlayRulesetSelector.cs @@ -28,19 +28,15 @@ public Color4 AccentColour } } - protected OverlayColourScheme ColourScheme { get; } - - public OverlayRulesetSelector(OverlayColourScheme colourScheme) + public OverlayRulesetSelector() { - ColourScheme = colourScheme; - AutoSizeAxes = Axes.Both; } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { - AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.7f); + AccentColour = colourProvider.Highlight1; } protected override TabItem CreateTabItem(RulesetInfo value) => new OverlayRulesetTabItem(value); diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs index f7e8d4b1f5..41a3ee8ad6 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs @@ -3,7 +3,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Rulesets; using osu.Game.Users; @@ -13,11 +12,6 @@ public class ProfileRulesetSelector : OverlayRulesetSelector { public readonly Bindable User = new Bindable(); - public ProfileRulesetSelector(OverlayColourScheme colourScheme) - : base(colourScheme) - { - } - protected override void LoadComplete() { base.LoadComplete();