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.
|
|
|
|
|
|
2019-08-04 19:15:16 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-06-04 21:22:54 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Rulesets;
|
2019-08-04 19:15:16 +08:00
|
|
|
|
using osu.Game.Users;
|
2019-06-04 21:22:54 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
|
|
|
|
{
|
2020-01-02 03:55:28 +08:00
|
|
|
|
public class ProfileRulesetSelector : OverlayRulesetSelector
|
2019-06-04 21:22:54 +08:00
|
|
|
|
{
|
2019-08-04 19:15:16 +08:00
|
|
|
|
public readonly Bindable<User> User = new Bindable<User>();
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
2019-06-04 22:51:56 +08:00
|
|
|
|
{
|
2019-08-04 19:15:16 +08:00
|
|
|
|
base.LoadComplete();
|
2019-08-05 12:18:29 +08:00
|
|
|
|
User.BindValueChanged(u => SetDefaultRuleset(Rulesets.GetRuleset(u.NewValue?.PlayMode ?? "osu")), true);
|
2019-08-04 19:15:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetDefaultRuleset(RulesetInfo ruleset)
|
2019-06-04 23:37:31 +08:00
|
|
|
|
{
|
2020-01-02 03:55:28 +08:00
|
|
|
|
foreach (var tabItem in TabContainer)
|
2019-08-04 19:15:16 +08:00
|
|
|
|
((ProfileRulesetTabItem)tabItem).IsDefault = ((ProfileRulesetTabItem)tabItem).Value.ID == ruleset.ID;
|
2019-06-04 21:22:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-02 03:55:28 +08:00
|
|
|
|
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new ProfileRulesetTabItem(value);
|
2019-06-04 21:22:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|