mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 18:33:20 +08:00
Use colour schemes for OverlayRulesetSelector
This commit is contained in:
parent
6552097866
commit
11e7c8be3f
@ -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<User>();
|
||||
|
||||
Child = selector = new ProfileRulesetSelector
|
||||
Child = selector = new ProfileRulesetSelector(OverlayColourScheme.Green)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -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<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<RulesetInfo> CreateTabItem(RulesetInfo value) => new OverlayRulesetTabItem(value);
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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> User = new Bindable<User>();
|
||||
|
||||
[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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user