Use BeforeGameStart to remove mission browser UI on game start.

This commit is contained in:
Paul Chote
2016-05-28 18:13:09 +01:00
parent 773eb25917
commit 485e695585
2 changed files with 23 additions and 6 deletions

View File

@@ -197,7 +197,7 @@ namespace OpenRA
CreateAndStartLocalServer(lobbyInfo.GlobalSettings.Map, orders); CreateAndStartLocalServer(lobbyInfo.GlobalSettings.Map, orders);
} }
public static void CreateAndStartLocalServer(string mapUID, IEnumerable<Order> setupOrders, Action onStart = null) public static void CreateAndStartLocalServer(string mapUID, IEnumerable<Order> setupOrders)
{ {
OrderManager om = null; OrderManager om = null;
@@ -207,10 +207,8 @@ namespace OpenRA
LobbyInfoChanged -= lobbyReady; LobbyInfoChanged -= lobbyReady;
foreach (var o in setupOrders) foreach (var o in setupOrders)
om.IssueOrder(o); om.IssueOrder(o);
if (onStart != null)
onStart();
}; };
LobbyInfoChanged += lobbyReady; LobbyInfoChanged += lobbyReady;
om = JoinServer(IPAddress.Loopback.ToString(), CreateLocalServer(mapUID), ""); om = JoinServer(IPAddress.Loopback.ToString(), CreateLocalServer(mapUID), "");

View File

@@ -55,6 +55,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
this.modData = modData; this.modData = modData;
this.onStart = onStart; this.onStart = onStart;
Game.BeforeGameStart += OnGameStart;
missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST"); missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST");
@@ -151,6 +152,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}; };
} }
void OnGameStart()
{
Ui.CloseWindow();
onStart();
}
bool disposed;
protected override void Dispose(bool disposing)
{
if (disposing && !disposed)
{
disposed = true;
Game.BeforeGameStart -= OnGameStart;
}
base.Dispose(disposing);
}
void CreateMissionGroup(string title, IEnumerable<MapPreview> previews) void CreateMissionGroup(string title, IEnumerable<MapPreview> previews)
{ {
var header = ScrollItemWidget.Setup(headerTemplate, () => true, () => { }); var header = ScrollItemWidget.Setup(headerTemplate, () => true, () => { });
@@ -344,11 +363,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
PlayVideo(fsPlayer, missionData.StartVideo, PlayingVideo.GameStart, () => PlayVideo(fsPlayer, missionData.StartVideo, PlayingVideo.GameStart, () =>
{ {
StopVideo(fsPlayer); StopVideo(fsPlayer);
Game.CreateAndStartLocalServer(selectedMap.Uid, orders, onStart); Game.CreateAndStartLocalServer(selectedMap.Uid, orders);
}); });
} }
else else
Game.CreateAndStartLocalServer(selectedMap.Uid, orders, onStart); Game.CreateAndStartLocalServer(selectedMap.Uid, orders);
} }
class DropDownOption class DropDownOption