From fba509b3632755166c110c4509d4c05a1e036e5f Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 28 May 2016 18:16:18 +0100 Subject: [PATCH] Use BeforeGameStart to remove replay browser UI on game start. --- .../Widgets/Logic/ReplayBrowserLogic.cs | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs index 003af771f0..82f717b7b1 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs @@ -44,6 +44,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic panel = widget; this.onStart = onStart; + Game.BeforeGameStart += OnGameStart; playerList = panel.Get("PLAYER_LIST"); playerHeader = playerList.Get("HEADER"); @@ -664,16 +665,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) @@ -697,6 +693,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;