Lobby, Add Bots button
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -18,6 +18,7 @@ Previous developers included:
|
||||
|
||||
Also thanks to:
|
||||
* Akseli Virtanen (RAGEQUIT)
|
||||
* Andrew Perkins
|
||||
* Andrew Riedi
|
||||
* Andreas Beck (baxtor)
|
||||
* Barnaby Smith (mvi)
|
||||
|
||||
@@ -335,7 +335,7 @@ namespace OpenRA.Mods.RA.Server
|
||||
server.SendOrderTo(conn, "Message", "Number of teams could not be parsed: {0}".F(s));
|
||||
return true;
|
||||
}
|
||||
teams = teams.Clamp(2, 8);
|
||||
teams = teams.Clamp(1, 8);
|
||||
|
||||
var players = server.lobbyInfo.Slots
|
||||
.Select(slot => server.lobbyInfo.Clients.SingleOrDefault(c => c.Slot == slot.Key))
|
||||
@@ -366,6 +366,9 @@ namespace OpenRA.Mods.RA.Server
|
||||
cl.Team = team;
|
||||
}
|
||||
}
|
||||
// All vs Host
|
||||
if (teams == 1)
|
||||
client.Team = 2;
|
||||
server.SyncLobbyInfo();
|
||||
return true;
|
||||
}},
|
||||
|
||||
@@ -174,9 +174,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|
||||
assignTeams.OnMouseDown = _ =>
|
||||
{
|
||||
var options = Enumerable.Range(2, orderManager.LobbyInfo.Clients.Count(c => c.Slot != null).Clamp(2, 8) - 1).Select(d => new DropDownOption
|
||||
var options = Enumerable.Range(1, orderManager.LobbyInfo.Clients.Count(c => c.Slot != null).Clamp(1, 8) - 1).Select(d => new DropDownOption
|
||||
{
|
||||
Title = "{0} Teams".F(d),
|
||||
Title = (d == 1 ? "All vs Host" : "{0} Teams".F(d)),
|
||||
IsSelected = () => false,
|
||||
OnClick = () => orderManager.IssueOrder(Order.Command("assignteams {0}".F(d.ToString())))
|
||||
});
|
||||
@@ -193,6 +193,21 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
||||
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
||||
|
||||
var addBotsButton = lobby.Get<ButtonWidget>("ADD_BOTS");
|
||||
addBotsButton.IsVisible = () => Game.IsHost;
|
||||
addBotsButton.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null
|
||||
|| orderManager.LocalClient.IsReady || !orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots);
|
||||
addBotsButton.OnClick = () => {
|
||||
var aiModes = Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name);
|
||||
foreach (var slot in orderManager.LobbyInfo.Slots)
|
||||
{
|
||||
var bot = aiModes.Random(Game.CosmeticRandom);
|
||||
var c = orderManager.LobbyInfo.ClientInSlot(slot.Key);
|
||||
if (slot.Value.AllowBots == true && (c == null || c.Bot != null))
|
||||
orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot.Key,0,bot)));
|
||||
}
|
||||
};
|
||||
|
||||
var allowCheats = lobby.Get<CheckboxWidget>("ALLOWCHEATS_CHECKBOX");
|
||||
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
|
||||
allowCheats.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null
|
||||
|
||||
@@ -448,6 +448,13 @@ Container@SERVER_LOBBY:
|
||||
Width:80
|
||||
Height:20
|
||||
Text: Crates
|
||||
Button@ADD_BOTS:
|
||||
X:398-120-10
|
||||
Y:255
|
||||
Width:120
|
||||
Height:25
|
||||
Text:Add Bots
|
||||
Font:Bold
|
||||
DropDownButton@ASSIGNTEAMS_DROPDOWNBUTTON:
|
||||
X:398
|
||||
Y:255
|
||||
@@ -522,4 +529,4 @@ Container@SERVER_LOBBY:
|
||||
Width:140
|
||||
Height:35
|
||||
Text:Start Game
|
||||
TooltipContainer@TOOLTIP_CONTAINER:
|
||||
TooltipContainer@TOOLTIP_CONTAINER:
|
||||
|
||||
@@ -474,6 +474,13 @@ Background@SERVER_LOBBY:
|
||||
Height:25
|
||||
Text:Change Map
|
||||
Font:Bold
|
||||
Button@ADD_BOTS:
|
||||
X:PARENT_RIGHT-154
|
||||
Y:PARENT_BOTTOM-(289-25-5)
|
||||
Width:120
|
||||
Height:25
|
||||
Text:Add Bots
|
||||
Font:Bold
|
||||
DropDownButton@ASSIGNTEAMS_DROPDOWNBUTTON:
|
||||
X:PARENT_RIGHT-154
|
||||
Y:PARENT_BOTTOM-229
|
||||
@@ -515,4 +522,4 @@ Background@SERVER_LOBBY:
|
||||
Height:25
|
||||
Text:Start Game
|
||||
Font:Bold
|
||||
TooltipContainer@TOOLTIP_CONTAINER:
|
||||
TooltipContainer@TOOLTIP_CONTAINER:
|
||||
|
||||
@@ -474,6 +474,13 @@ Background@SERVER_LOBBY:
|
||||
Height:25
|
||||
Text:Change Map
|
||||
Font:Bold
|
||||
Button@ADD_BOTS:
|
||||
X:PARENT_RIGHT-154
|
||||
Y:PARENT_BOTTOM-(289-25-5)
|
||||
Width:120
|
||||
Height:25
|
||||
Text:Add Bots
|
||||
Font:Bold
|
||||
DropDownButton@ASSIGNTEAMS_DROPDOWNBUTTON:
|
||||
X:PARENT_RIGHT-154
|
||||
Y:PARENT_BOTTOM-229
|
||||
@@ -521,4 +528,4 @@ Background@SERVER_LOBBY:
|
||||
Height:25
|
||||
Text:Start Game
|
||||
Font:Bold
|
||||
TooltipContainer@TOOLTIP_CONTAINER:
|
||||
TooltipContainer@TOOLTIP_CONTAINER:
|
||||
|
||||
Reference in New Issue
Block a user