1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-31 00:02:56 +08:00
osu-lazer/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs

66 lines
2.3 KiB
C#
Raw Normal View History

// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
2024-02-29 06:13:31 +08:00
using osu.Game.Online;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics.User;
namespace osu.Game.Screens.Ranking.Statistics
{
public partial class UserStatisticsPanel : StatisticsPanel
{
private readonly ScoreInfo achievedScore;
internal readonly Bindable<UserStatisticsUpdate?> DisplayedUserStatisticsUpdate = new Bindable<UserStatisticsUpdate?>();
private IBindable<UserStatisticsUpdate?> latestGlobalStatisticsUpdate = null!;
public UserStatisticsPanel(ScoreInfo achievedScore)
{
this.achievedScore = achievedScore;
}
[BackgroundDependencyLoader]
2024-02-29 06:11:01 +08:00
private void load(UserStatisticsWatcher? userStatisticsWatcher)
{
2024-02-29 06:11:01 +08:00
if (userStatisticsWatcher != null)
{
2024-02-29 06:11:01 +08:00
latestGlobalStatisticsUpdate = userStatisticsWatcher.LatestUpdate.GetBoundCopy();
latestGlobalStatisticsUpdate.BindValueChanged(update =>
{
if (update.NewValue?.Score.MatchesOnlineID(achievedScore) == true)
DisplayedUserStatisticsUpdate.Value = update.NewValue;
});
}
}
protected override ICollection<StatisticItem> CreateStatisticItems(ScoreInfo newScore, IBeatmap playableBeatmap)
{
var items = base.CreateStatisticItems(newScore, playableBeatmap);
if (newScore.UserID > 1
&& newScore.UserID == achievedScore.UserID
&& newScore.OnlineID > 0
&& newScore.OnlineID == achievedScore.OnlineID)
{
items = items.Append(new StatisticItem("Overall Ranking", () => new OverallRanking
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
StatisticsUpdate = { BindTarget = DisplayedUserStatisticsUpdate }
})).ToArray();
}
return items;
}
}
}