mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:57:52 +08:00
Cleanup top header container + user handling
This commit is contained in:
parent
838325fed4
commit
d5b91c6455
@ -185,10 +185,10 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
|
||||
private void updateDisplay(User user)
|
||||
{
|
||||
followerText.Text = user.FollowerCount?.Length > 0 ? user.FollowerCount[0].ToString("#,##0") : "0";
|
||||
followerText.Text = user?.FollowerCount?.Length > 0 ? user.FollowerCount[0].ToString("#,##0") : "0";
|
||||
|
||||
hiddenDetailGlobal.Content = user.Statistics?.Ranks.Global?.ToString("#,##0") ?? "-";
|
||||
hiddenDetailCountry.Content = user.Statistics?.Ranks.Country?.ToString("#,##0") ?? "-";
|
||||
hiddenDetailGlobal.Content = user?.Statistics?.Ranks.Global?.ToString("#,##0") ?? "-";
|
||||
hiddenDetailCountry.Content = user?.Statistics?.Ranks.Country?.ToString("#,##0") ?? "-";
|
||||
}
|
||||
|
||||
private class ExpandButton : ProfileHeaderButton
|
||||
|
@ -46,12 +46,12 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
}
|
||||
};
|
||||
|
||||
User.BindValueChanged(updateLevel);
|
||||
User.BindValueChanged(user => updateLevel(user.NewValue));
|
||||
}
|
||||
|
||||
private void updateLevel(ValueChangedEvent<User> user)
|
||||
private void updateLevel(User user)
|
||||
{
|
||||
levelText.Text = user.NewValue?.Statistics?.Level.Current.ToString() ?? "0";
|
||||
levelText.Text = user?.Statistics?.Level.Current.ToString() ?? "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
}
|
||||
};
|
||||
|
||||
User.BindValueChanged(updateProgress);
|
||||
User.BindValueChanged(user => updateProgress(user.NewValue));
|
||||
}
|
||||
|
||||
private void updateProgress(ValueChangedEvent<User> user)
|
||||
private void updateProgress(User user)
|
||||
{
|
||||
levelProgressBar.Length = user.NewValue?.Statistics?.Level.Progress / 100f ?? 0;
|
||||
levelProgressText.Text = user.NewValue?.Statistics?.Level.Progress.ToString("0'%'");
|
||||
levelProgressBar.Length = user?.Statistics?.Level.Progress / 100f ?? 0;
|
||||
levelProgressText.Text = user?.Statistics?.Level.Progress.ToString("0'%'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,10 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
{
|
||||
public class TopHeaderContainer : CompositeDrawable
|
||||
{
|
||||
private const float avatar_size = 110;
|
||||
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
private SupporterIcon supporterTag;
|
||||
private UpdateableAvatar avatar;
|
||||
private OsuSpriteText usernameText;
|
||||
@ -26,15 +30,10 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
private OsuSpriteText userCountryText;
|
||||
private FillFlowContainer userStats;
|
||||
|
||||
private const float avatar_size = 110;
|
||||
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Height = 150;
|
||||
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
@ -146,21 +145,23 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
Spacing = new Vector2(0, 2)
|
||||
}
|
||||
};
|
||||
|
||||
User.BindValueChanged(user => updateUser(user.NewValue));
|
||||
}
|
||||
|
||||
private void updateDisplay(User user)
|
||||
private void updateUser(User user)
|
||||
{
|
||||
avatar.User = user;
|
||||
usernameText.Text = user.Username;
|
||||
openUserExternally.Link = $@"https://osu.ppy.sh/users/{user.Id}";
|
||||
userFlag.Country = user.Country;
|
||||
userCountryText.Text = user.Country?.FullName ?? "Alien";
|
||||
supporterTag.SupporterLevel = user.SupportLevel;
|
||||
titleText.Text = user.Title;
|
||||
titleText.Colour = OsuColour.FromHex(user.Colour ?? "fff");
|
||||
usernameText.Text = user?.Username ?? string.Empty;
|
||||
openUserExternally.Link = $@"https://osu.ppy.sh/users/{user?.Id ?? 0}";
|
||||
userFlag.Country = user?.Country;
|
||||
userCountryText.Text = user?.Country?.FullName ?? "Alien";
|
||||
supporterTag.SupporterLevel = user?.SupportLevel ?? 0;
|
||||
titleText.Text = user?.Title ?? string.Empty;
|
||||
titleText.Colour = OsuColour.FromHex(user?.Colour ?? "fff");
|
||||
|
||||
userStats.Clear();
|
||||
if (user.Statistics != null)
|
||||
if (user?.Statistics != null)
|
||||
{
|
||||
userStats.Add(new UserStatsLine("Ranked Score", user.Statistics.RankedScore.ToString("#,##0")));
|
||||
userStats.Add(new UserStatsLine("Hit Accuracy", Math.Round(user.Statistics.Accuracy, 2).ToString("#0.00'%'")));
|
||||
|
Loading…
Reference in New Issue
Block a user