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 System.Collections.Generic;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-10 06:58:14 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
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-24 05:19:51 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-05-08 22:08:08 +08:00
|
|
|
|
using osu.Game.Online.Leaderboards;
|
2019-04-26 12:49:44 +08:00
|
|
|
|
using osu.Game.Overlays.Profile.Header.Components;
|
2021-07-17 21:29:34 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Header
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class DetailHeaderContainer : CompositeDrawable
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly Dictionary<ScoreRank, ScoreRankInfo> scoreRankInfos = new Dictionary<ScoreRank, ScoreRankInfo>();
|
2022-12-30 20:17:59 +08:00
|
|
|
|
private OverlinedInfoContainer medalInfo = null!;
|
|
|
|
|
private OverlinedInfoContainer ppInfo = null!;
|
|
|
|
|
private OverlinedInfoContainer detailGlobalRank = null!;
|
|
|
|
|
private OverlinedInfoContainer detailCountryRank = null!;
|
|
|
|
|
private FillFlowContainer? fillFlow;
|
|
|
|
|
private RankGraph rankGraph = null!;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2022-12-30 21:56:19 +08:00
|
|
|
|
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2019-05-04 10:01:12 +08:00
|
|
|
|
private bool expanded = true;
|
|
|
|
|
|
|
|
|
|
public bool Expanded
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (expanded == value) return;
|
|
|
|
|
|
|
|
|
|
expanded = value;
|
|
|
|
|
|
|
|
|
|
if (fillFlow == null) return;
|
|
|
|
|
|
|
|
|
|
fillFlow.ClearTransforms();
|
|
|
|
|
|
|
|
|
|
if (expanded)
|
|
|
|
|
fillFlow.AutoSizeAxes = Axes.Y;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fillFlow.AutoSizeAxes = Axes.None;
|
|
|
|
|
fillFlow.ResizeHeightTo(0, 200, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:12:19 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2020-01-30 05:10:58 +08:00
|
|
|
|
private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-03-10 06:58:14 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y;
|
2019-05-04 10:01:12 +08:00
|
|
|
|
|
2022-12-30 21:56:19 +08:00
|
|
|
|
UserProfile.ValueChanged += e => updateDisplay(e.NewValue);
|
2019-03-10 06:58:14 +08:00
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-01-30 05:10:58 +08:00
|
|
|
|
Colour = colourProvider.Background5,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
2019-05-04 10:01:12 +08:00
|
|
|
|
fillFlow = new FillFlowContainer
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2019-05-04 10:01:12 +08:00
|
|
|
|
AutoSizeAxes = expanded ? Axes.Y : Axes.None,
|
|
|
|
|
AutoSizeDuration = 200,
|
|
|
|
|
AutoSizeEasing = Easing.OutQuint,
|
|
|
|
|
Masking = true,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 },
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 20),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(10, 0),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-04-25 19:30:16 +08:00
|
|
|
|
new OverlinedTotalPlayTime
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-12-30 21:56:19 +08:00
|
|
|
|
UserProfile = { BindTarget = UserProfile }
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
2019-03-10 06:58:14 +08:00
|
|
|
|
medalInfo = new OverlinedInfoContainer
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2021-07-17 21:29:34 +08:00
|
|
|
|
Title = UsersStrings.ShowStatsMedals,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
LineColour = colours.GreenLight,
|
|
|
|
|
},
|
2019-03-10 06:58:14 +08:00
|
|
|
|
ppInfo = new OverlinedInfoContainer
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
Title = "pp",
|
|
|
|
|
LineColour = colours.Red,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2019-06-21 14:27:19 +08:00
|
|
|
|
Spacing = new Vector2(5),
|
2019-01-11 08:12:19 +08:00
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
scoreRankInfos[ScoreRank.XH] = new ScoreRankInfo(ScoreRank.XH),
|
|
|
|
|
scoreRankInfos[ScoreRank.X] = new ScoreRankInfo(ScoreRank.X),
|
|
|
|
|
scoreRankInfos[ScoreRank.SH] = new ScoreRankInfo(ScoreRank.SH),
|
|
|
|
|
scoreRankInfos[ScoreRank.S] = new ScoreRankInfo(ScoreRank.S),
|
|
|
|
|
scoreRankInfos[ScoreRank.A] = new ScoreRankInfo(ScoreRank.A),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Padding = new MarginPadding { Right = 130 },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
rankGraph = new RankGraph
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Width = 130,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Padding = new MarginPadding { Horizontal = 10 },
|
|
|
|
|
Spacing = new Vector2(0, 20),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-03-10 06:58:14 +08:00
|
|
|
|
detailGlobalRank = new OverlinedInfoContainer(true, 110)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2021-07-17 21:29:34 +08:00
|
|
|
|
Title = UsersStrings.ShowRankGlobalSimple,
|
2020-01-30 05:10:58 +08:00
|
|
|
|
LineColour = colourProvider.Highlight1,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
2019-03-10 06:58:14 +08:00
|
|
|
|
detailCountryRank = new OverlinedInfoContainer(false, 110)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2021-07-17 21:29:34 +08:00
|
|
|
|
Title = UsersStrings.ShowRankCountrySimple,
|
2020-01-30 05:10:58 +08:00
|
|
|
|
LineColour = colourProvider.Highlight1,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-30 21:56:19 +08:00
|
|
|
|
private void updateDisplay(UserProfile? userProfile)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2022-12-30 21:56:19 +08:00
|
|
|
|
var user = userProfile?.User;
|
|
|
|
|
|
2019-01-11 08:12:19 +08:00
|
|
|
|
medalInfo.Content = user?.Achievements?.Length.ToString() ?? "0";
|
2021-07-25 03:32:26 +08:00
|
|
|
|
ppInfo.Content = user?.Statistics?.PP?.ToLocalisableString("#,##0") ?? (LocalisableString)"0";
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
|
|
|
|
foreach (var scoreRankInfo in scoreRankInfos)
|
2019-03-06 15:30:56 +08:00
|
|
|
|
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2021-07-25 03:32:26 +08:00
|
|
|
|
detailGlobalRank.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
|
|
|
|
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
2019-01-11 08:12:19 +08:00
|
|
|
|
|
2019-08-04 19:35:26 +08:00
|
|
|
|
rankGraph.Statistics.Value = user?.Statistics;
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
private partial class ScoreRankInfo : CompositeDrawable
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly OsuSpriteText rankCount;
|
|
|
|
|
|
|
|
|
|
public int RankCount
|
|
|
|
|
{
|
2021-07-24 05:19:51 +08:00
|
|
|
|
set => rankCount.Text = value.ToLocalisableString("#,##0");
|
2019-01-11 08:12:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ScoreRankInfo(ScoreRank rank)
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
InternalChild = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Width = 56,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-06-21 14:27:19 +08:00
|
|
|
|
new DrawableRank(rank)
|
2019-01-11 08:12:19 +08:00
|
|
|
|
{
|
2019-05-08 22:08:08 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 30,
|
2019-01-11 08:12:19 +08:00
|
|
|
|
},
|
|
|
|
|
rankCount = new OsuSpriteText
|
|
|
|
|
{
|
2019-04-25 17:05:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
2019-01-11 08:12:19 +08:00
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|