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);
|
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), "");
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
if (om.Connection.ConnectionState == ConnectionState.NotConnected)
|
||||||
{
|
{
|
||||||
// Show connection failed dialog
|
// Show connection failed dialog
|
||||||
CloseWindow();
|
Ui.CloseWindow();
|
||||||
|
|
||||||
Action onConnect = () =>
|
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]
|
[ObjectCreator.UseCtor]
|
||||||
internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager,
|
internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager,
|
||||||
Action onExit, Action onStart, bool skirmishMode)
|
Action onExit, Action onStart, bool skirmishMode)
|
||||||
@@ -618,7 +607,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
||||||
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
disconnectButton.OnClick = () => { Ui.CloseWindow(); onExit(); };
|
||||||
|
|
||||||
if (skirmishMode)
|
if (skirmishMode)
|
||||||
disconnectButton.Text = "Back";
|
disconnectButton.Text = "Back";
|
||||||
@@ -716,6 +705,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
addBotOnMapLoad = true;
|
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()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
var newMessages = Game.GlobalChat.History.Count(m => m.Type == ChatMessageType.Message);
|
var newMessages = Game.GlobalChat.History.Count(m => m.Type == ChatMessageType.Message);
|
||||||
@@ -985,7 +990,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
void OnGameStart()
|
void OnGameStart()
|
||||||
{
|
{
|
||||||
CloseWindow();
|
Ui.CloseWindow();
|
||||||
onStart();
|
onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
this.modData = modData;
|
this.modData = modData;
|
||||||
this.onStart = onStart;
|
this.onStart = onStart;
|
||||||
|
Game.BeforeGameStart += OnGameStart;
|
||||||
|
|
||||||
playerList = panel.Get<ScrollPanelWidget>("PLAYER_LIST");
|
playerList = panel.Get<ScrollPanelWidget>("PLAYER_LIST");
|
||||||
playerHeader = playerList.Get<ScrollItemWidget>("HEADER");
|
playerHeader = playerList.Get<ScrollItemWidget>("HEADER");
|
||||||
@@ -668,16 +669,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
void WatchReplay()
|
void WatchReplay()
|
||||||
{
|
{
|
||||||
Action startReplay = () =>
|
if (selectedReplay != null && ReplayUtils.PromptConfirmReplayCompatibility(selectedReplay))
|
||||||
{
|
{
|
||||||
cancelLoadingReplays = true;
|
cancelLoadingReplays = true;
|
||||||
Game.JoinReplay(selectedReplay.FilePath);
|
Game.JoinReplay(selectedReplay.FilePath);
|
||||||
Ui.CloseWindow();
|
}
|
||||||
onStart();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (selectedReplay != null && ReplayUtils.PromptConfirmReplayCompatibility(selectedReplay))
|
|
||||||
startReplay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddReplay(ReplayMetadata replay, ScrollItemWidget template)
|
void AddReplay(ReplayMetadata replay, ScrollItemWidget template)
|
||||||
@@ -701,6 +697,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
replayList.AddChild(item);
|
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
|
class ReplayState
|
||||||
{
|
{
|
||||||
public bool Visible;
|
public bool Visible;
|
||||||
|
|||||||
Reference in New Issue
Block a user