Change Leaderboard to use IUser instead of APIUser

This commit is contained in:
Dean Herbert 2022-09-13 16:56:19 +09:00
parent ac58c222b9
commit d2b80645ab
5 changed files with 11 additions and 10 deletions

View File

@ -120,6 +120,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
=> AddStep($"set user {userId} time {time}", () => clocks[userId].CurrentTime = time); => AddStep($"set user {userId} time {time}", () => clocks[userId].CurrentTime = time);
private void assertCombo(int userId, int expectedCombo) private void assertCombo(int userId, int expectedCombo)
=> AddUntilStep($"player {userId} has {expectedCombo} combo", () => this.ChildrenOfType<GameplayLeaderboardScore>().Single(s => s.User?.Id == userId).Combo.Value == expectedCombo); => AddUntilStep($"player {userId} has {expectedCombo} combo", () => this.ChildrenOfType<GameplayLeaderboardScore>().Single(s => s.User?.OnlineID == userId).Combo.Value == expectedCombo);
} }
} }

View File

@ -522,7 +522,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
private PlayerArea getInstance(int userId) => spectatorScreen.ChildrenOfType<PlayerArea>().Single(p => p.UserId == userId); private PlayerArea getInstance(int userId) => spectatorScreen.ChildrenOfType<PlayerArea>().Single(p => p.UserId == userId);
private GameplayLeaderboardScore getLeaderboardScore(int userId) => spectatorScreen.ChildrenOfType<GameplayLeaderboardScore>().Single(s => s.User?.Id == userId); private GameplayLeaderboardScore getLeaderboardScore(int userId) => spectatorScreen.ChildrenOfType<GameplayLeaderboardScore>().Single(s => s.User?.OnlineID == userId);
private int[] getPlayerIds(int count) => Enumerable.Range(PLAYER_1_ID, count).ToArray(); private int[] getPlayerIds(int count) => Enumerable.Range(PLAYER_1_ID, count).ToArray();
} }

View File

@ -10,7 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Users;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -72,7 +72,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(APIUser? user, bool isTracked) public ILeaderboardScore Add(IUser? user, bool isTracked)
{ {
var drawable = CreateLeaderboardScoreDrawable(user, isTracked); var drawable = CreateLeaderboardScoreDrawable(user, isTracked);
@ -103,7 +103,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(IUser? user, bool isTracked) =>
new GameplayLeaderboardScore(user, isTracked); new GameplayLeaderboardScore(user, isTracked);
protected override void Update() protected override void Update()

View File

@ -12,7 +12,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Users;
using osu.Game.Users.Drawables; using osu.Game.Users.Drawables;
using osu.Game.Utils; using osu.Game.Utils;
using osuTK; using osuTK;
@ -81,7 +81,7 @@ namespace osu.Game.Screens.Play.HUD
} }
[CanBeNull] [CanBeNull]
public APIUser User { get; } public IUser User { get; }
/// <summary> /// <summary>
/// Whether this score is the local user or a replay player (and should be focused / always visible). /// Whether this score is the local user or a replay player (and should be focused / always visible).
@ -103,7 +103,7 @@ namespace osu.Game.Screens.Play.HUD
/// </summary> /// </summary>
/// <param name="user">The score's player.</param> /// <param name="user">The score's player.</param>
/// <param name="tracked">Whether the player is the local user or a replay player.</param> /// <param name="tracked">Whether the player is the local user or a replay player.</param>
public GameplayLeaderboardScore([CanBeNull] APIUser user, bool tracked) public GameplayLeaderboardScore([CanBeNull] IUser user, bool tracked)
{ {
User = user; User = user;
Tracked = tracked; Tracked = tracked;

View File

@ -21,6 +21,7 @@ using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus; using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
using osu.Game.Online.Spectator; using osu.Game.Online.Spectator;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Users;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
@ -125,11 +126,11 @@ namespace osu.Game.Screens.Play.HUD
playingUserIds.BindCollectionChanged(playingUsersChanged); playingUserIds.BindCollectionChanged(playingUsersChanged);
} }
protected override GameplayLeaderboardScore CreateLeaderboardScoreDrawable(APIUser user, bool isTracked) protected override GameplayLeaderboardScore CreateLeaderboardScoreDrawable(IUser user, bool isTracked)
{ {
var leaderboardScore = base.CreateLeaderboardScoreDrawable(user, isTracked); var leaderboardScore = base.CreateLeaderboardScoreDrawable(user, isTracked);
if (UserScores[user.Id].Team is int team) if (UserScores[user.OnlineID].Team is int team)
{ {
leaderboardScore.BackgroundColour = getTeamColour(team).Lighten(1.2f); leaderboardScore.BackgroundColour = getTeamColour(team).Lighten(1.2f);
leaderboardScore.TextColour = Color4.White; leaderboardScore.TextColour = Color4.White;