mirror of
https://github.com/osukey/osukey.git
synced 2025-05-05 13:47:19 +09:00
39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
// 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 System.Linq;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
|
using osu.Framework.Graphics.UserInterface;
|
|
using osu.Game.Extensions;
|
|
using osu.Game.Rulesets;
|
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
|
{
|
|
public partial class ProfileRulesetSelector : OverlayRulesetSelector
|
|
{
|
|
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
|
|
UserProfile.BindValueChanged(userProfile => updateState(userProfile.NewValue), true);
|
|
}
|
|
|
|
private void updateState(UserProfile? userProfile)
|
|
{
|
|
Current.Value = Items.SingleOrDefault(ruleset => userProfile?.Ruleset.MatchesOnlineID(ruleset) == true);
|
|
SetDefaultRuleset(Rulesets.GetRuleset(userProfile?.User.PlayMode ?? @"osu").AsNonNull());
|
|
}
|
|
|
|
public void SetDefaultRuleset(RulesetInfo ruleset)
|
|
{
|
|
foreach (var tabItem in TabContainer)
|
|
((ProfileRulesetTabItem)tabItem).IsDefault = ((ProfileRulesetTabItem)tabItem).Value.Equals(ruleset);
|
|
}
|
|
|
|
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new ProfileRulesetTabItem(value);
|
|
}
|
|
}
|