mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 08:12:56 +08:00
Pin multiplayer host panel to the top of the list
This commit is contained in:
parent
4adb8c205f
commit
1c899d00b9
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -15,6 +16,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
{
|
||||
private FillFlowContainer<ParticipantPanel> panels;
|
||||
|
||||
[CanBeNull]
|
||||
private ParticipantPanel currentHostPanel;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -55,6 +59,16 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
// Add panels for all users new to the room.
|
||||
foreach (var user in Room.Users.Except(panels.Select(p => p.User)))
|
||||
panels.Add(new ParticipantPanel(user));
|
||||
|
||||
if (currentHostPanel == null || !currentHostPanel.User.Equals(Room.Host))
|
||||
{
|
||||
// Reset position of previous host back to normal, if one existing.
|
||||
if (currentHostPanel != null && panels.Contains(currentHostPanel))
|
||||
panels.SetLayoutPosition(currentHostPanel, 0);
|
||||
|
||||
// Change position of new host to display above all participants.
|
||||
panels.SetLayoutPosition(currentHostPanel = panels.Single(u => u.User.Equals(Room.Host)), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user