Make the lobby player list include the ready indicator and not hack it together (#1860)
* Started new Lobby * -Proper styling -Use a scrollcontainer :smilethink: * Too lazy to add a stylerule, too young to optimize css * Fix typo Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using Content.Client.Interfaces;
|
||||||
using System.Linq;
|
|
||||||
using Content.Client.Interfaces;
|
|
||||||
using Content.Client.Interfaces.Chat;
|
using Content.Client.Interfaces.Chat;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
@@ -18,6 +16,8 @@ using Robust.Shared.Localization;
|
|||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using static Content.Shared.SharedGameTicker;
|
using static Content.Shared.SharedGameTicker;
|
||||||
|
|
||||||
namespace Content.Client.State
|
namespace Content.Client.State
|
||||||
@@ -211,12 +211,11 @@ namespace Content.Client.State
|
|||||||
|
|
||||||
private void UpdatePlayerList()
|
private void UpdatePlayerList()
|
||||||
{
|
{
|
||||||
_lobby.OnlinePlayerItemList.Clear();
|
_lobby.OnlinePlayerList.Clear();
|
||||||
_lobby.PlayerReadyList.Clear();
|
|
||||||
|
|
||||||
foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name))
|
foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name))
|
||||||
{
|
{
|
||||||
_lobby.OnlinePlayerItemList.AddItem(session.Name);
|
|
||||||
|
|
||||||
var readyState = "";
|
var readyState = "";
|
||||||
// Don't show ready state if we're ingame
|
// Don't show ready state if we're ingame
|
||||||
@@ -236,7 +235,7 @@ namespace Content.Client.State
|
|||||||
_ => "",
|
_ => "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
_lobby.PlayerReadyList.AddItem(readyState, null, false);
|
_lobby.OnlinePlayerList.AddItem(session.Name, readyState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ using Robust.Client.UserInterface.Controls;
|
|||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Content.Client.UserInterface
|
namespace Content.Client.UserInterface
|
||||||
{
|
{
|
||||||
@@ -21,8 +23,7 @@ namespace Content.Client.UserInterface
|
|||||||
public Button CreditsButton { get; }
|
public Button CreditsButton { get; }
|
||||||
public Button LeaveButton { get; }
|
public Button LeaveButton { get; }
|
||||||
public ChatBox Chat { get; }
|
public ChatBox Chat { get; }
|
||||||
public ItemList OnlinePlayerItemList { get; }
|
public LobbyPlayerList OnlinePlayerList { get; }
|
||||||
public ItemList PlayerReadyList { get; }
|
|
||||||
public ServerInfo ServerInfo { get; }
|
public ServerInfo ServerInfo { get; }
|
||||||
public LobbyCharacterPreviewPanel CharacterPreview { get; }
|
public LobbyCharacterPreviewPanel CharacterPreview { get; }
|
||||||
|
|
||||||
@@ -226,17 +227,11 @@ namespace Content.Client.UserInterface
|
|||||||
CustomMinimumSize = (50,50),
|
CustomMinimumSize = (50,50),
|
||||||
Children =
|
Children =
|
||||||
{
|
{
|
||||||
(OnlinePlayerItemList = new ItemList
|
(OnlinePlayerList = new LobbyPlayerList
|
||||||
{
|
{
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
}),
|
})
|
||||||
(PlayerReadyList = new ItemList
|
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
|
||||||
SizeFlagsStretchRatio = 0.2f
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,4 +257,82 @@ namespace Content.Client.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LobbyPlayerList : Control
|
||||||
|
{
|
||||||
|
private ScrollContainer _scroll;
|
||||||
|
private VBoxContainer _vBox;
|
||||||
|
|
||||||
|
public LobbyPlayerList()
|
||||||
|
{
|
||||||
|
var panel = new PanelContainer()
|
||||||
|
{
|
||||||
|
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#202028") },
|
||||||
|
};
|
||||||
|
_vBox = new VBoxContainer();
|
||||||
|
_scroll = new ScrollContainer();
|
||||||
|
_scroll.AddChild(_vBox);
|
||||||
|
panel.AddChild(_scroll);
|
||||||
|
AddChild(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds a row
|
||||||
|
public void AddItem(string name, string status)
|
||||||
|
{
|
||||||
|
var hbox = new HBoxContainer
|
||||||
|
{
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Player Name
|
||||||
|
hbox.AddChild(new PanelContainer()
|
||||||
|
{
|
||||||
|
PanelOverride = new StyleBoxFlat
|
||||||
|
{
|
||||||
|
BackgroundColor = Color.FromHex("#373744"),
|
||||||
|
ContentMarginBottomOverride = 2,
|
||||||
|
ContentMarginLeftOverride = 4,
|
||||||
|
ContentMarginRightOverride = 4,
|
||||||
|
ContentMarginTopOverride = 2
|
||||||
|
},
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
new Label
|
||||||
|
{
|
||||||
|
Text = name
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand
|
||||||
|
});
|
||||||
|
// Status
|
||||||
|
hbox.AddChild(new PanelContainer()
|
||||||
|
{
|
||||||
|
PanelOverride = new StyleBoxFlat
|
||||||
|
{
|
||||||
|
BackgroundColor = Color.FromHex("#373744"),
|
||||||
|
ContentMarginBottomOverride = 2,
|
||||||
|
ContentMarginLeftOverride = 4,
|
||||||
|
ContentMarginRightOverride = 4,
|
||||||
|
ContentMarginTopOverride = 2
|
||||||
|
},
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
new Label
|
||||||
|
{
|
||||||
|
Text = status
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
SizeFlagsStretchRatio = 0.2f,
|
||||||
|
});
|
||||||
|
|
||||||
|
_vBox.AddChild(hbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deletes all rows
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
_vBox.RemoveAllChildren();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user