Skirmish mode starts with a bot selected.
This commit is contained in:
@@ -50,7 +50,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
|
||||
{
|
||||
{ "onExit", onExit },
|
||||
{ "onStart", OnGameStart }
|
||||
{ "onStart", OnGameStart },
|
||||
{ "addBots", false }
|
||||
});
|
||||
};
|
||||
|
||||
@@ -86,7 +87,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
[ObjectCreator.Param] World world, // Shellmap world
|
||||
[ObjectCreator.Param] OrderManager orderManager,
|
||||
[ObjectCreator.Param] Action onExit,
|
||||
[ObjectCreator.Param] Action onStart)
|
||||
[ObjectCreator.Param] Action onStart,
|
||||
[ObjectCreator.Param] bool addBots)
|
||||
{
|
||||
this.orderManager = orderManager;
|
||||
this.OnGameStart = () => { CloseWindow(); onStart(); };
|
||||
@@ -222,6 +224,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
{ "onExit", () => {} },
|
||||
});
|
||||
};
|
||||
|
||||
// Add a bot on the first lobbyinfo update
|
||||
if (addBots)
|
||||
Game.LobbyInfoChanged += WidgetUtils.Once(() =>
|
||||
{
|
||||
var slot = orderManager.LobbyInfo.FirstEmptySlot();
|
||||
var bot = Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name).FirstOrDefault();
|
||||
if (bot != null)
|
||||
orderManager.IssueOrder(Order.Command("slot_bot {0} {1}".F(slot, bot)));
|
||||
});
|
||||
}
|
||||
|
||||
public void AddChatLine(Color c, string from, string text)
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Widget.OpenWindow("SERVERBROWSER_PANEL", new WidgetArgs()
|
||||
{
|
||||
{ "onExit", () => Menu = MenuType.Multiplayer },
|
||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer) }
|
||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
|
||||
});
|
||||
};
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Widget.OpenWindow("CREATESERVER_PANEL", new WidgetArgs()
|
||||
{
|
||||
{ "onExit", () => Menu = MenuType.Multiplayer },
|
||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer) }
|
||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
|
||||
});
|
||||
};
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Widget.OpenWindow("DIRECTCONNECT_PANEL", new WidgetArgs()
|
||||
{
|
||||
{ "onExit", () => Menu = MenuType.Multiplayer },
|
||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer) }
|
||||
{ "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) }
|
||||
});
|
||||
};
|
||||
|
||||
@@ -140,13 +140,14 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
rootMenu.Parent.RemoveChild(rootMenu);
|
||||
}
|
||||
|
||||
void OpenLobbyPanel(MenuType menu)
|
||||
void OpenLobbyPanel(MenuType menu, bool addBots)
|
||||
{
|
||||
Menu = MenuType.None;
|
||||
Game.OpenWindow("SERVER_LOBBY", new WidgetArgs()
|
||||
{
|
||||
{ "onExit", () => { Game.Disconnect(); Menu = menu; } },
|
||||
{ "onStart", RemoveShellmapUI }
|
||||
{ "onStart", RemoveShellmapUI },
|
||||
{ "addBots", addBots }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -156,7 +157,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
var port = Game.CreateLocalServer(map);
|
||||
CncConnectingLogic.Connect(IPAddress.Loopback.ToString(),
|
||||
port,
|
||||
() => OpenLobbyPanel(MenuType.Main),
|
||||
() => OpenLobbyPanel(MenuType.Main, true),
|
||||
() => { Game.CloseServer(); Menu = MenuType.Main; });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user