mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 00:13:10 +08:00
Track local Player.Score
's user rather than using APIProvider
This commit is contained in:
parent
fed9a47866
commit
4c669e2bce
@ -1,11 +1,8 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Caching;
|
using osu.Framework.Caching;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -31,7 +28,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
private bool requiresScroll;
|
private bool requiresScroll;
|
||||||
private readonly OsuScrollContainer scroll;
|
private readonly OsuScrollContainer scroll;
|
||||||
|
|
||||||
private GameplayLeaderboardScore trackedScore;
|
private GameplayLeaderboardScore? trackedScore;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new leaderboard.
|
/// Create a new leaderboard.
|
||||||
@ -77,7 +74,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
/// Whether the player should be tracked on the leaderboard.
|
/// Whether the player should be tracked on the leaderboard.
|
||||||
/// Set to <c>true</c> for the local player or a player whose replay is currently being played.
|
/// Set to <c>true</c> for the local player or a player whose replay is currently being played.
|
||||||
/// </param>
|
/// </param>
|
||||||
public ILeaderboardScore Add([CanBeNull] APIUser user, bool isTracked)
|
public ILeaderboardScore Add(APIUser? user, bool isTracked)
|
||||||
{
|
{
|
||||||
var drawable = CreateLeaderboardScoreDrawable(user, isTracked);
|
var drawable = CreateLeaderboardScoreDrawable(user, isTracked);
|
||||||
|
|
||||||
@ -108,7 +105,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
scroll.ScrollToStart(false);
|
scroll.ScrollToStart(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual GameplayLeaderboardScore CreateLeaderboardScoreDrawable(APIUser user, bool isTracked) =>
|
protected virtual GameplayLeaderboardScore CreateLeaderboardScoreDrawable(APIUser? user, bool isTracked) =>
|
||||||
new GameplayLeaderboardScore(user, isTracked);
|
new GameplayLeaderboardScore(user, isTracked);
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -14,25 +11,26 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
public class SoloGameplayLeaderboard : GameplayLeaderboard
|
public class SoloGameplayLeaderboard : GameplayLeaderboard
|
||||||
{
|
{
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IAPIProvider api, ScoreProcessor processor, ILeaderboard leaderboard)
|
private void load(Player player, ScoreProcessor processor, ILeaderboard leaderboard)
|
||||||
{
|
{
|
||||||
var local = Add(api.LocalUser.Value, true);
|
ILeaderboardScore local = Add(player.Score.ScoreInfo.User, true);
|
||||||
|
|
||||||
local.TotalScore.BindTarget = processor.TotalScore;
|
local.TotalScore.BindTarget = processor.TotalScore;
|
||||||
local.Accuracy.BindTarget = processor.Accuracy;
|
local.Accuracy.BindTarget = processor.Accuracy;
|
||||||
local.Combo.BindTarget = processor.Combo;
|
local.Combo.BindTarget = processor.Combo;
|
||||||
|
|
||||||
foreach (var player in leaderboard.Scores)
|
foreach (var s in leaderboard.Scores)
|
||||||
{
|
{
|
||||||
// todo: APIUser is pain for IScoreInfo.
|
// todo: APIUser is pain for IScoreInfo.
|
||||||
var score = Add(new APIUser
|
var score = Add(new APIUser
|
||||||
{
|
{
|
||||||
Id = player.User.OnlineID,
|
Id = s.User.OnlineID,
|
||||||
Username = player.User.Username,
|
Username = s.User.Username,
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
score.TotalScore.Value = player.TotalScore;
|
score.TotalScore.Value = s.TotalScore;
|
||||||
score.Accuracy.Value = player.Accuracy;
|
score.Accuracy.Value = s.Accuracy;
|
||||||
score.Combo.Value = player.MaxCombo;
|
score.Combo.Value = s.MaxCombo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user