From d0b4761e07a0d0c7a675ada5011ba777faf29ac6 Mon Sep 17 00:00:00 2001 From: alzeih Date: Wed, 21 Jul 2010 16:18:45 +1200 Subject: [PATCH] actually remove the rootWidget from Chrome --- OpenRA.Game/Chrome.cs | 18 ++++++++---------- OpenRA.Game/Widgets/Widget.cs | 4 +--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index b58202e0bd..9dfa0b919d 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -30,26 +30,24 @@ namespace OpenRA var widgetYaml = m.ChromeLayout.Select(a => MiniYaml.FromFile(a)).Aggregate(MiniYaml.Merge); - if (rootWidget == null) + if (Widget.RootWidget == null) { - rootWidget = WidgetLoader.LoadWidget( widgetYaml.FirstOrDefault() ); - rootWidget.Initialize(); - rootWidget.InitDelegates(); + Widget.RootWidget = WidgetLoader.LoadWidget( widgetYaml.FirstOrDefault() ); + Widget.RootWidget.Initialize(); + Widget.RootWidget.InitDelegates(); } } - public static Widget rootWidget = null; - public void Tick(World world) { - rootWidget.Tick(world); + Widget.RootWidget.Tick(world); if (!world.GameHasStarted) return; if (world.LocalPlayer == null) return; ++ticksSinceLastMove; } - public void Draw(World world) { rootWidget.Draw(world); shpRenderer.Flush(); rgbaRenderer.Flush(); lineRenderer.Flush(); } + public void Draw(World world) { Widget.RootWidget.Draw(world); shpRenderer.Flush(); rgbaRenderer.Flush(); lineRenderer.Flush(); } public int ticksSinceLastMove = 0; public int2 lastMousePos; @@ -58,7 +56,7 @@ namespace OpenRA if (Widget.SelectedWidget != null && Widget.SelectedWidget.HandleMouseInputOuter(mi)) return true; - if (rootWidget.HandleMouseInputOuter(mi)) + if (Widget.RootWidget.HandleMouseInputOuter(mi)) return true; if (mi.Event == MouseInputEvent.Move) @@ -74,7 +72,7 @@ namespace OpenRA if (Widget.SelectedWidget != null) return Widget.SelectedWidget.HandleKeyPressOuter(e); - if (rootWidget.HandleKeyPressOuter(e)) + if (Widget.RootWidget.HandleKeyPressOuter(e)) return true; return false; } diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 4e95145577..dafdb387b6 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -47,9 +47,7 @@ namespace OpenRA.Widgets public Widget() { IsVisible = () => Visible; } - public static Widget RootWidget { - get { return Chrome.rootWidget; } - } + public static Widget RootWidget = null; public Widget(Widget widget) {