mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:07:52 +08:00
Rename variable to make more sense
It needs to be explicitly stated that the users in this list are related to the *joined* room. Especially since it's sharing its variable name with `SpectatorStreamingClient` where it has the opposite meaning (is a list of *globally* playing players).
This commit is contained in:
parent
6aeb7ece66
commit
e3a41f6118
@ -42,7 +42,7 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
||||
}
|
||||
|
||||
private void checkPlayingUserCount(int expectedCount)
|
||||
=> AddAssert($"{"user".ToQuantity(expectedCount)} playing", () => Client.PlayingUsers.Count == expectedCount);
|
||||
=> AddAssert($"{"user".ToQuantity(expectedCount)} playing", () => Client.CurrentMatchPlayingUserIds.Count == expectedCount);
|
||||
|
||||
private void changeState(int userCount, MultiplayerUserState state)
|
||||
=> AddStep($"{"user".ToQuantity(userCount)} in {state}", () =>
|
||||
|
@ -62,8 +62,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
streamingClient.Start(Beatmap.Value.BeatmapInfo.OnlineBeatmapID ?? 0);
|
||||
|
||||
Client.PlayingUsers.Clear();
|
||||
Client.PlayingUsers.AddRange(streamingClient.PlayingUsers);
|
||||
Client.CurrentMatchPlayingUserIds.Clear();
|
||||
Client.CurrentMatchPlayingUserIds.AddRange(streamingClient.PlayingUsers);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestUserQuit()
|
||||
{
|
||||
AddRepeatStep("mark user quit", () => Client.PlayingUsers.RemoveAt(0), users);
|
||||
AddRepeatStep("mark user quit", () => Client.CurrentMatchPlayingUserIds.RemoveAt(0), users);
|
||||
}
|
||||
|
||||
public class TestMultiplayerStreaming : SpectatorStreamingClient
|
||||
|
@ -61,9 +61,9 @@ namespace osu.Game.Online.Multiplayer
|
||||
public MultiplayerRoom? Room { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The users currently in gameplay.
|
||||
/// The users in the joined <see cref="Room"/> which are currently in gameplay.
|
||||
/// </summary>
|
||||
public readonly BindableList<int> PlayingUsers = new BindableList<int>();
|
||||
public readonly BindableList<int> CurrentMatchPlayingUserIds = new BindableList<int>();
|
||||
|
||||
[Resolved]
|
||||
private UserLookupCache userLookupCache { get; set; } = null!;
|
||||
@ -133,7 +133,7 @@ namespace osu.Game.Online.Multiplayer
|
||||
|
||||
apiRoom = null;
|
||||
Room = null;
|
||||
PlayingUsers.Clear();
|
||||
CurrentMatchPlayingUserIds.Clear();
|
||||
|
||||
RoomUpdated?.Invoke();
|
||||
}, false);
|
||||
@ -254,7 +254,7 @@ namespace osu.Game.Online.Multiplayer
|
||||
return;
|
||||
|
||||
Room.Users.Remove(user);
|
||||
PlayingUsers.Remove(user.UserID);
|
||||
CurrentMatchPlayingUserIds.Remove(user.UserID);
|
||||
|
||||
RoomUpdated?.Invoke();
|
||||
}, false);
|
||||
@ -454,22 +454,22 @@ namespace osu.Game.Online.Multiplayer
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For the provided user ID, update whether the user is included in <see cref="PlayingUsers"/>.
|
||||
/// For the provided user ID, update whether the user is included in <see cref="CurrentMatchPlayingUserIds"/>.
|
||||
/// </summary>
|
||||
/// <param name="userId">The user's ID.</param>
|
||||
/// <param name="state">The new state of the user.</param>
|
||||
private void updateUserPlayingState(int userId, MultiplayerUserState state)
|
||||
{
|
||||
bool wasPlaying = PlayingUsers.Contains(userId);
|
||||
bool wasPlaying = CurrentMatchPlayingUserIds.Contains(userId);
|
||||
bool isPlaying = state >= MultiplayerUserState.WaitingForLoad && state <= MultiplayerUserState.FinishedPlay;
|
||||
|
||||
if (isPlaying == wasPlaying)
|
||||
return;
|
||||
|
||||
if (isPlaying)
|
||||
PlayingUsers.Add(userId);
|
||||
CurrentMatchPlayingUserIds.Add(userId);
|
||||
else
|
||||
PlayingUsers.Remove(userId);
|
||||
CurrentMatchPlayingUserIds.Remove(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
{
|
||||
Debug.Assert(client.Room != null);
|
||||
|
||||
int[] userIds = client.PlayingUsers.ToArray();
|
||||
int[] userIds = client.CurrentMatchPlayingUserIds.ToArray();
|
||||
|
||||
StartPlay(() => new MultiplayerPlayer(SelectedItem.Value, userIds));
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ namespace osu.Game.Screens.Play.HUD
|
||||
// BindableList handles binding in a really bad way (Clear then AddRange) so we need to do this manually..
|
||||
foreach (int userId in playingUsers)
|
||||
{
|
||||
if (!multiplayerClient.PlayingUsers.Contains(userId))
|
||||
if (!multiplayerClient.CurrentMatchPlayingUserIds.Contains(userId))
|
||||
usersChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, new[] { userId }));
|
||||
}
|
||||
|
||||
playingUsers.BindTo(multiplayerClient.PlayingUsers);
|
||||
playingUsers.BindTo(multiplayerClient.CurrentMatchPlayingUserIds);
|
||||
playingUsers.BindCollectionChanged(usersChanged);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user