ui for opening and closing slots
This commit is contained in:
@@ -161,6 +161,11 @@ namespace OpenRA.Server
|
|||||||
throw new InvalidOperationException("Already got 8 players");
|
throw new InvalidOperationException("Already got 8 players");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ChooseFreeSlot()
|
||||||
|
{
|
||||||
|
return lobbyInfo.Slots.First(s => !s.Closed && s.Bot == null).Index;
|
||||||
|
}
|
||||||
|
|
||||||
static void AcceptConnection()
|
static void AcceptConnection()
|
||||||
{
|
{
|
||||||
var newConn = new Connection { socket = listener.AcceptSocket() };
|
var newConn = new Connection { socket = listener.AcceptSocket() };
|
||||||
@@ -195,6 +200,7 @@ namespace OpenRA.Server
|
|||||||
State = Session.ClientState.NotReady,
|
State = Session.ClientState.NotReady,
|
||||||
SpawnPoint = 0,
|
SpawnPoint = 0,
|
||||||
Team = 0,
|
Team = 0,
|
||||||
|
Slot = ChooseFreeSlot(),
|
||||||
});
|
});
|
||||||
|
|
||||||
Log.Write("server", "Client {0}: Accepted connection from {1}",
|
Log.Write("server", "Client {0}: Accepted connection from {1}",
|
||||||
|
|||||||
@@ -261,6 +261,12 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
template = EmptySlotTemplateHost.Clone();
|
template = EmptySlotTemplateHost.Clone();
|
||||||
var name = template.GetWidget<ButtonWidget>("NAME");
|
var name = template.GetWidget<ButtonWidget>("NAME");
|
||||||
name.GetText = () => s.Closed ? "Closed" : "Open";
|
name.GetText = () => s.Closed ? "Closed" : "Open";
|
||||||
|
name.OnMouseUp = _ =>
|
||||||
|
{
|
||||||
|
Game.IssueOrder(
|
||||||
|
Order.Command((s.Closed ? "slot_open " : "slot_close ") + s.Index));
|
||||||
|
return true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -271,7 +277,10 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
|
|
||||||
var join = template.GetWidget<ButtonWidget>("JOIN");
|
var join = template.GetWidget<ButtonWidget>("JOIN");
|
||||||
if (join != null)
|
if (join != null)
|
||||||
|
{
|
||||||
join.OnMouseUp = _ => { Game.IssueOrder(Order.Command("slot " + s.Index)); return true; };
|
join.OnMouseUp = _ => { Game.IssueOrder(Order.Command("slot " + s.Index)); return true; };
|
||||||
|
join.IsVisible = () => !s.Closed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (c.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
else if (c.Index == Game.LocalClient.Index && c.State != Session.ClientState.Ready)
|
||||||
{
|
{
|
||||||
@@ -406,4 +415,4 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user