From 1526b6ff379e21feb6de60d235fcdec950b4b556 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 13 May 2011 15:53:46 +1200 Subject: [PATCH] Make Game.LoadWidget / Widget.LoadWidget consistent. --- OpenRA.Game/Game.cs | 4 ++-- OpenRA.Game/Widgets/Widget.cs | 4 ++-- OpenRA.Mods.Cnc/CncLoadScreen.cs | 2 +- OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs | 5 ++++- OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs | 2 +- OpenRA.Mods.RA/OpenWidgetAtGameStart.cs | 2 +- OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index a0905ac62e..f2a0c8c559 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -114,14 +114,14 @@ namespace OpenRA } // Load a widget with world, orderManager, worldRenderer args, without adding it to the widget tree - public static Widget LoadWidget(World world, string widget, WidgetArgs args) + public static Widget LoadWidget(World world, string id, Widget parent, WidgetArgs args) { return Game.modData.WidgetLoader.LoadWidget(new WidgetArgs(args) { { "world", world }, { "orderManager", orderManager }, { "worldRenderer", worldRenderer }, - }, null, widget); + }, parent, id); } static ActionQueue afterTickActions = new ActionQueue(); diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 7ad9801a7f..4863af705b 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -334,9 +334,9 @@ namespace OpenRA.Widgets return window; } - public static Widget LoadWidget(string id, WidgetArgs args) + public static Widget LoadWidget(string id, Widget parent, WidgetArgs args) { - return Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id); + return Game.modData.WidgetLoader.LoadWidget(args, parent, id); } public static void DoTick() diff --git a/OpenRA.Mods.Cnc/CncLoadScreen.cs b/OpenRA.Mods.Cnc/CncLoadScreen.cs index d62477e8ea..95d9bde4d3 100644 --- a/OpenRA.Mods.Cnc/CncLoadScreen.cs +++ b/OpenRA.Mods.Cnc/CncLoadScreen.cs @@ -90,7 +90,7 @@ namespace OpenRA.Mods.Cnc { "continueLoading", () => TestAndContinue() }, { "installData", Info } }; - Widget.LoadWidget(Info["InstallerBackgroundWidget"], args); + Widget.LoadWidget(Info["InstallerBackgroundWidget"], Widget.RootWidget, args); Widget.OpenWindow(Info["InstallerMenuWidget"], args); } else diff --git a/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs index a1ecc39293..92ead60628 100755 --- a/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs @@ -59,7 +59,10 @@ namespace OpenRA.Mods.Cnc.Widgets ingameRoot.GetWidget("OPTIONS_BUTTON").OnClick = () => { ingameRoot.IsVisible = () => false; - Widget.LoadWidget("INGAME_MENU", new WidgetArgs() {{ "world", world }, { "onExit", () => ingameRoot.IsVisible = () => true }}); + Game.LoadWidget(world, "INGAME_MENU", Widget.RootWidget, new WidgetArgs() + { + { "onExit", () => ingameRoot.IsVisible = () => true } + }); }; var postgameBG = ingameRoot.GetWidget("POSTGAME_BG"); diff --git a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs index 9b3d737401..c3cd145861 100755 --- a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs @@ -402,7 +402,7 @@ namespace OpenRA.Mods.Cnc.Widgets CurrentColorPreview = c; }; - var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", new WidgetArgs() + var colorChooser = Game.LoadWidget(orderManager.world, "COLOR_CHOOSER", null, new WidgetArgs() { { "onSelect", onSelect }, { "onChange", onChange }, diff --git a/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs b/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs index 58dd6273d2..d361ec7471 100644 --- a/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs +++ b/OpenRA.Mods.RA/OpenWidgetAtGameStart.cs @@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA public void WorldLoaded(World world) { - Widget.RootWidget.AddChild(Game.LoadWidget(world, Info.Widget, new WidgetArgs())); + Game.LoadWidget(world, Info.Widget, Widget.RootWidget, new WidgetArgs()); } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs index 1b95fba0ca..443382e9ad 100755 --- a/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/GameInitDelegate.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates switch (orderManager.Connection.ConnectionState) { case ConnectionState.PreConnecting: - Widget.LoadWidget("MAINMENU_BG", new WidgetArgs()); + Widget.LoadWidget("MAINMENU_BG", Widget.RootWidget, new WidgetArgs()); break; case ConnectionState.Connecting: Widget.OpenWindow("CONNECTING_BG",