diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index c50e7dfd89..8afa7746a1 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -310,8 +310,8 @@ namespace OpenRA JoinLocal(); StartGame(shellmap); - Widget.RootWidget.CloseWindow(); - Widget.RootWidget.OpenWindow("MAINMENU_BG"); + Widget.CloseWindow(); + Widget.OpenWindow("MAINMENU_BG"); } static string baseSupportDir = null; diff --git a/OpenRA.Game/Widgets/Delegates/ConnectionDialogsDelegate.cs b/OpenRA.Game/Widgets/Delegates/ConnectionDialogsDelegate.cs index aedc5ec365..e72cb61848 100644 --- a/OpenRA.Game/Widgets/Delegates/ConnectionDialogsDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/ConnectionDialogsDelegate.cs @@ -40,20 +40,20 @@ namespace OpenRA.Widgets.Delegates Game.ConnectionStateChanged += () => { - r.CloseWindow(); + Widget.CloseWindow(); switch( Game.orderManager.Connection.ConnectionState ) { case ConnectionState.PreConnecting: - r.OpenWindow("MAINMENU_BG"); + Widget.OpenWindow("MAINMENU_BG"); break; case ConnectionState.Connecting: - r.OpenWindow("CONNECTING_BG"); + Widget.OpenWindow("CONNECTING_BG"); break; case ConnectionState.NotConnected: - r.OpenWindow("CONNECTION_FAILED_BG"); + Widget.OpenWindow("CONNECTION_FAILED_BG"); break; case ConnectionState.Connected: - r.OpenWindow("SERVER_LOBBY"); + Widget.OpenWindow("SERVER_LOBBY"); var lobby = r.GetWidget("SERVER_LOBBY"); lobby.GetWidget("CHAT_DISPLAY").ClearChat(); diff --git a/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs b/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs index 14d3d40ff5..4ef81bbf97 100644 --- a/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/CreateServerMenuDelegate.cs @@ -22,17 +22,17 @@ namespace OpenRA.Widgets.Delegates var r = Widget.RootWidget; var cs = r.GetWidget("CREATESERVER_BG"); r.GetWidget("MAINMENU_BUTTON_CREATE").OnMouseUp = mi => { - r.OpenWindow("CREATESERVER_BG"); + Widget.OpenWindow("CREATESERVER_BG"); return true; }; cs.GetWidget("BUTTON_CANCEL").OnMouseUp = mi => { - r.CloseWindow(); + Widget.CloseWindow(); return true; }; cs.GetWidget("BUTTON_START").OnMouseUp = mi => { - r.OpenWindow("SERVER_LOBBY"); + Widget.OpenWindow("SERVER_LOBBY"); var map = Game.modData.AvailableMaps.FirstOrDefault(m => m.Value.Selectable).Key; diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index 36bd756dea..bcc5eaabee 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -75,7 +75,7 @@ namespace OpenRA.Widgets.Delegates mapButton.OnMouseUp = mi => { r.GetWidget("MAP_CHOOSER").SpecialOneArg(MapUid); - r.OpenWindow("MAP_CHOOSER"); + Widget.OpenWindow("MAP_CHOOSER"); return true; }; diff --git a/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs b/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs index 11616c0039..9b21a2cf2a 100644 --- a/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/MapChooserDelegate.cs @@ -33,13 +33,13 @@ namespace OpenRA.Widgets.Delegates bg.GetWidget("BUTTON_OK").OnMouseUp = mi => { Game.IssueOrder(Order.Command("map " + Map.Uid)); - r.CloseWindow(); + Widget.CloseWindow(); return true; }; bg.GetWidget("BUTTON_CANCEL").OnMouseUp = mi => { - r.CloseWindow(); + Widget.CloseWindow(); return true; }; diff --git a/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs b/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs index 9b3462dabb..a72fc45825 100644 --- a/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs @@ -24,12 +24,12 @@ namespace OpenRA.Widgets.Delegates bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => { Game.Settings.Save(); - Widget.RootWidget.CloseWindow(); + Widget.CloseWindow(); return true; }; Widget.RootWidget.GetWidget("MAINMENU_BUTTON_MUSIC").OnMouseUp = mi => { - Widget.RootWidget.OpenWindow("MUSIC_MENU"); + Widget.OpenWindow("MUSIC_MENU"); return true; }; diff --git a/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs b/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs index 22d53df936..688f1a7e41 100644 --- a/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs @@ -33,7 +33,7 @@ namespace OpenRA.Widgets.Delegates r.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp = mi => { - r.OpenWindow("JOINSERVER_BG"); + Widget.OpenWindow("JOINSERVER_BG"); r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true; r.GetWidget("JOINSERVER_PROGRESS_TITLE").Text = "Fetching game list..."; @@ -83,16 +83,16 @@ namespace OpenRA.Widgets.Delegates bg.GetWidget("CANCEL_BUTTON").OnMouseUp = mi => { - r.CloseWindow(); + Widget.CloseWindow(); return true; }; bg.GetWidget("DIRECTCONNECT_BUTTON").OnMouseUp = mi => { - r.CloseWindow(); + Widget.CloseWindow(); dc.GetWidget("SERVER_ADDRESS").Text = Game.Settings.Player.LastServer; - r.OpenWindow("DIRECTCONNECT_BG"); + Widget.OpenWindow("DIRECTCONNECT_BG"); return true; }; @@ -119,7 +119,7 @@ namespace OpenRA.Widgets.Delegates return false; } - r.CloseWindow(); + Widget.CloseWindow(); Game.JoinServer(currentServer.Address.Split(':')[0], int.Parse(currentServer.Address.Split(':')[1])); return true; }; @@ -136,14 +136,14 @@ namespace OpenRA.Widgets.Delegates Game.Settings.Player.LastServer = address; Game.Settings.Save(); - r.CloseWindow(); + Widget.CloseWindow(); Game.JoinServer(cpts[0], int.Parse(cpts[1])); return true; }; dc.GetWidget("CANCEL_BUTTON").OnMouseUp = mi => { - r.CloseWindow(); + Widget.CloseWindow(); return r.GetWidget("MAINMENU_BUTTON_JOIN").OnMouseUp(mi); }; } diff --git a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs index 62bb46e4c9..910d52c614 100644 --- a/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/SettingsMenuDelegate.cs @@ -150,13 +150,13 @@ namespace OpenRA.Widgets.Delegates bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => { Game.Settings.Save(); - Widget.RootWidget.CloseWindow(); + Widget.CloseWindow(); return true; }; // Menu Buttons Widget.RootWidget.GetWidget("MAINMENU_BUTTON_SETTINGS").OnMouseUp = mi => { - Widget.RootWidget.OpenWindow("SETTINGS_MENU"); + Widget.OpenWindow("SETTINGS_MENU"); return true; }; diff --git a/OpenRA.Game/Widgets/Delegates/VideoPlayerDelegate.cs b/OpenRA.Game/Widgets/Delegates/VideoPlayerDelegate.cs index 142bda39e0..1d9ff73007 100644 --- a/OpenRA.Game/Widgets/Delegates/VideoPlayerDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/VideoPlayerDelegate.cs @@ -44,13 +44,13 @@ namespace OpenRA.Widgets.Delegates bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => { player.Stop(); - Widget.RootWidget.CloseWindow(); + Widget.CloseWindow(); return true; }; // Menu Buttons Widget.RootWidget.GetWidget("MAINMENU_BUTTON_VIDEOPLAYER").OnMouseUp = mi => { - Widget.RootWidget.OpenWindow("VIDEOPLAYER_MENU"); + Widget.OpenWindow("VIDEOPLAYER_MENU"); return true; }; diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index df42cca714..157dbcc3dc 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -322,14 +322,14 @@ namespace OpenRA.Widgets return (widget != null)? (T) widget : null; } - public void CloseWindow() + public static void CloseWindow() { RootWidget.GetWidget(WindowList.Pop()).Visible = false; if (WindowList.Count > 0) RootWidget.GetWidget(WindowList.Peek()).Visible = true; } - public Widget OpenWindow(string id) + public static Widget OpenWindow(string id) { if (WindowList.Count > 0) RootWidget.GetWidget(WindowList.Peek()).Visible = false; diff --git a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs index bcd151f89c..f59cd4a162 100644 --- a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs +++ b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA public static void PlayFullscreenFMVThen(World w, string movie, Action then) { - var playerRoot = Widget.RootWidget.OpenWindow("FMVPLAYER"); + var playerRoot = Widget.OpenWindow("FMVPLAYER"); var player = playerRoot.GetWidget("PLAYER"); w.DisableTick = true; player.Load(movie); @@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA if (music) Sound.PlayMusic(); - Widget.RootWidget.CloseWindow(); + Widget.CloseWindow(); w.DisableTick = false; then(); }); diff --git a/OpenRA.Mods.RA/Widgets/Delegates/IngameChromeDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/IngameChromeDelegate.cs index 958a60e610..137cfcc02b 100755 --- a/OpenRA.Mods.RA/Widgets/Delegates/IngameChromeDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/IngameChromeDelegate.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates var gameRoot = r.GetWidget("INGAME_ROOT"); var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG"); - Game.BeforeGameStart += () => r.OpenWindow("INGAME_ROOT"); + Game.BeforeGameStart += () => Widget.OpenWindow("INGAME_ROOT"); Game.AfterGameStart += () => gameRoot.GetWidget("INGAME_RADAR_BIN").SetWorld(Game.world); r.GetWidget("INGAME_OPTIONS_BUTTON").OnMouseUp = mi => { @@ -36,12 +36,12 @@ namespace OpenRA.Mods.RA.Widgets.Delegates }; optionsBG.GetWidget("SETTINGS").OnMouseUp = mi => { - r.OpenWindow("SETTINGS_MENU"); + Widget.OpenWindow("SETTINGS_MENU"); return true; }; optionsBG.GetWidget("MUSIC").OnMouseUp = mi => { - r.OpenWindow("MUSIC_MENU"); + Widget.OpenWindow("MUSIC_MENU"); return true; };