mirror of
https://github.com/ppy/osu
synced 2024-12-29 10:22:43 +00:00
Merge pull request #17786 from peppy/gameplay-leaderboard-update-totals-mode-change
Fix multiple issues with gameplay leaderboard (and tests)
This commit is contained in:
commit
3d27d3c536
@ -27,6 +27,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public abstract class MultiplayerGameplayLeaderboardTestScene : OsuTestScene
|
public abstract class MultiplayerGameplayLeaderboardTestScene : OsuTestScene
|
||||||
{
|
{
|
||||||
|
private const int total_users = 16;
|
||||||
|
|
||||||
protected readonly BindableList<MultiplayerRoomUser> MultiplayerUsers = new BindableList<MultiplayerRoomUser>();
|
protected readonly BindableList<MultiplayerRoomUser> MultiplayerUsers = new BindableList<MultiplayerRoomUser>();
|
||||||
|
|
||||||
protected MultiplayerGameplayLeaderboard Leaderboard { get; private set; }
|
protected MultiplayerGameplayLeaderboard Leaderboard { get; private set; }
|
||||||
@ -84,7 +86,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public virtual void SetUpSteps()
|
public virtual void SetUpSteps()
|
||||||
{
|
{
|
||||||
AddStep("reset counts", () => spectatorClient.Invocations.Clear());
|
AddStep("reset counts", () =>
|
||||||
|
{
|
||||||
|
spectatorClient.Invocations.Clear();
|
||||||
|
lastHeaders.Clear();
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("set local user", () => ((DummyAPIAccess)API).LocalUser.Value = new APIUser
|
AddStep("set local user", () => ((DummyAPIAccess)API).LocalUser.Value = new APIUser
|
||||||
{
|
{
|
||||||
@ -94,7 +100,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("populate users", () =>
|
AddStep("populate users", () =>
|
||||||
{
|
{
|
||||||
MultiplayerUsers.Clear();
|
MultiplayerUsers.Clear();
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < total_users; i++)
|
||||||
MultiplayerUsers.Add(CreateUser(i));
|
MultiplayerUsers.Add(CreateUser(i));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
||||||
using osu.Game.Rulesets.Osu.Scoring;
|
using osu.Game.Rulesets.Osu.Scoring;
|
||||||
@ -14,12 +13,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public class TestSceneMultiplayerGameplayLeaderboardTeams : MultiplayerGameplayLeaderboardTestScene
|
public class TestSceneMultiplayerGameplayLeaderboardTeams : MultiplayerGameplayLeaderboardTestScene
|
||||||
{
|
{
|
||||||
|
private int team;
|
||||||
|
|
||||||
protected override MultiplayerRoomUser CreateUser(int userId)
|
protected override MultiplayerRoomUser CreateUser(int userId)
|
||||||
{
|
{
|
||||||
var user = base.CreateUser(userId);
|
var user = base.CreateUser(userId);
|
||||||
user.MatchState = new TeamVersusUserState
|
user.MatchState = new TeamVersusUserState
|
||||||
{
|
{
|
||||||
TeamID = RNG.Next(0, 2)
|
TeamID = team++ % 2
|
||||||
};
|
};
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;
|
var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;
|
||||||
var score = TestResources.CreateTestScoreInfo(beatmapInfo);
|
var score = TestResources.CreateTestScoreInfo(beatmapInfo);
|
||||||
|
|
||||||
SortedDictionary<int, BindableInt> teamScores = new SortedDictionary<int, BindableInt>
|
SortedDictionary<int, BindableLong> teamScores = new SortedDictionary<int, BindableLong>
|
||||||
{
|
{
|
||||||
{ 0, new BindableInt(team1Score) },
|
{ 0, new BindableLong(team1Score) },
|
||||||
{ 1, new BindableInt(team2Score) }
|
{ 1, new BindableLong(team2Score) }
|
||||||
};
|
};
|
||||||
|
|
||||||
Stack.Push(screen = new MultiplayerTeamResultsScreen(score, 1, new PlaylistItem(beatmapInfo), teamScores));
|
Stack.Push(screen = new MultiplayerTeamResultsScreen(score, 1, new PlaylistItem(beatmapInfo), teamScores));
|
||||||
|
@ -24,12 +24,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
public class MultiplayerTeamResultsScreen : MultiplayerResultsScreen
|
public class MultiplayerTeamResultsScreen : MultiplayerResultsScreen
|
||||||
{
|
{
|
||||||
private readonly SortedDictionary<int, BindableInt> teamScores;
|
private readonly SortedDictionary<int, BindableLong> teamScores;
|
||||||
|
|
||||||
private Container winnerBackground;
|
private Container winnerBackground;
|
||||||
private Drawable winnerText;
|
private Drawable winnerText;
|
||||||
|
|
||||||
public MultiplayerTeamResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem, SortedDictionary<int, BindableInt> teamScores)
|
public MultiplayerTeamResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem, SortedDictionary<int, BindableLong> teamScores)
|
||||||
: base(score, roomId, playlistItem)
|
: base(score, roomId, playlistItem)
|
||||||
{
|
{
|
||||||
if (teamScores.Count != 2)
|
if (teamScores.Count != 2)
|
||||||
|
@ -19,8 +19,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
private const float bar_height = 18;
|
private const float bar_height = 18;
|
||||||
private const float font_size = 50;
|
private const float font_size = 50;
|
||||||
|
|
||||||
public BindableInt Team1Score = new BindableInt();
|
public BindableLong Team1Score = new BindableLong();
|
||||||
public BindableInt Team2Score = new BindableInt();
|
public BindableLong Team2Score = new BindableLong();
|
||||||
|
|
||||||
protected MatchScoreCounter Score1Text;
|
protected MatchScoreCounter Score1Text;
|
||||||
protected MatchScoreCounter Score2Text;
|
protected MatchScoreCounter Score2Text;
|
||||||
@ -133,7 +133,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
var winningBar = Team1Score.Value > Team2Score.Value ? score1Bar : score2Bar;
|
var winningBar = Team1Score.Value > Team2Score.Value ? score1Bar : score2Bar;
|
||||||
var losingBar = Team1Score.Value <= Team2Score.Value ? score1Bar : score2Bar;
|
var losingBar = Team1Score.Value <= Team2Score.Value ? score1Bar : score2Bar;
|
||||||
|
|
||||||
int diff = Math.Max(Team1Score.Value, Team2Score.Value) - Math.Min(Team1Score.Value, Team2Score.Value);
|
long diff = Math.Max(Team1Score.Value, Team2Score.Value) - Math.Min(Team1Score.Value, Team2Score.Value);
|
||||||
|
|
||||||
losingBar.ResizeWidthTo(0, 400, Easing.OutQuint);
|
losingBar.ResizeWidthTo(0, 400, Easing.OutQuint);
|
||||||
winningBar.ResizeWidthTo(Math.Min(0.4f, MathF.Pow(diff / 1500000f, 0.5f) / 2), 400, Easing.OutQuint);
|
winningBar.ResizeWidthTo(Math.Min(0.4f, MathF.Pow(diff / 1500000f, 0.5f) / 2), 400, Easing.OutQuint);
|
||||||
|
@ -29,7 +29,7 @@ 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 SortedDictionary<int, BindableInt> TeamScores = new SortedDictionary<int, BindableInt>();
|
public readonly SortedDictionary<int, BindableLong> TeamScores = new SortedDictionary<int, BindableLong>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
@ -75,21 +75,27 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
foreach (var user in playingUsers)
|
foreach (var user in playingUsers)
|
||||||
{
|
{
|
||||||
var trackedUser = CreateUserData(user, ruleset, scoreProcessor);
|
var trackedUser = CreateUserData(user, ruleset, scoreProcessor);
|
||||||
|
|
||||||
trackedUser.ScoringMode.BindTo(scoringMode);
|
trackedUser.ScoringMode.BindTo(scoringMode);
|
||||||
|
trackedUser.Score.BindValueChanged(_ => Scheduler.AddOnce(updateTotals));
|
||||||
|
|
||||||
UserScores[user.UserID] = trackedUser;
|
UserScores[user.UserID] = trackedUser;
|
||||||
|
|
||||||
if (trackedUser.Team is int team && !TeamScores.ContainsKey(team))
|
if (trackedUser.Team is int team && !TeamScores.ContainsKey(team))
|
||||||
TeamScores.Add(team, new BindableInt());
|
TeamScores.Add(team, new BindableLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
userLookupCache.GetUsersAsync(playingUsers.Select(u => u.UserID).ToArray()).ContinueWith(task => Schedule(() =>
|
userLookupCache.GetUsersAsync(playingUsers.Select(u => u.UserID).ToArray()).ContinueWith(task => Schedule(() =>
|
||||||
{
|
{
|
||||||
var users = task.GetResultSafely();
|
var users = task.GetResultSafely();
|
||||||
|
|
||||||
foreach (var user in users)
|
for (int i = 0; i < users.Length; i++)
|
||||||
{
|
{
|
||||||
if (user == null)
|
var user = users[i] ?? new APIUser
|
||||||
continue;
|
{
|
||||||
|
Id = playingUsers[i].UserID,
|
||||||
|
Username = "Unknown user",
|
||||||
|
};
|
||||||
|
|
||||||
var trackedUser = UserScores[user.Id];
|
var trackedUser = UserScores[user.Id];
|
||||||
|
|
||||||
@ -175,8 +181,6 @@ 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();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
private void updateTotals()
|
private void updateTotals()
|
||||||
|
Loading…
Reference in New Issue
Block a user