2019-06-04 21:22:54 +08:00
|
|
|
|
// 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.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2019-06-05 00:33:55 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2019-06-04 21:22:54 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
|
|
|
|
{
|
2019-06-26 23:56:40 +08:00
|
|
|
|
public class ProfileRulesetSelector : RulesetSelector
|
2019-06-04 21:22:54 +08:00
|
|
|
|
{
|
|
|
|
|
private Color4 accentColour = Color4.White;
|
|
|
|
|
|
2019-06-07 06:43:26 +08:00
|
|
|
|
public ProfileRulesetSelector()
|
2019-06-04 21:22:54 +08:00
|
|
|
|
{
|
|
|
|
|
TabContainer.Masking = false;
|
2019-06-04 22:51:56 +08:00
|
|
|
|
TabContainer.Spacing = new Vector2(10, 0);
|
2019-06-04 21:22:54 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-06-26 23:56:40 +08:00
|
|
|
|
private void load(OsuColour colours)
|
2019-06-04 21:22:54 +08:00
|
|
|
|
{
|
2019-06-27 14:02:26 +08:00
|
|
|
|
accentColour = colours.Seafoam;
|
2019-06-04 22:51:56 +08:00
|
|
|
|
|
2019-06-27 14:02:26 +08:00
|
|
|
|
foreach (TabItem<RulesetInfo> tabItem in TabContainer)
|
|
|
|
|
((ProfileRulesetTabItem)tabItem).AccentColour = accentColour;
|
|
|
|
|
}
|
2019-06-27 13:53:18 +08:00
|
|
|
|
|
|
|
|
|
public void SetDefaultRuleset(RulesetInfo ruleset)
|
2019-06-04 22:51:56 +08:00
|
|
|
|
{
|
2019-06-27 13:53:18 +08:00
|
|
|
|
// Todo: This method shouldn't exist, but bindables don't provide the concept of observing a change to the default value
|
2019-06-05 00:02:09 +08:00
|
|
|
|
foreach (TabItem<RulesetInfo> tabItem in TabContainer)
|
2019-06-27 13:54:31 +08:00
|
|
|
|
((ProfileRulesetTabItem)tabItem).IsDefault = ((ProfileRulesetTabItem)tabItem).Value.ID == ruleset.ID;
|
2019-06-04 23:37:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-27 13:53:18 +08:00
|
|
|
|
public void SelectDefaultRuleset()
|
2019-06-04 23:37:31 +08:00
|
|
|
|
{
|
2019-06-27 13:53:18 +08:00
|
|
|
|
// Todo: This method shouldn't exist, but bindables don't provide the concept of observing a change to the default value
|
2019-06-05 00:02:09 +08:00
|
|
|
|
foreach (TabItem<RulesetInfo> tabItem in TabContainer)
|
2019-06-04 23:37:31 +08:00
|
|
|
|
{
|
2019-06-27 13:54:31 +08:00
|
|
|
|
if (((ProfileRulesetTabItem)tabItem).IsDefault)
|
2019-06-04 22:51:56 +08:00
|
|
|
|
{
|
2019-06-27 13:54:31 +08:00
|
|
|
|
Current.Value = ((ProfileRulesetTabItem)tabItem).Value;
|
2019-06-04 22:51:56 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-04 21:22:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-27 14:02:26 +08:00
|
|
|
|
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new ProfileRulesetTabItem(value)
|
|
|
|
|
{
|
|
|
|
|
AccentColour = accentColour
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-04 21:22:54 +08:00
|
|
|
|
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|