mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Refactor SoloGameplayLeaderboard
to not read scores via DI
Also allows updating scores if they arrive late.
This commit is contained in:
parent
d2b80645ab
commit
70e6b595f1
@ -1,32 +1,43 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// 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.Allocation;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
using osu.Game.Online.Leaderboards;
|
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
namespace osu.Game.Screens.Play.HUD
|
||||||
{
|
{
|
||||||
public class SoloGameplayLeaderboard : GameplayLeaderboard
|
public class SoloGameplayLeaderboard : GameplayLeaderboard
|
||||||
{
|
{
|
||||||
[BackgroundDependencyLoader]
|
private readonly IUser trackingUser;
|
||||||
private void load(Player player, ScoreProcessor processor, ILeaderboard leaderboard)
|
|
||||||
|
[Resolved]
|
||||||
|
private ScoreProcessor scoreProcessor { get; set; } = null!;
|
||||||
|
|
||||||
|
public SoloGameplayLeaderboard(IUser trackingUser)
|
||||||
{
|
{
|
||||||
ILeaderboardScore local = Add(player.Score.ScoreInfo.User, true);
|
this.trackingUser = trackingUser;
|
||||||
|
}
|
||||||
|
|
||||||
local.TotalScore.BindTarget = processor.TotalScore;
|
public void ShowScores(IEnumerable<IScoreInfo> scores)
|
||||||
local.Accuracy.BindTarget = processor.Accuracy;
|
{
|
||||||
local.Combo.BindTarget = processor.Combo;
|
Clear();
|
||||||
|
|
||||||
foreach (var s in leaderboard.Scores)
|
if (!scores.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ILeaderboardScore local = Add(trackingUser, true);
|
||||||
|
|
||||||
|
local.TotalScore.BindTarget = scoreProcessor.TotalScore;
|
||||||
|
local.Accuracy.BindTarget = scoreProcessor.Accuracy;
|
||||||
|
local.Combo.BindTarget = scoreProcessor.Combo;
|
||||||
|
|
||||||
|
foreach (var s in scores)
|
||||||
{
|
{
|
||||||
// todo: APIUser is pain for IScoreInfo.
|
var score = Add(s.User, false);
|
||||||
var score = Add(new APIUser
|
|
||||||
{
|
|
||||||
Id = s.User.OnlineID,
|
|
||||||
Username = s.User.Username,
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
score.TotalScore.Value = s.TotalScore;
|
score.TotalScore.Value = s.TotalScore;
|
||||||
score.Accuracy.Value = s.Accuracy;
|
score.Accuracy.Value = s.Accuracy;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user