|
|
|
|
@@ -327,19 +327,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|
|
|
|
{
|
|
|
|
|
// This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them)
|
|
|
|
|
// Todo: handle this nicer
|
|
|
|
|
Players.RemoveChildren();
|
|
|
|
|
|
|
|
|
|
var idx = 0;
|
|
|
|
|
foreach (var kv in orderManager.LobbyInfo.Slots)
|
|
|
|
|
{
|
|
|
|
|
var key = kv.Key;
|
|
|
|
|
var slot = kv.Value;
|
|
|
|
|
var client = orderManager.LobbyInfo.ClientInSlot(key);
|
|
|
|
|
Widget template;
|
|
|
|
|
Widget template = null;
|
|
|
|
|
|
|
|
|
|
// get template for possible reuse
|
|
|
|
|
if (idx < Players.Children.Count)
|
|
|
|
|
template = Players.Children [idx];
|
|
|
|
|
|
|
|
|
|
// Empty slot
|
|
|
|
|
if (client == null)
|
|
|
|
|
{
|
|
|
|
|
template = EmptySlotTemplate.Clone();
|
|
|
|
|
//template = EmptySlotTemplate.Clone();
|
|
|
|
|
if (template == null || template.Id != EmptySlotTemplate.Id)
|
|
|
|
|
template = EmptySlotTemplate.Clone();
|
|
|
|
|
|
|
|
|
|
Func<string> getText = () => slot.Closed ? "Closed" : "Open";
|
|
|
|
|
var ready = orderManager.LocalClient.IsReady;
|
|
|
|
|
|
|
|
|
|
@@ -367,7 +374,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|
|
|
|
else if ((client.Index == orderManager.LocalClient.Index) ||
|
|
|
|
|
(client.Bot != null && Game.IsHost))
|
|
|
|
|
{
|
|
|
|
|
template = EditablePlayerTemplate.Clone();
|
|
|
|
|
if (template == null || template.Id != EditablePlayerTemplate.Id)
|
|
|
|
|
template = EditablePlayerTemplate.Clone();
|
|
|
|
|
|
|
|
|
|
var botReady = client.Bot != null && Game.IsHost && orderManager.LocalClient.IsReady;
|
|
|
|
|
var ready = botReady || client.IsReady;
|
|
|
|
|
|
|
|
|
|
@@ -422,7 +431,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ // Non-editable player in slot
|
|
|
|
|
template = NonEditablePlayerTemplate.Clone();
|
|
|
|
|
if (template == null || template.Id != NonEditablePlayerTemplate.Id)
|
|
|
|
|
template = NonEditablePlayerTemplate.Clone();
|
|
|
|
|
|
|
|
|
|
template.Get<LabelWidget>("NAME").GetText = () => client.Name;
|
|
|
|
|
if (client.IsAdmin)
|
|
|
|
|
template.Get<LabelWidget>("NAME").Font = "Bold";
|
|
|
|
|
@@ -449,20 +460,35 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template.IsVisible = () => true;
|
|
|
|
|
Players.AddChild(template);
|
|
|
|
|
|
|
|
|
|
if (idx >= Players.Children.Count)
|
|
|
|
|
Players.AddChild(template);
|
|
|
|
|
else if (Players.Children [idx].Id != template.Id)
|
|
|
|
|
{
|
|
|
|
|
Players.Children [idx].Removed();
|
|
|
|
|
template.Parent = Players;
|
|
|
|
|
Players.Children [idx] = template;
|
|
|
|
|
}
|
|
|
|
|
idx++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add spectators
|
|
|
|
|
foreach (var client in orderManager.LobbyInfo.Clients.Where(client => client.Slot == null))
|
|
|
|
|
{
|
|
|
|
|
Widget template;
|
|
|
|
|
Widget template = null;
|
|
|
|
|
var c = client;
|
|
|
|
|
var ready = c.IsReady;
|
|
|
|
|
|
|
|
|
|
// get template for possible reuse
|
|
|
|
|
if (idx < Players.Children.Count)
|
|
|
|
|
template = Players.Children[idx];
|
|
|
|
|
|
|
|
|
|
// Editable spectator
|
|
|
|
|
if (c.Index == orderManager.LocalClient.Index)
|
|
|
|
|
{
|
|
|
|
|
template = EditableSpectatorTemplate.Clone();
|
|
|
|
|
if (template == null || template.Id != EditableSpectatorTemplate.Id)
|
|
|
|
|
template = EditableSpectatorTemplate.Clone();
|
|
|
|
|
|
|
|
|
|
var name = template.Get<TextFieldWidget>("NAME");
|
|
|
|
|
name.IsDisabled = () => ready;
|
|
|
|
|
LobbyUtils.SetupNameWidget(orderManager, c, name);
|
|
|
|
|
@@ -481,7 +507,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|
|
|
|
// Non-editable spectator
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
template = NonEditableSpectatorTemplate.Clone();
|
|
|
|
|
if (template == null || template.Id != NonEditableSpectatorTemplate.Id)
|
|
|
|
|
template = NonEditableSpectatorTemplate.Clone();
|
|
|
|
|
|
|
|
|
|
template.Get<LabelWidget>("NAME").GetText = () => c.Name;
|
|
|
|
|
if (client.IsAdmin)
|
|
|
|
|
template.Get<LabelWidget>("NAME").Font = "Bold";
|
|
|
|
|
@@ -497,9 +525,21 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template.IsVisible = () => true;
|
|
|
|
|
Players.AddChild(template);
|
|
|
|
|
|
|
|
|
|
if (idx >= Players.Children.Count)
|
|
|
|
|
Players.AddChild(template);
|
|
|
|
|
else if (Players.Children [idx].Id != template.Id)
|
|
|
|
|
{
|
|
|
|
|
Players.Children [idx].Removed();
|
|
|
|
|
template.Parent = Players;
|
|
|
|
|
Players.Children [idx] = template;
|
|
|
|
|
}
|
|
|
|
|
idx++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var i = idx; i < Players.Children.Count; i++)
|
|
|
|
|
Players.RemoveChild(Players.Children[i]);
|
|
|
|
|
|
|
|
|
|
// Spectate button
|
|
|
|
|
if (orderManager.LocalClient.Slot != null)
|
|
|
|
|
{
|
|
|
|
|
|