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