diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 1845dab2fb..efd520a2de 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -205,7 +205,6 @@ namespace OpenRA LobbyInfoChanged(); } - public static event Action AfterGameStart = _ => {}; public static event Action BeforeGameStart = () => {}; internal static void StartGame(string mapUID) { @@ -223,7 +222,6 @@ namespace OpenRA orderManager.LastTickTime = Environment.TickCount; orderManager.StartGame(); worldRenderer.RefreshPalette(); - AfterGameStart( orderManager.world ); } public static bool IsHost @@ -275,9 +273,8 @@ namespace OpenRA AddChatLine = (a,b,c) => {}; ConnectionStateChanged = om => {}; BeforeGameStart = () => {}; - AfterGameStart = w => {}; Widget.ResetAll(); - + worldRenderer = null; if (server != null) server.Shutdown(); diff --git a/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs b/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs index 40484d76b7..65d454f9f5 100644 --- a/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs +++ b/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs @@ -47,6 +47,7 @@ namespace OpenRA.Mods.RA public class LoadWidgetAtGameStartInfo : ITraitInfo { public readonly string Widget = null; + public readonly bool ClearRootWidget = true; public object Create(ActorInitializer init) { return new LoadWidgetAtGameStart(this); } } @@ -60,6 +61,10 @@ namespace OpenRA.Mods.RA public void WorldLoaded(World world) { + // Clear any existing widget state + if (Info.ClearRootWidget) + Widget.ResetAll(); + Game.LoadWidget(world, Info.Widget, Widget.RootWidget, new WidgetArgs()); } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs index 85eafba4f8..fdc1b62f88 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return true; }; - Game.AfterGameStart += _ => validPlayers = world.players.Values.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count(); + validPlayers = world.players.Values.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count(); diplomacy.IsVisible = () => (validPlayers > 0); }