diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 8ef5a05701..a2d6b242b1 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -254,8 +254,6 @@ namespace OpenRA JoinLocal(); StartGame(modData.Manifest.ShellmapUid); - Game.AfterGameStart += world => Widget.OpenWindow("INGAME_ROOT", new Dictionary{{"world", world},{"orderManager",orderManager}}); - Game.ConnectionStateChanged += orderManager => { Widget.CloseWindow(); diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 10d63e41e5..1aebffba2c 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -19,6 +19,7 @@ using OpenRA.Orders; using OpenRA.Traits; using XRandom = OpenRA.Thirdparty.Random; +using OpenRA.Widgets; namespace OpenRA { @@ -117,6 +118,12 @@ namespace OpenRA wlh.WorldLoaded(this); } + // Hacky workaround for orderManager visibility + public void OpenWindow(string widget) + { + Widget.OpenWindow(widget, new Dictionary{{"world", this}, { "orderManager", orderManager }}); + } + public Actor CreateActor( string name, TypeDictionary initDict ) { return CreateActor( true, name, initDict ); diff --git a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs index e608e6f06a..af4941bbba 100644 --- a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs +++ b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs @@ -21,7 +21,7 @@ using OpenRA.Mods.RA; namespace OpenRA.Mods.Cnc { - class Gdi01ScriptInfo : TraitInfo { } + class Gdi01ScriptInfo : TraitInfo, ITraitPrerequisite { } class Gdi01Script: IWorldLoaded, ITick { diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 530d3e99f4..ea6f8ec205 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -263,6 +263,7 @@ + diff --git a/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs b/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs new file mode 100644 index 0000000000..2ad30c0650 --- /dev/null +++ b/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs @@ -0,0 +1,37 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see LICENSE. + */ +#endregion + +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + public class OpenWidgetAtGameStartInfo : ITraitInfo + { + public readonly string Widget = "INGAME_ROOT"; + + public object Create(ActorInitializer init) { return new OpenWidgetAtGameStart(this); } + } + + public class OpenWidgetAtGameStart: IWorldLoaded + { + readonly OpenWidgetAtGameStartInfo Info; + public OpenWidgetAtGameStart(OpenWidgetAtGameStartInfo Info) + { + this.Info = Info; + } + + public void WorldLoaded(World world) + { + // Todo: custom observer ui? + if (world.LocalPlayer != null) + world.OpenWindow(Info.Widget); + } + } +} \ No newline at end of file diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 1ad94b633a..ca3116db82 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -42,6 +42,7 @@ Player: PaletteFormat: cnc World: + OpenWidgetAtGameStart: ScreenShaker: NukePaletteEffect: WaterPaletteRotation: diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index 1bbb6e3429..0d0cb09c3a 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -102,6 +102,7 @@ Player: BasePalette: terrain World: + OpenWidgetAtGameStart: ScreenShaker: WaterPaletteRotation: ChronoshiftPaletteEffect: