mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 22:22:55 +08:00
Update recent participants list to use participant_count
This commit is contained in:
parent
fd6d488657
commit
0ea982c036
@ -36,13 +36,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("add 50 users", () =>
|
AddStep("add 50 users", () =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 50; i++)
|
for (int i = 0; i < 50; i++)
|
||||||
{
|
addUser(i);
|
||||||
SelectedRoom.Value.RecentParticipants.Add(new User
|
|
||||||
{
|
|
||||||
Id = i,
|
|
||||||
Username = $"User {i}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("set 3 avatars", () => list.NumberOfAvatars = 3);
|
AddStep("set 3 avatars", () => list.NumberOfAvatars = 3);
|
||||||
@ -60,34 +54,44 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddStep("add 50 users", () =>
|
AddStep("add 50 users", () =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 50; i++)
|
for (int i = 0; i < 50; i++)
|
||||||
{
|
addUser(i);
|
||||||
SelectedRoom.Value.RecentParticipants.Add(new User
|
|
||||||
{
|
|
||||||
Id = i,
|
|
||||||
Username = $"User {i}"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("remove from start", () => SelectedRoom.Value.RecentParticipants.RemoveAt(0));
|
AddStep("remove from start", () => removeUserAt(0));
|
||||||
AddAssert("3 avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
AddAssert("3 avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
||||||
AddAssert("46 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 46);
|
AddAssert("46 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 46);
|
||||||
|
|
||||||
AddStep("remove from end", () => SelectedRoom.Value.RecentParticipants.RemoveAt(SelectedRoom.Value.RecentParticipants.Count - 1));
|
AddStep("remove from end", () => removeUserAt(SelectedRoom.Value.RecentParticipants.Count - 1));
|
||||||
AddAssert("3 avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
AddAssert("3 avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
||||||
AddAssert("45 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 45);
|
AddAssert("45 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 45);
|
||||||
|
|
||||||
AddRepeatStep("remove 45 users", () => SelectedRoom.Value.RecentParticipants.RemoveAt(0), 45);
|
AddRepeatStep("remove 45 users", () => removeUserAt(0), 45);
|
||||||
AddAssert("3 avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
AddAssert("3 avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 3);
|
||||||
AddAssert("0 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 0);
|
AddAssert("0 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 0);
|
||||||
AddAssert("hidden users bubble hidden", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Alpha < 0.5f);
|
AddAssert("hidden users bubble hidden", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Alpha < 0.5f);
|
||||||
|
|
||||||
AddStep("remove another user", () => SelectedRoom.Value.RecentParticipants.RemoveAt(0));
|
AddStep("remove another user", () => removeUserAt(0));
|
||||||
AddAssert("2 avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 2);
|
AddAssert("2 avatars displayed", () => list.ChildrenOfType<UpdateableAvatar>().Count() == 2);
|
||||||
AddAssert("0 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 0);
|
AddAssert("0 hidden users", () => list.ChildrenOfType<RecentParticipantsList.HiddenUserCount>().Single().Count == 0);
|
||||||
|
|
||||||
AddRepeatStep("remove the remaining two users", () => SelectedRoom.Value.RecentParticipants.RemoveAt(0), 2);
|
AddRepeatStep("remove the remaining two users", () => removeUserAt(0), 2);
|
||||||
AddAssert("0 avatars displayed", () => !list.ChildrenOfType<UpdateableAvatar>().Any());
|
AddAssert("0 avatars displayed", () => !list.ChildrenOfType<UpdateableAvatar>().Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addUser(int id)
|
||||||
|
{
|
||||||
|
SelectedRoom.Value.ParticipantCount.Value++;
|
||||||
|
SelectedRoom.Value.RecentParticipants.Add(new User
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Username = $"User {id}"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeUserAt(int index)
|
||||||
|
{
|
||||||
|
SelectedRoom.Value.ParticipantCount.Value--;
|
||||||
|
SelectedRoom.Value.RecentParticipants.RemoveAt(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
RecentParticipants.BindCollectionChanged(onParticipantsChanged, true);
|
RecentParticipants.BindCollectionChanged(onParticipantsChanged, true);
|
||||||
|
ParticipantCount.BindValueChanged(_ => updateHiddenUserCount(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int numberOfAvatars = 3;
|
private int numberOfAvatars = 3;
|
||||||
@ -141,8 +142,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
{
|
{
|
||||||
if (avatarFlow.Count < NumberOfAvatars)
|
if (avatarFlow.Count < NumberOfAvatars)
|
||||||
avatarFlow.Add(new CircularAvatar { User = user });
|
avatarFlow.Add(new CircularAvatar { User = user });
|
||||||
else
|
|
||||||
hiddenUsers.Count++;
|
updateHiddenUserCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeUser(User user)
|
private void removeUser(User user)
|
||||||
@ -150,21 +151,20 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
if (avatarFlow.RemoveAll(a => a.User == user) > 0)
|
if (avatarFlow.RemoveAll(a => a.User == user) > 0)
|
||||||
{
|
{
|
||||||
if (RecentParticipants.Count >= NumberOfAvatars)
|
if (RecentParticipants.Count >= NumberOfAvatars)
|
||||||
{
|
|
||||||
avatarFlow.Add(new CircularAvatar { User = RecentParticipants.First(u => avatarFlow.All(a => a.User != u)) });
|
avatarFlow.Add(new CircularAvatar { User = RecentParticipants.First(u => avatarFlow.All(a => a.User != u)) });
|
||||||
hiddenUsers.Count--;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
updateHiddenUserCount();
|
||||||
hiddenUsers.Count--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearUsers()
|
private void clearUsers()
|
||||||
{
|
{
|
||||||
avatarFlow.Clear();
|
avatarFlow.Clear();
|
||||||
hiddenUsers.Count = 0;
|
updateHiddenUserCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateHiddenUserCount() => hiddenUsers.Count = ParticipantCount.Value - avatarFlow.Count;
|
||||||
|
|
||||||
private class CircularAvatar : CompositeDrawable
|
private class CircularAvatar : CompositeDrawable
|
||||||
{
|
{
|
||||||
public User User
|
public User User
|
||||||
|
Loading…
Reference in New Issue
Block a user