mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add tracking of team totals to leaderboard implementation
This commit is contained in:
@ -83,6 +83,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
}, Add);
|
}, Add);
|
||||||
|
|
||||||
|
LoadComponentAsync(new MatchScoreDisplay
|
||||||
|
{
|
||||||
|
Team1Score = { BindTarget = leaderboard.Team1Score },
|
||||||
|
Team2Score = { BindTarget = leaderboard.Team2Score }
|
||||||
|
}, Add);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for load", () => leaderboard.IsLoaded);
|
AddUntilStep("wait for load", () => leaderboard.IsLoaded);
|
||||||
|
@ -26,6 +26,12 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
protected readonly Dictionary<int, TrackedUserData> UserScores = new Dictionary<int, TrackedUserData>();
|
protected readonly Dictionary<int, TrackedUserData> UserScores = new Dictionary<int, TrackedUserData>();
|
||||||
|
|
||||||
|
public readonly BindableInt Team1Score = new BindableInt();
|
||||||
|
public readonly BindableInt Team2Score = new BindableInt();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorClient spectatorClient { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
@ -39,6 +45,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
private readonly BindableList<int> playingUsers;
|
private readonly BindableList<int> playingUsers;
|
||||||
private Bindable<ScoringMode> scoringMode;
|
private Bindable<ScoringMode> scoringMode;
|
||||||
|
|
||||||
|
private bool hasTeams;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct a new leaderboard.
|
/// Construct a new leaderboard.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -65,6 +73,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
var trackedUser = CreateUserData(user, scoreProcessor);
|
var trackedUser = CreateUserData(user, scoreProcessor);
|
||||||
trackedUser.ScoringMode.BindTo(scoringMode);
|
trackedUser.ScoringMode.BindTo(scoringMode);
|
||||||
UserScores[userId] = trackedUser;
|
UserScores[userId] = trackedUser;
|
||||||
|
|
||||||
|
hasTeams |= trackedUser.Team != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
userLookupCache.GetUsersAsync(playingUsers.ToArray()).ContinueWith(users => Schedule(() =>
|
userLookupCache.GetUsersAsync(playingUsers.ToArray()).ContinueWith(users => Schedule(() =>
|
||||||
@ -107,8 +117,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
spectatorClient.OnNewFrames += handleIncomingFrames;
|
spectatorClient.OnNewFrames += handleIncomingFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
protected virtual TrackedUserData CreateUserData(MultiplayerRoomUser user, ScoreProcessor scoreProcessor) => new TrackedUserData(user, scoreProcessor);
|
||||||
private OsuColour colours { get; set; }
|
|
||||||
|
|
||||||
protected override GameplayLeaderboardScore CreateLeaderboardScoreDrawable(User user, bool isTracked)
|
protected override GameplayLeaderboardScore CreateLeaderboardScoreDrawable(User user, bool isTracked)
|
||||||
{
|
{
|
||||||
@ -159,9 +168,26 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
trackedData.Frames.Add(new TimedFrame(bundle.Frames.First().Time, bundle.Header));
|
trackedData.Frames.Add(new TimedFrame(bundle.Frames.First().Time, bundle.Header));
|
||||||
trackedData.UpdateScore();
|
trackedData.UpdateScore();
|
||||||
|
|
||||||
|
updateTotals();
|
||||||
});
|
});
|
||||||
|
|
||||||
protected virtual TrackedUserData CreateUserData(MultiplayerRoomUser user, ScoreProcessor scoreProcessor) => new TrackedUserData(user, scoreProcessor);
|
private void updateTotals()
|
||||||
|
{
|
||||||
|
if (!hasTeams)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Team1Score.Value = 0;
|
||||||
|
Team2Score.Value = 0;
|
||||||
|
|
||||||
|
foreach (var u in UserScores.Values)
|
||||||
|
{
|
||||||
|
if (u.Team == 0)
|
||||||
|
Team1Score.Value += (int)u.Score.Value;
|
||||||
|
else
|
||||||
|
Team2Score.Value += (int)u.Score.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user