Merge pull request #11370 from pchote/fix-game-start-events
Fix shellmap UI disappearing prematurely when starting a mission or replay.
This commit is contained in:
@@ -197,7 +197,7 @@ namespace OpenRA
|
||||
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;
|
||||
|
||||
@@ -207,10 +207,8 @@ namespace OpenRA
|
||||
LobbyInfoChanged -= lobbyReady;
|
||||
foreach (var o in setupOrders)
|
||||
om.IssueOrder(o);
|
||||
|
||||
if (onStart != null)
|
||||
onStart();
|
||||
};
|
||||
|
||||
LobbyInfoChanged += lobbyReady;
|
||||
|
||||
om = JoinServer(IPAddress.Loopback.ToString(), CreateLocalServer(mapUID), "");
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
||||
{
|
||||
// Show connection failed dialog
|
||||
CloseWindow();
|
||||
Ui.CloseWindow();
|
||||
|
||||
Action onConnect = () =>
|
||||
{
|
||||
@@ -100,17 +100,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
}
|
||||
|
||||
void CloseWindow()
|
||||
{
|
||||
orderManager.AddChatLine -= AddChatLine;
|
||||
Game.LobbyInfoChanged -= UpdateCurrentMap;
|
||||
Game.LobbyInfoChanged -= UpdatePlayerList;
|
||||
Game.BeforeGameStart -= OnGameStart;
|
||||
Game.ConnectionStateChanged -= ConnectionStateChanged;
|
||||
|
||||
Ui.CloseWindow();
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager,
|
||||
Action onExit, Action onStart, bool skirmishMode)
|
||||
@@ -618,7 +607,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
||||
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
||||
disconnectButton.OnClick = () => { Ui.CloseWindow(); onExit(); };
|
||||
|
||||
if (skirmishMode)
|
||||
disconnectButton.Text = "Back";
|
||||
@@ -716,6 +705,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
addBotOnMapLoad = true;
|
||||
}
|
||||
|
||||
bool disposed;
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && !disposed)
|
||||
{
|
||||
disposed = true;
|
||||
orderManager.AddChatLine -= AddChatLine;
|
||||
Game.LobbyInfoChanged -= UpdateCurrentMap;
|
||||
Game.LobbyInfoChanged -= UpdatePlayerList;
|
||||
Game.BeforeGameStart -= OnGameStart;
|
||||
Game.ConnectionStateChanged -= ConnectionStateChanged;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
{
|
||||
var newMessages = Game.GlobalChat.History.Count(m => m.Type == ChatMessageType.Message);
|
||||
@@ -985,7 +990,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
void OnGameStart()
|
||||
{
|
||||
CloseWindow();
|
||||
Ui.CloseWindow();
|
||||
onStart();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
this.modData = modData;
|
||||
this.onStart = onStart;
|
||||
Game.BeforeGameStart += OnGameStart;
|
||||
|
||||
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)
|
||||
{
|
||||
var header = ScrollItemWidget.Setup(headerTemplate, () => true, () => { });
|
||||
@@ -344,11 +363,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
PlayVideo(fsPlayer, missionData.StartVideo, PlayingVideo.GameStart, () =>
|
||||
{
|
||||
StopVideo(fsPlayer);
|
||||
Game.CreateAndStartLocalServer(selectedMap.Uid, orders, onStart);
|
||||
Game.CreateAndStartLocalServer(selectedMap.Uid, orders);
|
||||
});
|
||||
}
|
||||
else
|
||||
Game.CreateAndStartLocalServer(selectedMap.Uid, orders, onStart);
|
||||
Game.CreateAndStartLocalServer(selectedMap.Uid, orders);
|
||||
}
|
||||
|
||||
class DropDownOption
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
this.modData = modData;
|
||||
this.onStart = onStart;
|
||||
Game.BeforeGameStart += OnGameStart;
|
||||
|
||||
playerList = panel.Get<ScrollPanelWidget>("PLAYER_LIST");
|
||||
playerHeader = playerList.Get<ScrollItemWidget>("HEADER");
|
||||
@@ -668,16 +669,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
void WatchReplay()
|
||||
{
|
||||
Action startReplay = () =>
|
||||
if (selectedReplay != null && ReplayUtils.PromptConfirmReplayCompatibility(selectedReplay))
|
||||
{
|
||||
cancelLoadingReplays = true;
|
||||
Game.JoinReplay(selectedReplay.FilePath);
|
||||
Ui.CloseWindow();
|
||||
onStart();
|
||||
};
|
||||
|
||||
if (selectedReplay != null && ReplayUtils.PromptConfirmReplayCompatibility(selectedReplay))
|
||||
startReplay();
|
||||
}
|
||||
}
|
||||
|
||||
void AddReplay(ReplayMetadata replay, ScrollItemWidget template)
|
||||
@@ -701,6 +697,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
replayList.AddChild(item);
|
||||
}
|
||||
|
||||
void OnGameStart()
|
||||
{
|
||||
Ui.CloseWindow();
|
||||
onStart();
|
||||
}
|
||||
|
||||
bool disposed;
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && !disposed)
|
||||
{
|
||||
disposed = true;
|
||||
Game.BeforeGameStart -= OnGameStart;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
class ReplayState
|
||||
{
|
||||
public bool Visible;
|
||||
|
||||
Reference in New Issue
Block a user