add slot command

This commit is contained in:
Chris Forbes
2010-08-24 16:57:14 +12:00
parent 8ec16fdbbe
commit 3428b3c4c2
3 changed files with 62 additions and 9 deletions

View File

@@ -372,6 +372,16 @@ namespace OpenRA.Server
SyncLobbyInfo(); SyncLobbyInfo();
return true; 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", { "map",
s => s =>
{ {

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Widgets.Delegates
{ {
public class LobbyDelegate : IWidgetDelegate public class LobbyDelegate : IWidgetDelegate
{ {
Widget Players, LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate; Widget Players, LocalPlayerTemplate, RemotePlayerTemplate, EmptySlotTemplate, EmptySlotTemplateHost;
Dictionary<string, string> CountryNames; Dictionary<string, string> CountryNames;
string MapUid; string MapUid;
@@ -41,6 +41,7 @@ namespace OpenRA.Widgets.Delegates
LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL"); LocalPlayerTemplate = Players.GetWidget("TEMPLATE_LOCAL");
RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE"); RemotePlayerTemplate = Players.GetWidget("TEMPLATE_REMOTE");
EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY"); EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY");
EmptySlotTemplateHost = Players.GetWidget("TEMPLATE_EMPTY_HOST");
var mapPreview = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW"); var mapPreview = lobby.GetWidget<MapPreviewWidget>("LOBBY_MAP_PREVIEW");
mapPreview.Map = () => Map; mapPreview.Map = () => Map;
@@ -253,12 +254,26 @@ namespace OpenRA.Widgets.Delegates
var c = GetClientInSlot(s); var c = GetClientInSlot(s);
Widget template; 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"); var join = template.GetWidget<ButtonWidget>("JOIN");
name.GetText = () => s.Bot ?? (s.Closed ? "Closed" : c != null ? c.Name : "Open"); if (join != null)
join.OnMouseUp = _ => { Game.IssueOrder(Order.Command("slot " + s.Index)); return true; };
/*if (client.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready) }
else if (c.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
{ {
template = LocalPlayerTemplate.Clone(); template = LocalPlayerTemplate.Clone();
var name = template.GetWidget<TextFieldWidget>("NAME"); var name = template.GetWidget<TextFieldWidget>("NAME");
@@ -339,9 +354,8 @@ namespace OpenRA.Widgets.Delegates
var status = template.GetWidget<CheckboxWidget>("STATUS"); var status = template.GetWidget<CheckboxWidget>("STATUS");
status.Checked = () => c.State == Session.ClientState.Ready; 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.Id = "SLOT_{0}".F(s.Index);
template.Parent = Players; template.Parent = Players;

View File

@@ -32,7 +32,7 @@ Container@ROOT:
Height:244 Height:244
Container@PLAYERS: Container@PLAYERS:
Id:PLAYERS Id:PLAYERS
X:30 X:20
Y:75 Y:75
Width:500 Width:500
Height:200 Height:200
@@ -170,6 +170,35 @@ Container@ROOT:
Height:25 Height:25
X:0 X:0
Y: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: Container@LABEL_CONTAINER:
X:30 X:30
Y:45 Y:45