start hacking up lobby to work with slots (cnc only)
This commit is contained in:
@@ -34,6 +34,9 @@ namespace OpenRA.Traits
|
||||
|
||||
public void Tick( Player owner, Cache<string, List<Actor>> buildings )
|
||||
{
|
||||
if (owner.Country == null)
|
||||
return;
|
||||
|
||||
var effectivePrereq = prerequisites.Where( a => a.Traits.Get<BuildableInfo>().Owner.Contains( owner.Country.Race ) );
|
||||
var nowHasPrerequisites = effectivePrereq.Any() &&
|
||||
effectivePrereq.All( a => buildings[ a.Name ].Any( b => !b.Trait<Building>().Disabled ) );
|
||||
|
||||
@@ -12,14 +12,13 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Network;
|
||||
|
||||
namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class LobbyDelegate : IWidgetDelegate
|
||||
{
|
||||
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate;
|
||||
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate;
|
||||
|
||||
Dictionary<string, string> CountryNames;
|
||||
string MapUid;
|
||||
@@ -41,7 +40,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
Players = Widget.RootWidget.GetWidget("SERVER_LOBBY").GetWidget("PLAYERS");
|
||||
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
|
||||
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
|
||||
|
||||
EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY");
|
||||
|
||||
var mapPreview = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW");
|
||||
mapPreview.Map = () => Map;
|
||||
@@ -235,6 +234,11 @@ namespace OpenRA.Widgets.Delegates
|
||||
if (Game.orderManager.Connection.ConnectionState == ConnectionState.PreConnecting)
|
||||
hasJoined = false;
|
||||
}
|
||||
|
||||
static Session.Client GetClientInSlot(Session.Slot slot)
|
||||
{
|
||||
return Game.LobbyInfo.Clients.FirstOrDefault(c => c.Slot == slot.Index);
|
||||
}
|
||||
|
||||
void UpdatePlayerList()
|
||||
{
|
||||
@@ -243,12 +247,18 @@ namespace OpenRA.Widgets.Delegates
|
||||
Players.Children.Clear();
|
||||
|
||||
int offset = 0;
|
||||
foreach (var client in Game.LobbyInfo.Clients)
|
||||
foreach (var slot in Game.LobbyInfo.Slots)
|
||||
{
|
||||
var c = client;
|
||||
var s = slot;
|
||||
var c = GetClientInSlot(s);
|
||||
Widget template;
|
||||
|
||||
if (client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
||||
template = EmptySlotTemplate.Clone(); // FIXME
|
||||
|
||||
var name = template.GetWidget<LabelWidget>("NAME");
|
||||
name.Text = s.Bot ?? (s.Closed ? "Closed" : c != null ? c.Name : "Open");
|
||||
|
||||
/*if (client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
||||
{
|
||||
template = LocalPlayerTemplate.Clone();
|
||||
var name = template.GetWidget<TextFieldWidget>("NAME");
|
||||
@@ -331,8 +341,9 @@ namespace OpenRA.Widgets.Delegates
|
||||
status.Checked = () => c.State == Session.ClientState.Ready;
|
||||
if (client.Index == Game.LocalClient.Index) status.OnMouseDown = CycleReady;
|
||||
}
|
||||
* */
|
||||
|
||||
template.Id = "PLAYER_{0}".F(c.Index);
|
||||
template.Id = "SLOT_{0}".F(s.Index);
|
||||
template.Parent = Players;
|
||||
|
||||
template.Bounds = new Rectangle(0, offset, template.Bounds.Width, template.Bounds.Height);
|
||||
|
||||
@@ -155,6 +155,21 @@ Container@ROOT:
|
||||
Y:2
|
||||
Width:20
|
||||
Height:20
|
||||
Container@TEMPLATE_EMPTY:
|
||||
Id:TEMPLATE_EMPTY
|
||||
X:0
|
||||
Y:0
|
||||
Width:500
|
||||
Height:30
|
||||
Visible:false
|
||||
Children:
|
||||
Label@NAME:
|
||||
Id:NAME
|
||||
Text:Name
|
||||
Width:139
|
||||
Height:25
|
||||
X:0
|
||||
Y:0
|
||||
Container@LABEL_CONTAINER:
|
||||
X:30
|
||||
Y:45
|
||||
|
||||
Reference in New Issue
Block a user