From 11e7c8be3f3f3da461a65a22d1be2b5ec8017a7d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 20 Jan 2020 08:34:46 +0300 Subject: [PATCH] Use colour schemes for OverlayRulesetSelector --- .../Online/TestSceneProfileRulesetSelector.cs | 3 +- .../TestSceneOverlayRulesetSelector.cs | 28 ++++++++++--------- osu.Game/Overlays/OverlayRulesetSelector.cs | 9 ++++-- .../Components/ProfileRulesetSelector.cs | 7 ++--- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs index a36b6880d2..1a9dca51c9 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs @@ -11,6 +11,7 @@ using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Taiko; using osu.Game.Users; using osu.Framework.Bindables; +using osu.Game.Graphics; namespace osu.Game.Tests.Visual.Online { @@ -27,7 +28,7 @@ namespace osu.Game.Tests.Visual.Online ProfileRulesetSelector selector; var user = new Bindable(); - Child = selector = new ProfileRulesetSelector + Child = selector = new ProfileRulesetSelector(OverlayColourScheme.Green) { 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 93aa414c94..bc5f66da0b 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayRulesetSelector.cs @@ -13,7 +13,8 @@ using osu.Game.Overlays; using osu.Game.Rulesets; using NUnit.Framework; using osu.Game.Graphics; -using osu.Framework.Allocation; +using osu.Framework.Graphics.Containers; +using osuTK; namespace osu.Game.Tests.Visual.UserInterface { @@ -25,19 +26,27 @@ namespace osu.Game.Tests.Visual.UserInterface typeof(OverlayRulesetTabItem), }; - [Resolved] - private OsuColour colours { get; set; } - private readonly OverlayRulesetSelector selector; private readonly Bindable ruleset = new Bindable(); public TestSceneOverlayRulesetSelector() { - Add(selector = new OverlayRulesetSelector + Add(new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Current = ruleset, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + 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 } + } }); } @@ -56,12 +65,5 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("Select catch", () => ruleset.Value = new CatchRuleset().RulesetInfo); AddAssert("Check catch selected", () => selector.Current.Value.Equals(new CatchRuleset().RulesetInfo)); } - - [Test] - public void TestColours() - { - AddStep("Set colour to blue", () => selector.AccentColour = colours.Blue); - AddAssert("Check colour is blue", () => selector.AccentColour == colours.Blue); - } } } diff --git a/osu.Game/Overlays/OverlayRulesetSelector.cs b/osu.Game/Overlays/OverlayRulesetSelector.cs index da49335250..b70d6a08f2 100644 --- a/osu.Game/Overlays/OverlayRulesetSelector.cs +++ b/osu.Game/Overlays/OverlayRulesetSelector.cs @@ -28,16 +28,19 @@ namespace osu.Game.Overlays } } - public OverlayRulesetSelector() + protected OverlayColourScheme ColourScheme { get; } + + public OverlayRulesetSelector(OverlayColourScheme colourScheme) { + ColourScheme = colourScheme; + AutoSizeAxes = Axes.Both; } [BackgroundDependencyLoader] private void load(OsuColour colours) { - if (accentColour == default) - AccentColour = colours.Pink; + AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.7f); } 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 e63102f989..f7e8d4b1f5 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.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.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; @@ -14,16 +13,14 @@ namespace osu.Game.Overlays.Profile.Header.Components { public readonly Bindable User = new Bindable(); - [BackgroundDependencyLoader] - private void load(OsuColour colours) + public ProfileRulesetSelector(OverlayColourScheme colourScheme) + : base(colourScheme) { - AccentColour = colours.Seafoam; } protected override void LoadComplete() { base.LoadComplete(); - User.BindValueChanged(u => SetDefaultRuleset(Rulesets.GetRuleset(u.NewValue?.PlayMode ?? "osu")), true); }