2019-01-28 06:45:00 +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-01-11 08:12:19 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-10 06:58:14 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2022-07-16 09:40:37 +08:00
|
|
|
|
using osu.Framework.Extensions;
|
2020-03-11 09:18:41 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2021-08-29 20:00:28 +08:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-07-17 21:32:28 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2022-08-24 15:07:03 +08:00
|
|
|
|
using osu.Game.Graphics.Cursor;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-12-24 17:11:40 +08:00
|
|
|
|
using osu.Game.Online.API;
|
2019-04-26 12:49:44 +08:00
|
|
|
|
using osu.Game.Overlays.Profile.Header.Components;
|
2021-07-17 21:32:28 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-06-18 01:57:57 +08:00
|
|
|
|
using osu.Game.Users.Drawables;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Header
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class TopHeaderContainer : CompositeDrawable
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-04-26 11:32:15 +08:00
|
|
|
|
private const float avatar_size = 110;
|
|
|
|
|
|
2023-01-11 02:24:54 +08:00
|
|
|
|
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
|
2019-04-26 11:32:15 +08:00
|
|
|
|
|
2020-12-24 17:11:40 +08:00
|
|
|
|
[Resolved]
|
2022-12-30 20:17:59 +08:00
|
|
|
|
private IAPIProvider api { get; set; } = null!;
|
2020-12-24 17:11:40 +08:00
|
|
|
|
|
2022-12-30 20:17:59 +08:00
|
|
|
|
private SupporterIcon supporterTag = null!;
|
|
|
|
|
private UpdateableAvatar avatar = null!;
|
|
|
|
|
private OsuSpriteText usernameText = null!;
|
|
|
|
|
private ExternalLinkButton openUserExternally = null!;
|
|
|
|
|
private OsuSpriteText titleText = null!;
|
|
|
|
|
private UpdateableFlag userFlag = null!;
|
|
|
|
|
private OsuSpriteText userCountryText = null!;
|
|
|
|
|
private FillFlowContainer userStats = null!;
|
2023-01-11 15:47:29 +08:00
|
|
|
|
private GroupBadgeFlow groupBadgeFlow = null!;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-01-30 04:48:02 +08:00
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-03-10 06:58:14 +08:00
|
|
|
|
Height = 150;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-01-30 04:48:02 +08:00
|
|
|
|
Colour = colourProvider.Background5,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN },
|
|
|
|
|
Height = avatar_size,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2019-06-18 01:57:57 +08:00
|
|
|
|
Children = new Drawable[]
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2021-09-10 13:18:40 +08:00
|
|
|
|
avatar = new UpdateableAvatar(isInteractive: false, showGuestOnNull: false)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(avatar_size),
|
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = avatar_size * 0.25f,
|
|
|
|
|
},
|
2022-08-24 15:07:03 +08:00
|
|
|
|
new OsuContextMenuContainer
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
2022-08-24 15:07:03 +08:00
|
|
|
|
Child = new Container
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Padding = new MarginPadding { Left = 10 },
|
|
|
|
|
Children = new Drawable[]
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
new FillFlowContainer
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
new FillFlowContainer
|
2019-07-03 01:52:24 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2023-01-11 12:11:38 +08:00
|
|
|
|
Spacing = new Vector2(5),
|
2022-08-24 15:07:03 +08:00
|
|
|
|
Children = new Drawable[]
|
2019-07-03 01:52:24 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
usernameText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Regular)
|
|
|
|
|
},
|
|
|
|
|
openUserExternally = new ExternalLinkButton
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
},
|
2023-01-11 15:47:29 +08:00
|
|
|
|
groupBadgeFlow = new GroupBadgeFlow
|
2023-01-11 12:11:38 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
}
|
2022-08-24 15:07:03 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
titleText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Regular)
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
supporterTag = new SupporterIcon
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
Height = 20,
|
|
|
|
|
Margin = new MarginPadding { Top = 5 }
|
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 1.5f,
|
|
|
|
|
Margin = new MarginPadding { Top = 10 },
|
|
|
|
|
Colour = colourProvider.Light1,
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new Drawable[]
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-08-24 15:07:03 +08:00
|
|
|
|
userFlag = new UpdateableFlag
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(28, 20),
|
|
|
|
|
ShowPlaceholderOnUnknown = false,
|
|
|
|
|
},
|
|
|
|
|
userCountryText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 17.5f, weight: FontWeight.Regular),
|
|
|
|
|
Margin = new MarginPadding { Left = 10 },
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Colour = colourProvider.Light1,
|
|
|
|
|
}
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
2022-08-24 15:07:03 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
userStats = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Width = 300,
|
|
|
|
|
Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN },
|
|
|
|
|
Padding = new MarginPadding { Vertical = 15 },
|
|
|
|
|
Spacing = new Vector2(0, 2)
|
|
|
|
|
}
|
|
|
|
|
};
|
2019-04-26 11:32:15 +08:00
|
|
|
|
|
2023-01-11 02:24:54 +08:00
|
|
|
|
User.BindValueChanged(user => updateUser(user.NewValue));
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 00:46:08 +08:00
|
|
|
|
private void updateUser(UserProfileData? data)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2023-01-10 00:46:08 +08:00
|
|
|
|
var user = data?.User;
|
2022-12-30 21:56:19 +08:00
|
|
|
|
|
2019-03-10 06:58:14 +08:00
|
|
|
|
avatar.User = user;
|
2019-04-26 11:32:15 +08:00
|
|
|
|
usernameText.Text = user?.Username ?? string.Empty;
|
2020-12-24 17:11:40 +08:00
|
|
|
|
openUserExternally.Link = $@"{api.WebsiteRootUrl}/users/{user?.Id ?? 0}";
|
2022-07-18 13:40:34 +08:00
|
|
|
|
userFlag.CountryCode = user?.CountryCode ?? default;
|
|
|
|
|
userCountryText.Text = (user?.CountryCode ?? default).GetDescription();
|
2019-04-28 19:11:36 +08:00
|
|
|
|
supporterTag.SupportLevel = user?.SupportLevel ?? 0;
|
2019-04-26 11:32:15 +08:00
|
|
|
|
titleText.Text = user?.Title ?? string.Empty;
|
2020-03-11 09:18:41 +08:00
|
|
|
|
titleText.Colour = Color4Extensions.FromHex(user?.Colour ?? "fff");
|
2023-01-11 15:47:29 +08:00
|
|
|
|
groupBadgeFlow.User.Value = user;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
|
|
|
|
userStats.Clear();
|
2019-05-07 12:23:09 +08:00
|
|
|
|
|
2019-04-26 11:32:15 +08:00
|
|
|
|
if (user?.Statistics != null)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2021-07-23 01:20:20 +08:00
|
|
|
|
userStats.Add(new UserStatsLine(UsersStrings.ShowStatsRankedScore, user.Statistics.RankedScore.ToLocalisableString("#,##0")));
|
2021-07-17 21:32:28 +08:00
|
|
|
|
userStats.Add(new UserStatsLine(UsersStrings.ShowStatsHitAccuracy, user.Statistics.DisplayAccuracy));
|
2021-07-23 01:20:20 +08:00
|
|
|
|
userStats.Add(new UserStatsLine(UsersStrings.ShowStatsPlayCount, user.Statistics.PlayCount.ToLocalisableString("#,##0")));
|
|
|
|
|
userStats.Add(new UserStatsLine(UsersStrings.ShowStatsTotalScore, user.Statistics.TotalScore.ToLocalisableString("#,##0")));
|
|
|
|
|
userStats.Add(new UserStatsLine(UsersStrings.ShowStatsTotalHits, user.Statistics.TotalHits.ToLocalisableString("#,##0")));
|
|
|
|
|
userStats.Add(new UserStatsLine(UsersStrings.ShowStatsMaximumCombo, user.Statistics.MaxCombo.ToLocalisableString("#,##0")));
|
|
|
|
|
userStats.Add(new UserStatsLine(UsersStrings.ShowStatsReplaysWatchedByOthers, user.Statistics.ReplaysWatched.ToLocalisableString("#,##0")));
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
private partial class UserStatsLine : Container
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2021-07-23 01:20:20 +08:00
|
|
|
|
public UserStatsLine(LocalisableString left, LocalisableString right)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2019-04-25 17:05:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 15),
|
2019-01-11 08:12:19 +08:00
|
|
|
|
Text = left,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
2019-04-25 17:05:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold),
|
2019-01-11 08:12:19 +08:00
|
|
|
|
Text = right,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|