add slot command
This commit is contained in:
@@ -372,6 +372,16 @@ namespace OpenRA.Server
|
||||
SyncLobbyInfo();
|
||||
return true;
|
||||
}},
|
||||
{ "slot",
|
||||
s =>
|
||||
{
|
||||
int slot;
|
||||
if (!int.TryParse(s, out slot)) { Log.Write("server", "Invalid slot: {0}", s ); return false; }
|
||||
|
||||
GetClient(conn).Slot = slot;
|
||||
SyncLobbyInfo();
|
||||
return true;
|
||||
}},
|
||||
{ "map",
|
||||
s =>
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class LobbyDelegate : IWidgetDelegate
|
||||
{
|
||||
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate;
|
||||
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate, EmptySlotTemplateHost;
|
||||
|
||||
Dictionary<string, string> CountryNames;
|
||||
string MapUid;
|
||||
@@ -41,6 +41,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
|
||||
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
|
||||
EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY");
|
||||
EmptySlotTemplateHost = Players.GetWidget("TEMPLATE_EMPTY_HOST");
|
||||
|
||||
var mapPreview = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW");
|
||||
mapPreview.Map = () => Map;
|
||||
@@ -253,12 +254,26 @@ namespace OpenRA.Widgets.Delegates
|
||||
var c = GetClientInSlot(s);
|
||||
Widget template;
|
||||
|
||||
template = EmptySlotTemplate.Clone(); // FIXME
|
||||
if (c == null)
|
||||
{
|
||||
if (Game.IsHost)
|
||||
{
|
||||
template = EmptySlotTemplateHost.Clone();
|
||||
var name = template.GetWidget<ButtonWidget>("NAME");
|
||||
name.GetText = () => s.Closed ? "Closed" : "Open";
|
||||
}
|
||||
else
|
||||
{
|
||||
template = EmptySlotTemplate.Clone();
|
||||
var name = template.GetWidget<ButtonWidget>("NAME");
|
||||
name.GetText = () => s.Closed ? "Closed" : "Open";
|
||||
}
|
||||
|
||||
var name = template.GetWidget<LabelWidget>("NAME");
|
||||
name.GetText = () => s.Bot ?? (s.Closed ? "Closed" : c != null ? c.Name : "Open");
|
||||
|
||||
/*if (client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
||||
var join = template.GetWidget<ButtonWidget>("JOIN");
|
||||
if (join != null)
|
||||
join.OnMouseUp = _ => { Game.IssueOrder(Order.Command("slot " + s.Index)); return true; };
|
||||
}
|
||||
else if (c.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
||||
{
|
||||
template = LocalPlayerTemplate.Clone();
|
||||
var name = template.GetWidget<TextFieldWidget>("NAME");
|
||||
@@ -339,9 +354,8 @@ namespace OpenRA.Widgets.Delegates
|
||||
|
||||
var status = template.GetWidget<CheckboxWidget>("STATUS");
|
||||
status.Checked = () => c.State == Session.ClientState.Ready;
|
||||
if (client.Index == Game.LocalClient.Index) status.OnMouseDown = CycleReady;
|
||||
if (c.Index == Game.LocalClient.Index) status.OnMouseDown = CycleReady;
|
||||
}
|
||||
* */
|
||||
|
||||
template.Id = "SLOT_{0}".F(s.Index);
|
||||
template.Parent = Players;
|
||||
|
||||
@@ -32,7 +32,7 @@ Container@ROOT:
|
||||
Height:244
|
||||
Container@PLAYERS:
|
||||
Id:PLAYERS
|
||||
X:30
|
||||
X:20
|
||||
Y:75
|
||||
Width:500
|
||||
Height:200
|
||||
@@ -170,6 +170,35 @@ Container@ROOT:
|
||||
Height:25
|
||||
X:0
|
||||
Y:0
|
||||
Button@JOIN:
|
||||
Id:JOIN
|
||||
Text:Play in this slot
|
||||
Width:PARENT_RIGHT - 160
|
||||
Height:25
|
||||
X:160
|
||||
Y:0
|
||||
Container@TEMPLATE_EMPTY_HOST:
|
||||
Id:TEMPLATE_EMPTY_HOST
|
||||
X:0
|
||||
Y:0
|
||||
Width:500
|
||||
Height:30
|
||||
Visible:false
|
||||
Children:
|
||||
Button@NAME: -- TODO: replace with dropdown
|
||||
Id:NAME
|
||||
Text:Name
|
||||
Width:155
|
||||
Height:25
|
||||
X:0
|
||||
Y:0
|
||||
Button@JOIN:
|
||||
Id:JOIN
|
||||
Text:Play in this slot
|
||||
Width:PARENT_RIGHT - 160
|
||||
Height:25
|
||||
X:160
|
||||
Y:0
|
||||
Container@LABEL_CONTAINER:
|
||||
X:30
|
||||
Y:45
|
||||
|
||||
Reference in New Issue
Block a user