diff --git a/OpenRA.Game/Widgets/DropDownButtonWidget.cs b/OpenRA.Game/Widgets/DropDownButtonWidget.cs index 7b82a09440..21fd88d1ab 100644 --- a/OpenRA.Game/Widgets/DropDownButtonWidget.cs +++ b/OpenRA.Game/Widgets/DropDownButtonWidget.cs @@ -85,7 +85,7 @@ namespace OpenRA.Widgets var panel = (ScrollPanelWidget)Ui.LoadWidget(panelTemplate, null, new WidgetArgs() {{ "substitutions", substitutions }}); - var itemTemplate = panel.GetWidget("TEMPLATE"); + var itemTemplate = panel.Get("TEMPLATE"); panel.RemoveChildren(); foreach (var option in options) { diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 6d1b52eca1..d1c0df90fa 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -363,25 +363,36 @@ namespace OpenRA.Widgets c.Removed(); } - public Widget GetWidget(string id) + public Widget GetOrNull(string id) { if (this.Id == id) return this; foreach (var child in Children) { - var w = child.GetWidget(id); + var w = child.GetOrNull(id); if (w != null) return w; } return null; } - public T GetWidget(string id) where T : Widget + public T GetOrNull(string id) where T : Widget { - var widget = GetWidget(id); - return (widget != null) ? (T)widget : null; + return (T) GetOrNull(id); } + + public T Get(string id) where T : Widget + { + var t = GetOrNull(id); + if (t == null) + throw new InvalidOperationException( + "Widget {0} has no child {1} of type {2}".F( + Id, id, typeof(T).Name)); + return t; + } + + public Widget Get(string id) { return Get(id); } } public class ContainerWidget : Widget diff --git a/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs b/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs index ce4e19e7d7..938cef99cb 100644 --- a/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs +++ b/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Cnc.Widgets this.world = world; tabsWidget = Lazy.New(() => - Ui.Root.GetWidget(info.ProductionTabsWidget)); + Ui.Root.Get(info.ProductionTabsWidget)); } public void SelectionChanged() diff --git a/OpenRA.Mods.Cnc/Widgets/CncWidgetUtils.cs b/OpenRA.Mods.Cnc/Widgets/CncWidgetUtils.cs index dd3b2978be..6469ee38db 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncWidgetUtils.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncWidgetUtils.cs @@ -20,16 +20,16 @@ namespace OpenRA.Mods.Cnc.Widgets public static void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel) { var prompt = Ui.OpenWindow("CONFIRM_PROMPT"); - prompt.GetWidget("PROMPT_TITLE").GetText = () => title; - prompt.GetWidget("PROMPT_TEXT").GetText = () => text; + prompt.Get("PROMPT_TITLE").GetText = () => title; + prompt.Get("PROMPT_TEXT").GetText = () => text; - prompt.GetWidget("CONFIRM_BUTTON").OnClick = () => + prompt.Get("CONFIRM_BUTTON").OnClick = () => { Ui.CloseWindow(); onConfirm(); }; - prompt.GetWidget("CANCEL_BUTTON").OnClick = () => + prompt.Get("CANCEL_BUTTON").OnClick = () => { Ui.CloseWindow(); onCancel(); diff --git a/OpenRA.Mods.Cnc/Widgets/CncWorldInteractionControllerWidget.cs b/OpenRA.Mods.Cnc/Widgets/CncWorldInteractionControllerWidget.cs index 0e973ad95c..27293e2871 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncWorldInteractionControllerWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncWorldInteractionControllerWidget.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Cnc.Widgets : base(world, worldRenderer) { tooltipContainer = Lazy.New(() => - Ui.Root.GetWidget(TooltipContainer)); + Ui.Root.Get(TooltipContainer)); } public override void MouseEntered() diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/ButtonTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/ButtonTooltipLogic.cs index 53fb660ddc..d9e6efd096 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/ButtonTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/ButtonTooltipLogic.cs @@ -17,8 +17,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public ButtonTooltipLogic(Widget widget, ToggleButtonWidget button) { - var label = widget.GetWidget("LABEL"); - var hotkey = widget.GetWidget("HOTKEY"); + var label = widget.Get("LABEL"); + var hotkey = widget.Get("HOTKEY"); label.GetText = () => button.TooltipText; var labelWidth = Game.Renderer.Fonts[label.Font].Measure(button.TooltipText).X; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs index 6f38b7adfe..92bdab650e 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs @@ -19,16 +19,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncConquestObjectivesLogic(Widget widget, World world) { - var panel = widget.GetWidget("CONQUEST_OBJECTIVES"); - panel.GetWidget("TITLE").GetText = () => "Conquest: " + world.Map.Title; + var panel = widget.Get("CONQUEST_OBJECTIVES"); + panel.Get("TITLE").GetText = () => "Conquest: " + world.Map.Title; - var statusLabel = panel.GetWidget("STATUS"); + var statusLabel = panel.Get("STATUS"); statusLabel.IsVisible = () => world.LocalPlayer != null; if (world.LocalPlayer != null) { var lp = world.LocalPlayer; - var objectiveCheckbox = panel.GetWidget("1"); + var objectiveCheckbox = panel.Get("1"); objectiveCheckbox.IsChecked = () => lp.WinState != WinState.Undefined; objectiveCheckbox.GetCheckType = () => lp.WinState == WinState.Won ? "checked" : "crossed"; @@ -39,8 +39,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic lp.WinState == WinState.Lost ? Color.Red : Color.White; } - var scrollpanel = panel.GetWidget("PLAYER_LIST"); - var itemTemplate = scrollpanel.GetWidget("PLAYER_TEMPLATE"); + var scrollpanel = panel.Get("PLAYER_LIST"); + var itemTemplate = scrollpanel.Get("PLAYER_TEMPLATE"); scrollpanel.RemoveChildren(); foreach (var p in world.Players.Where(a => !a.NonCombatant)) @@ -48,21 +48,21 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Player pp = p; var c = world.LobbyInfo.ClientWithIndex(pp.ClientIndex); var item = itemTemplate.Clone(); - var nameLabel = item.GetWidget("NAME"); + var nameLabel = item.Get("NAME"); nameLabel.GetText = () => pp.WinState == WinState.Lost ? pp.PlayerName + " (Dead)" : pp.PlayerName; nameLabel.GetColor = () => pp.ColorRamp.GetColor(0); - var flag = item.GetWidget("FACTIONFLAG"); + var flag = item.Get("FACTIONFLAG"); flag.GetImageName = () => pp.Country.Race; flag.GetImageCollection = () => "flags"; - item.GetWidget("FACTION").GetText = () => pp.Country.Name; + item.Get("FACTION").GetText = () => pp.Country.Name; - var team = item.GetWidget("TEAM"); + var team = item.Get("TEAM"); team.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString(); scrollpanel.AddChild(item); - item.GetWidget("KILLS").GetText = () => pp.Kills.ToString(); - item.GetWidget("DEATHS").GetText = () => pp.Deaths.ToString(); + item.Get("KILLS").GetText = () => pp.Kills.ToString(); + item.Get("DEATHS").GetText = () => pp.Deaths.ToString(); } } } diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs index 500b4f849a..b34b7b66dd 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic void AddChatLine(Color c, string from, string text) { - ingameRoot.GetWidget("CHAT_DISPLAY").AddLine(c, from, text); + ingameRoot.Get("CHAT_DISPLAY").AddLine(c, from, text); } void UnregisterEvents() @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic button.OnKeyPress = e => selectTab(e.Modifiers.HasModifier(Modifiers.Shift)); button.IsToggled = () => queueTabs.QueueGroup == group; var chromeName = group.ToLowerInvariant(); - var icon = button.GetWidget("ICON"); + var icon = button.Get("ICON"); icon.GetImageName = () => button.IsDisabled() ? chromeName+"-disabled" : queueTabs.Groups[group].Alert ? chromeName+"-alert" : chromeName; } @@ -72,8 +72,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Game.AddChatLine += AddChatLine; Game.BeforeGameStart += UnregisterEvents; - ingameRoot = widget.GetWidget("INGAME_ROOT"); - var playerRoot = ingameRoot.GetWidget("PLAYER_ROOT"); + ingameRoot = widget.Get("INGAME_ROOT"); + var playerRoot = ingameRoot.Get("PLAYER_ROOT"); // Observer if (world.LocalPlayer == null) @@ -100,7 +100,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic public void InitObserverWidgets(World world, Widget playerRoot) { var observerWidgets = Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs()); - observerWidgets.GetWidget("OPTIONS_BUTTON").OnClick = OptionsClicked; + observerWidgets.Get("OPTIONS_BUTTON").OnClick = OptionsClicked; } public void InitPlayerWidgets(World world, Widget playerRoot) @@ -109,29 +109,29 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs()); playerWidgets.IsVisible = () => true; - var sidebarRoot = playerWidgets.GetWidget("SIDEBAR_BACKGROUND"); + var sidebarRoot = playerWidgets.Get("SIDEBAR_BACKGROUND"); BindOrderButton(world, sidebarRoot, "SELL_BUTTON", "sell"); BindOrderButton(world, sidebarRoot, "REPAIR_BUTTON", "repair"); var playerResources = world.LocalPlayer.PlayerActor.Trait(); - sidebarRoot.GetWidget("CASH").GetText = () => + sidebarRoot.Get("CASH").GetText = () => "${0}".F(playerResources.DisplayCash + playerResources.DisplayOre); - queueTabs = playerWidgets.GetWidget("PRODUCTION_TABS"); + queueTabs = playerWidgets.Get("PRODUCTION_TABS"); world.ActorAdded += queueTabs.ActorChanged; world.ActorRemoved += queueTabs.ActorChanged; - var queueTypes = sidebarRoot.GetWidget("PRODUCTION_TYPES"); - SetupProductionGroupButton(queueTypes.GetWidget("BUILDING"), "Building"); - SetupProductionGroupButton(queueTypes.GetWidget("DEFENSE"), "Defense"); - SetupProductionGroupButton(queueTypes.GetWidget("INFANTRY"), "Infantry"); - SetupProductionGroupButton(queueTypes.GetWidget("VEHICLE"), "Vehicle"); - SetupProductionGroupButton(queueTypes.GetWidget("AIRCRAFT"), "Aircraft"); + var queueTypes = sidebarRoot.Get("PRODUCTION_TYPES"); + SetupProductionGroupButton(queueTypes.Get("BUILDING"), "Building"); + SetupProductionGroupButton(queueTypes.Get("DEFENSE"), "Defense"); + SetupProductionGroupButton(queueTypes.Get("INFANTRY"), "Infantry"); + SetupProductionGroupButton(queueTypes.Get("VEHICLE"), "Vehicle"); + SetupProductionGroupButton(queueTypes.Get("AIRCRAFT"), "Aircraft"); - playerWidgets.GetWidget("OPTIONS_BUTTON").OnClick = OptionsClicked; + playerWidgets.Get("OPTIONS_BUTTON").OnClick = OptionsClicked; - var cheatsButton = playerWidgets.GetWidget("CHEATS_BUTTON"); + var cheatsButton = playerWidgets.Get("CHEATS_BUTTON"); cheatsButton.OnClick = () => { if (menu != MenuType.None) @@ -142,7 +142,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }; cheatsButton.IsVisible = () => world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats; - var winLossWatcher = playerWidgets.GetWidget("WIN_LOSS_WATCHER"); + var winLossWatcher = playerWidgets.Get("WIN_LOSS_WATCHER"); winLossWatcher.OnTick = () => { if (world.LocalPlayer.WinState != WinState.Undefined) @@ -157,11 +157,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic static void BindOrderButton(World world, Widget parent, string button, string icon) where T : IOrderGenerator, new() { - var w = parent.GetWidget(button); + var w = parent.Get(button); w.OnClick = () => world.ToggleInputMode(); w.IsToggled = () => world.OrderGenerator is T; - w.GetWidget("ICON").GetImageName = + w.Get("ICON").GetImageName = () => world.OrderGenerator is T ? icon+"-active" : icon; } } diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs index 00657139f6..cac9e11e6e 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs @@ -23,14 +23,14 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic public CncIngameMenuLogic(Widget widget, World world, Action onExit) { var resumeDisabled = false; - menu = widget.GetWidget("INGAME_MENU"); + menu = widget.Get("INGAME_MENU"); var mpe = world.WorldActor.Trait(); mpe.Fade(CncMenuPaletteEffect.EffectType.Desaturated); - menu.GetWidget("VERSION_LABEL").GetText = WidgetUtils.ActiveModVersion; + menu.Get("VERSION_LABEL").GetText = WidgetUtils.ActiveModVersion; bool hideButtons = false; - menu.GetWidget("MENU_BUTTONS").IsVisible = () => !hideButtons; + menu.Get("MENU_BUTTONS").IsVisible = () => !hideButtons; // TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions Action onQuit = () => @@ -48,16 +48,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Action doNothing = () => {}; - menu.GetWidget("QUIT_BUTTON").OnClick = () => + menu.Get("QUIT_BUTTON").OnClick = () => CncWidgetUtils.PromptConfirmAction("Abort Mission", "Leave this game and return to the menu?", onQuit, doNothing); Action onSurrender = () => world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); - var surrenderButton = menu.GetWidget("SURRENDER_BUTTON"); + var surrenderButton = menu.Get("SURRENDER_BUTTON"); surrenderButton.IsDisabled = () => (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined); surrenderButton.OnClick = () => CncWidgetUtils.PromptConfirmAction("Surrender", "Are you sure you want to surrender?", onSurrender, doNothing); - menu.GetWidget("MUSIC_BUTTON").OnClick = () => + menu.Get("MUSIC_BUTTON").OnClick = () => { hideButtons = true; Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs() @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }); }; - menu.GetWidget("SETTINGS_BUTTON").OnClick = () => + menu.Get("SETTINGS_BUTTON").OnClick = () => { hideButtons = true; Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs() @@ -76,7 +76,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }); }; - var resumeButton = menu.GetWidget("RESUME_BUTTON"); + var resumeButton = menu.Get("RESUME_BUTTON"); resumeButton.IsDisabled = () => resumeDisabled; resumeButton.OnClick = () => { diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs index 76868856a2..5a435c8e99 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs @@ -36,17 +36,17 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic this.filesToExtract = filesToExtract; panel = widget; - progressBar = panel.GetWidget("PROGRESS_BAR"); - statusLabel = panel.GetWidget("STATUS_LABEL"); + progressBar = panel.Get("PROGRESS_BAR"); + statusLabel = panel.Get("STATUS_LABEL"); - backButton = panel.GetWidget("BACK_BUTTON"); + backButton = panel.Get("BACK_BUTTON"); backButton.OnClick = Ui.CloseWindow; - retryButton = panel.GetWidget("RETRY_BUTTON"); + retryButton = panel.Get("RETRY_BUTTON"); retryButton.OnClick = CheckForDisk; - installingContainer = panel.GetWidget("INSTALLING"); - insertDiskContainer = panel.GetWidget("INSERT_DISK"); + installingContainer = panel.Get("INSTALLING"); + insertDiskContainer = panel.Get("INSERT_DISK"); CheckForDisk(); } diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs index 91c1c32146..4d49ac346e 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs @@ -19,17 +19,17 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncInstallLogic(Widget widget, Dictionary installData, Action continueLoading) { - var panel = widget.GetWidget("INSTALL_PANEL"); + var panel = widget.Get("INSTALL_PANEL"); var args = new WidgetArgs() { { "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } }, { "installData", installData } }; - panel.GetWidget("DOWNLOAD_BUTTON").OnClick = () => + panel.Get("DOWNLOAD_BUTTON").OnClick = () => Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", args); - panel.GetWidget("INSTALL_BUTTON").OnClick = () => + panel.Get("INSTALL_BUTTON").OnClick = () => Ui.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs(args) { { "filesToCopy", new[] { "CONQUER.MIX", "DESERT.MIX", "SCORES.MIX", @@ -37,9 +37,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { "filesToExtract", new[] { "speech.mix", "tempicnh.mix", "transit.mix" } }, }); - panel.GetWidget("QUIT_BUTTON").OnClick = Game.Exit; + panel.Get("QUIT_BUTTON").OnClick = Game.Exit; - panel.GetWidget("MODS_BUTTON").OnClick = () => + panel.Get("MODS_BUTTON").OnClick = () => { Ui.OpenWindow("MODS_PANEL", new WidgetArgs() { diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs index 458b6276d8..dabf7b3cdc 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs @@ -27,17 +27,17 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic world.WorldActor.Trait() .Fade(CncMenuPaletteEffect.EffectType.Desaturated); - rootMenu = widget.GetWidget("MENU_BACKGROUND"); - rootMenu.GetWidget("VERSION_LABEL").GetText = WidgetUtils.ActiveModVersion; + rootMenu = widget.Get("MENU_BACKGROUND"); + rootMenu.Get("VERSION_LABEL").GetText = WidgetUtils.ActiveModVersion; // Menu buttons - var mainMenu = widget.GetWidget("MAIN_MENU"); + var mainMenu = widget.Get("MAIN_MENU"); mainMenu.IsVisible = () => Menu == MenuType.Main; - mainMenu.GetWidget("SOLO_BUTTON").OnClick = StartSkirmishGame; - mainMenu.GetWidget("MULTIPLAYER_BUTTON").OnClick = () => Menu = MenuType.Multiplayer; + mainMenu.Get("SOLO_BUTTON").OnClick = StartSkirmishGame; + mainMenu.Get("MULTIPLAYER_BUTTON").OnClick = () => Menu = MenuType.Multiplayer; - mainMenu.GetWidget("MODS_BUTTON").OnClick = () => + mainMenu.Get("MODS_BUTTON").OnClick = () => { Menu = MenuType.None; Ui.OpenWindow("MODS_PANEL", new WidgetArgs() @@ -47,23 +47,23 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }); }; - mainMenu.GetWidget("SETTINGS_BUTTON").OnClick = () => Menu = MenuType.Settings; - mainMenu.GetWidget("QUIT_BUTTON").OnClick = Game.Exit; + mainMenu.Get("SETTINGS_BUTTON").OnClick = () => Menu = MenuType.Settings; + mainMenu.Get("QUIT_BUTTON").OnClick = Game.Exit; // Multiplayer menu - var multiplayerMenu = widget.GetWidget("MULTIPLAYER_MENU"); + var multiplayerMenu = widget.Get("MULTIPLAYER_MENU"); multiplayerMenu.IsVisible = () => Menu == MenuType.Multiplayer; - multiplayerMenu.GetWidget("BACK_BUTTON").OnClick = () => Menu = MenuType.Main; - multiplayerMenu.GetWidget("JOIN_BUTTON").OnClick = () => OpenGamePanel("SERVERBROWSER_PANEL"); - multiplayerMenu.GetWidget("CREATE_BUTTON").OnClick = () => OpenGamePanel("CREATESERVER_PANEL"); - multiplayerMenu.GetWidget("DIRECTCONNECT_BUTTON").OnClick = () => OpenGamePanel("DIRECTCONNECT_PANEL"); + multiplayerMenu.Get("BACK_BUTTON").OnClick = () => Menu = MenuType.Main; + multiplayerMenu.Get("JOIN_BUTTON").OnClick = () => OpenGamePanel("SERVERBROWSER_PANEL"); + multiplayerMenu.Get("CREATE_BUTTON").OnClick = () => OpenGamePanel("CREATESERVER_PANEL"); + multiplayerMenu.Get("DIRECTCONNECT_BUTTON").OnClick = () => OpenGamePanel("DIRECTCONNECT_PANEL"); // Settings menu - var settingsMenu = widget.GetWidget("SETTINGS_MENU"); + var settingsMenu = widget.Get("SETTINGS_MENU"); settingsMenu.IsVisible = () => Menu == MenuType.Settings; - settingsMenu.GetWidget("REPLAYS_BUTTON").OnClick = () => + settingsMenu.Get("REPLAYS_BUTTON").OnClick = () => { Menu = MenuType.None; Ui.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs() @@ -73,7 +73,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }); }; - settingsMenu.GetWidget("MUSIC_BUTTON").OnClick = () => + settingsMenu.Get("MUSIC_BUTTON").OnClick = () => { Menu = MenuType.None; Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs() @@ -82,7 +82,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }); }; - settingsMenu.GetWidget("SETTINGS_BUTTON").OnClick = () => + settingsMenu.Get("SETTINGS_BUTTON").OnClick = () => { Menu = MenuType.None; Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs() @@ -92,9 +92,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }); }; - settingsMenu.GetWidget("BACK_BUTTON").OnClick = () => Menu = MenuType.Main; + settingsMenu.Get("BACK_BUTTON").OnClick = () => Menu = MenuType.Main; - rootMenu.GetWidget("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0; + rootMenu.Get("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0; } void OpenGamePanel(string id) diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs index 62f71c5ee6..14adc49af9 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs @@ -31,10 +31,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncMusicPlayerLogic(Widget widget, Action onExit) { - panel = widget.GetWidget("MUSIC_PANEL"); + panel = widget.Get("MUSIC_PANEL"); - var ml = panel.GetWidget("MUSIC_LIST"); - itemTemplate = ml.GetWidget("MUSIC_TEMPLATE"); + var ml = panel.Get("MUSIC_LIST"); + itemTemplate = ml.Get("MUSIC_TEMPLATE"); BuildMusicTable(ml); @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic installed = Rules.Music.Where(m => m.Value.Exists).Any(); Func noMusic = () => !installed; - panel.GetWidget("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; + panel.Get("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; Action afterInstall = () => { @@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic BuildMusicTable(ml); }; - var installButton = panel.GetWidget("INSTALL_BUTTON"); + var installButton = panel.Get("INSTALL_BUTTON"); installButton.OnClick = () => Ui.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() { { "afterInstall", afterInstall }, @@ -69,42 +69,42 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }); installButton.IsVisible = () => music.Length < 3; // Hack around music being split between transit.mix and scores.mix - panel.GetWidget("NO_MUSIC_LABEL").IsVisible = noMusic; + panel.Get("NO_MUSIC_LABEL").IsVisible = noMusic; - var playButton = panel.GetWidget("BUTTON_PLAY"); + var playButton = panel.Get("BUTTON_PLAY"); playButton.OnClick = Play; playButton.IsDisabled = noMusic; - var pauseButton = panel.GetWidget("BUTTON_PAUSE"); + var pauseButton = panel.Get("BUTTON_PAUSE"); pauseButton.OnClick = Pause; pauseButton.IsDisabled = noMusic; - var stopButton = panel.GetWidget("BUTTON_STOP"); + var stopButton = panel.Get("BUTTON_STOP"); stopButton.OnClick = Stop; stopButton.IsDisabled = noMusic; - var nextButton = panel.GetWidget("BUTTON_NEXT"); + var nextButton = panel.Get("BUTTON_NEXT"); nextButton.OnClick = () => { currentSong = GetNextSong(); Play(); }; nextButton.IsDisabled = noMusic; - var prevButton = panel.GetWidget("BUTTON_PREV"); + var prevButton = panel.Get("BUTTON_PREV"); prevButton.OnClick = () => { currentSong = GetPrevSong(); Play(); }; prevButton.IsDisabled = noMusic; - var shuffleCheckbox = panel.GetWidget("SHUFFLE"); + var shuffleCheckbox = panel.Get("SHUFFLE"); shuffleCheckbox.IsChecked = () => Game.Settings.Sound.Shuffle; shuffleCheckbox.OnClick = () => Game.Settings.Sound.Shuffle ^= true; - var repeatCheckbox = panel.GetWidget("REPEAT"); + var repeatCheckbox = panel.Get("REPEAT"); repeatCheckbox.IsChecked = () => Game.Settings.Sound.Repeat; repeatCheckbox.OnClick = () => Game.Settings.Sound.Repeat ^= true; - panel.GetWidget("TIME_LABEL").GetText = () => (currentSong == null) ? "" : + panel.Get("TIME_LABEL").GetText = () => (currentSong == null) ? "" : "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60, currentSong.Length / 60, currentSong.Length % 60); - panel.GetWidget("TITLE_LABEL").GetText = () => (currentSong == null) ? "" : currentSong.Title; + panel.Get("TITLE_LABEL").GetText = () => (currentSong == null) ? "" : currentSong.Title; - var musicSlider = panel.GetWidget("MUSIC_SLIDER"); + var musicSlider = panel.Get("MUSIC_SLIDER"); musicSlider.OnChange += x => Sound.MusicVolume = x; musicSlider.Value = Sound.MusicVolume; } @@ -122,8 +122,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic currentSong = song; var item = ScrollItemWidget.Setup(itemTemplate, () => currentSong == song, () => { currentSong = song; Play(); }); - item.GetWidget("TITLE").GetText = () => song.Title; - item.GetWidget("LENGTH").GetText = () => SongLengthLabel(song); + item.Get("TITLE").GetText = () => song.Title; + item.Get("LENGTH").GetText = () => SongLengthLabel(song); list.AddChild(item); } } @@ -140,22 +140,22 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Play(); }); - panel.GetWidget("BUTTON_PLAY").Visible = false; - panel.GetWidget("BUTTON_PAUSE").Visible = true; + panel.Get("BUTTON_PLAY").Visible = false; + panel.Get("BUTTON_PAUSE").Visible = true; } void Pause() { Sound.PauseMusic(); - panel.GetWidget("BUTTON_PAUSE").Visible = false; - panel.GetWidget("BUTTON_PLAY").Visible = true; + panel.Get("BUTTON_PAUSE").Visible = false; + panel.Get("BUTTON_PLAY").Visible = true; } void Stop() { Sound.StopMusic(); - panel.GetWidget("BUTTON_PAUSE").Visible = false; - panel.GetWidget("BUTTON_PLAY").Visible = true; + panel.Get("BUTTON_PAUSE").Visible = false; + panel.Get("BUTTON_PLAY").Visible = true; } string SongLengthLabel(MusicInfo song) diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncPerfDebugLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncPerfDebugLogic.cs index 3b0f17f30f..3d04cae420 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncPerfDebugLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncPerfDebugLogic.cs @@ -19,9 +19,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic public CncPerfDebugLogic(Widget widget) { // Performance info - var perfRoot = widget.GetWidget("PERFORMANCE_INFO"); + var perfRoot = widget.Get("PERFORMANCE_INFO"); perfRoot.IsVisible = () => Game.Settings.Debug.PerfGraph; - var text = perfRoot.GetWidget("PERF_TEXT"); + var text = perfRoot.Get("PERF_TEXT"); text.IsVisible = () => Game.Settings.Debug.PerfText; text.GetText = () => "Tick {0} @ {1:F1} ms\nRender {2} @ {3:F1} ms\nBatches: {4}".F( diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs index d3c9b97428..e71efe4de0 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs @@ -32,14 +32,14 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic public CncSettingsLogic(Widget widget, World world, Action onExit) { this.world = world; - var panel = widget.GetWidget("SETTINGS_PANEL"); + var panel = widget.Get("SETTINGS_PANEL"); // General pane - var generalButton = panel.GetWidget("GENERAL_BUTTON"); + var generalButton = panel.Get("GENERAL_BUTTON"); generalButton.OnClick = () => Settings = PanelType.General; generalButton.IsDisabled = () => Settings == PanelType.General; - var generalPane = panel.GetWidget("GENERAL_CONTROLS"); + var generalPane = panel.Get("GENERAL_CONTROLS"); generalPane.IsVisible = () => Settings == PanelType.General; var gameSettings = Game.Settings.Game; @@ -49,36 +49,36 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var soundSettings = Game.Settings.Sound; // Player profile - var nameTextfield = generalPane.GetWidget("NAME_TEXTFIELD"); + var nameTextfield = generalPane.Get("NAME_TEXTFIELD"); nameTextfield.Text = playerSettings.Name; playerPalettePreview = world.WorldActor.Trait(); playerPalettePreview.Ramp = playerSettings.ColorRamp; - var colorDropdown = generalPane.GetWidget("COLOR"); + var colorDropdown = generalPane.Get("COLOR"); colorDropdown.OnMouseDown = _ => ShowColorPicker(colorDropdown, playerSettings); - colorDropdown.GetWidget("COLORBLOCK").GetColor = () => playerSettings.ColorRamp.GetColor(0); + colorDropdown.Get("COLORBLOCK").GetColor = () => playerSettings.ColorRamp.GetColor(0); // Debug - var perftextCheckbox = generalPane.GetWidget("PERFTEXT_CHECKBOX"); + var perftextCheckbox = generalPane.Get("PERFTEXT_CHECKBOX"); perftextCheckbox.IsChecked = () => debugSettings.PerfText; perftextCheckbox.OnClick = () => debugSettings.PerfText ^= true; - var perfgraphCheckbox = generalPane.GetWidget("PERFGRAPH_CHECKBOX"); + var perfgraphCheckbox = generalPane.Get("PERFGRAPH_CHECKBOX"); perfgraphCheckbox.IsChecked = () => debugSettings.PerfGraph; perfgraphCheckbox.OnClick = () => debugSettings.PerfGraph ^= true; - var checkunsyncedCheckbox = generalPane.GetWidget("CHECKUNSYNCED_CHECKBOX"); + var checkunsyncedCheckbox = generalPane.Get("CHECKUNSYNCED_CHECKBOX"); checkunsyncedCheckbox.IsChecked = () => debugSettings.SanityCheckUnsyncedCode; checkunsyncedCheckbox.OnClick = () => debugSettings.SanityCheckUnsyncedCode ^= true; // Video - var windowModeDropdown = generalPane.GetWidget("MODE_DROPDOWN"); + var windowModeDropdown = generalPane.Get("MODE_DROPDOWN"); windowModeDropdown.OnMouseDown = _ => SettingsMenuLogic.ShowWindowModeDropdown(windowModeDropdown, graphicsSettings); windowModeDropdown.GetText = () => graphicsSettings.Mode == WindowMode.Windowed ? "Windowed" : graphicsSettings.Mode == WindowMode.Fullscreen ? "Fullscreen" : "Pseudo-Fullscreen"; - var pixelDoubleCheckbox = generalPane.GetWidget("PIXELDOUBLE_CHECKBOX"); + var pixelDoubleCheckbox = generalPane.Get("PIXELDOUBLE_CHECKBOX"); pixelDoubleCheckbox.IsChecked = () => graphicsSettings.PixelDouble; pixelDoubleCheckbox.OnClick = () => { @@ -86,53 +86,53 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Game.viewport.Zoom = graphicsSettings.PixelDouble ? 2 : 1; }; - generalPane.GetWidget("WINDOW_RESOLUTION").IsVisible = () => graphicsSettings.Mode == WindowMode.Windowed; - var windowWidth = generalPane.GetWidget("WINDOW_WIDTH"); + generalPane.Get("WINDOW_RESOLUTION").IsVisible = () => graphicsSettings.Mode == WindowMode.Windowed; + var windowWidth = generalPane.Get("WINDOW_WIDTH"); windowWidth.Text = graphicsSettings.WindowedSize.X.ToString(); - var windowHeight = generalPane.GetWidget("WINDOW_HEIGHT"); + var windowHeight = generalPane.Get("WINDOW_HEIGHT"); windowHeight.Text = graphicsSettings.WindowedSize.Y.ToString(); // Audio - var soundSlider = generalPane.GetWidget("SOUND_SLIDER"); + var soundSlider = generalPane.Get("SOUND_SLIDER"); soundSlider.OnChange += x => { soundSettings.SoundVolume = x; Sound.SoundVolume = x;}; soundSlider.Value = soundSettings.SoundVolume; - var musicSlider = generalPane.GetWidget("MUSIC_SLIDER"); + var musicSlider = generalPane.Get("MUSIC_SLIDER"); musicSlider.OnChange += x => { soundSettings.MusicVolume = x; Sound.MusicVolume = x; }; musicSlider.Value = soundSettings.MusicVolume; - var shellmapMusicCheckbox = generalPane.GetWidget("SHELLMAP_MUSIC"); + var shellmapMusicCheckbox = generalPane.Get("SHELLMAP_MUSIC"); shellmapMusicCheckbox.IsChecked = () => soundSettings.ShellmapMusic; shellmapMusicCheckbox.OnClick = () => soundSettings.ShellmapMusic ^= true; // Input pane - var inputPane = panel.GetWidget("INPUT_CONTROLS"); + var inputPane = panel.Get("INPUT_CONTROLS"); inputPane.IsVisible = () => Settings == PanelType.Input; - var inputButton = panel.GetWidget("INPUT_BUTTON"); + var inputButton = panel.Get("INPUT_BUTTON"); inputButton.OnClick = () => Settings = PanelType.Input; inputButton.IsDisabled = () => Settings == PanelType.Input; - inputPane.GetWidget("CLASSICORDERS_CHECKBOX").IsDisabled = () => true; + inputPane.Get("CLASSICORDERS_CHECKBOX").IsDisabled = () => true; - var scrollSlider = inputPane.GetWidget("SCROLLSPEED_SLIDER"); + var scrollSlider = inputPane.Get("SCROLLSPEED_SLIDER"); scrollSlider.Value = gameSettings.ViewportEdgeScrollStep; scrollSlider.OnChange += x => gameSettings.ViewportEdgeScrollStep = x; - var edgescrollCheckbox = inputPane.GetWidget("EDGESCROLL_CHECKBOX"); + var edgescrollCheckbox = inputPane.Get("EDGESCROLL_CHECKBOX"); edgescrollCheckbox.IsChecked = () => gameSettings.ViewportEdgeScroll; edgescrollCheckbox.OnClick = () => gameSettings.ViewportEdgeScroll ^= true; - var mouseScrollDropdown = inputPane.GetWidget("MOUSE_SCROLL"); + var mouseScrollDropdown = inputPane.Get("MOUSE_SCROLL"); mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown, gameSettings); mouseScrollDropdown.GetText = () => gameSettings.MouseScroll.ToString(); - var teamchatCheckbox = inputPane.GetWidget("TEAMCHAT_CHECKBOX"); + var teamchatCheckbox = inputPane.Get("TEAMCHAT_CHECKBOX"); teamchatCheckbox.IsChecked = () => gameSettings.TeamChatToggle; teamchatCheckbox.OnClick = () => gameSettings.TeamChatToggle ^= true; - panel.GetWidget("BACK_BUTTON").OnClick = () => + panel.Get("BACK_BUTTON").OnClick = () => { playerSettings.Name = nameTextfield.Text; int x, y; @@ -175,7 +175,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var item = ScrollItemWidget.Setup(itemTemplate, () => s.MouseScroll == options[o], () => s.MouseScroll = options[o]); - item.GetWidget("LABEL").GetText = () => o; + item.Get("LABEL").GetText = () => o; return item; }; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs index 3a320ee12b..5870a9df0c 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs @@ -27,11 +27,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var pr = palette.world.LocalPlayer.PlayerActor.Trait(); widget.IsVisible = () => palette.TooltipActor != null; - var nameLabel = widget.GetWidget("NAME"); - var requiresLabel = widget.GetWidget("REQUIRES"); - var powerLabel = widget.GetWidget("POWER"); - var timeLabel = widget.GetWidget("TIME"); - var costLabel = widget.GetWidget("COST"); + var nameLabel = widget.Get("NAME"); + var requiresLabel = widget.Get("REQUIRES"); + var powerLabel = widget.Get("POWER"); + var timeLabel = widget.Get("TIME"); + var costLabel = widget.Get("COST"); var font = Game.Renderer.Fonts[nameLabel.Font]; var requiresFont = Game.Renderer.Fonts[requiresLabel.Font]; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/SimpleTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/SimpleTooltipLogic.cs index d3b4b18f18..3939b26bce 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/SimpleTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/SimpleTooltipLogic.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public SimpleTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, Func getText) { - var label = widget.GetWidget("LABEL"); + var label = widget.Get("LABEL"); var font = Game.Renderer.Fonts[label.Font]; var cachedWidth = 0; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs index b7bb75d3ee..37f285b449 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs @@ -20,9 +20,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic public SupportPowerTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, SupportPowersWidget palette) { widget.IsVisible = () => palette.TooltipPower != null; - var nameLabel = widget.GetWidget("NAME"); - var timeLabel = widget.GetWidget("TIME"); - var descLabel = widget.GetWidget("DESC"); + var nameLabel = widget.Get("NAME"); + var timeLabel = widget.Get("TIME"); + var descLabel = widget.Get("DESC"); var nameFont = Game.Renderer.Fonts[nameLabel.Font]; var timeFont = Game.Renderer.Fonts[timeLabel.Font]; var descFont = Game.Renderer.Fonts[descLabel.Font]; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs index f4a55feded..978316a383 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs @@ -20,9 +20,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic public WorldTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, CncWorldInteractionControllerWidget wic) { widget.IsVisible = () => wic.TooltipType != WorldTooltipType.None; - var label = widget.GetWidget("LABEL"); - var flag = widget.GetWidget("FLAG"); - var owner = widget.GetWidget("OWNER"); + var label = widget.Get("LABEL"); + var flag = widget.Get("FLAG"); + var owner = widget.Get("OWNER"); var font = Game.Renderer.Fonts[label.Font]; var ownerFont = Game.Renderer.Fonts[owner.Font]; diff --git a/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs b/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs index 97da7eed72..3eba0d4415 100755 --- a/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc.Widgets { pm = world.LocalPlayer.PlayerActor.Trait(); tooltipContainer = Lazy.New(() => - Ui.Root.GetWidget(TooltipContainer)); + Ui.Root.Get(TooltipContainer)); } public override void MouseEntered() diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs index 3952998cfd..b921634394 100755 --- a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs @@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets this.world = world; this.worldRenderer = worldRenderer; tooltipContainer = Lazy.New(() => - Ui.Root.GetWidget(TooltipContainer)); + Ui.Root.Get(TooltipContainer)); cantBuild = new Animation("clock"); cantBuild.PlayFetchIndex("idle", () => 0); diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs index a2c5ae5f3c..10e3fb0090 100755 --- a/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs @@ -86,7 +86,7 @@ namespace OpenRA.Mods.Cnc.Widgets // Only visible if the production palette has icons to display IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0; - paletteWidget = Lazy.New(() => Ui.Root.GetWidget(PaletteWidget)); + paletteWidget = Lazy.New(() => Ui.Root.Get(PaletteWidget)); } public void SelectNextTab(bool reverse) diff --git a/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs b/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs index 0c3b8b5e2d..5fe546bfb1 100755 --- a/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc.Widgets { pr = world.LocalPlayer.PlayerActor.Trait(); tooltipContainer = Lazy.New(() => - Ui.Root.GetWidget(TooltipContainer)); + Ui.Root.Get(TooltipContainer)); } public override void MouseEntered() diff --git a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs index 8ffad9858d..c7bd81d4cd 100755 --- a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Cnc.Widgets this.worldRenderer = worldRenderer; spm = world.LocalPlayer.PlayerActor.Trait(); tooltipContainer = Lazy.New(() => - Ui.Root.GetWidget(TooltipContainer)); + Ui.Root.Get(TooltipContainer)); iconSprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface() ) .Select(u => u.Image).Distinct() diff --git a/OpenRA.Mods.Cnc/Widgets/ToggleButtonWidget.cs b/OpenRA.Mods.Cnc/Widgets/ToggleButtonWidget.cs index 32ab01cd8b..4b46a67956 100644 --- a/OpenRA.Mods.Cnc/Widgets/ToggleButtonWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ToggleButtonWidget.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets : base() { tooltipContainer = Lazy.New(() => - Ui.Root.GetWidget(TooltipContainer)); + Ui.Root.Get(TooltipContainer)); } protected ToggleButtonWidget(ToggleButtonWidget other) @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Cnc.Widgets TooltipText = other.TooltipText; TooltipContainer = other.TooltipContainer; tooltipContainer = Lazy.New(() => - Ui.Root.GetWidget(TooltipContainer)); + Ui.Root.Get(TooltipContainer)); } public override void MouseEntered() diff --git a/OpenRA.Mods.RA/Scripting/Media.cs b/OpenRA.Mods.RA/Scripting/Media.cs index d08c8dbcae..d403d9c945 100644 --- a/OpenRA.Mods.RA/Scripting/Media.cs +++ b/OpenRA.Mods.RA/Scripting/Media.cs @@ -18,7 +18,7 @@ namespace OpenRA.Scripting public static void PlayFMVFullscreen(World w, string movie, Action onComplete) { var playerRoot = Game.OpenWindow(w, "FMVPLAYER"); - var player = playerRoot.GetWidget("PLAYER"); + var player = playerRoot.Get("PLAYER"); w.EnableTick = false; player.Load(movie); diff --git a/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs index f07d7db388..e9c4b2defd 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs @@ -22,41 +22,41 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var devTrait = world.LocalPlayer.PlayerActor.Trait(); - var shroudCheckbox = widget.GetWidget("DISABLE_SHROUD"); + var shroudCheckbox = widget.Get("DISABLE_SHROUD"); shroudCheckbox.IsChecked = () => devTrait.DisableShroud; shroudCheckbox.OnClick = () => Order(world, "DevShroud"); - var pathCheckbox = widget.GetWidget("SHOW_UNIT_PATHS"); + var pathCheckbox = widget.Get("SHOW_UNIT_PATHS"); pathCheckbox.IsChecked = () => devTrait.PathDebug; pathCheckbox.OnClick = () => Order(world, "DevPathDebug"); - widget.GetWidget("GIVE_CASH").OnClick = () => + widget.Get("GIVE_CASH").OnClick = () => world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false)); - var fastBuildCheckbox = widget.GetWidget("INSTANT_BUILD"); + var fastBuildCheckbox = widget.Get("INSTANT_BUILD"); fastBuildCheckbox.IsChecked = () => devTrait.FastBuild; fastBuildCheckbox.OnClick = () => Order(world, "DevFastBuild"); - var fastChargeCheckbox = widget.GetWidget("INSTANT_CHARGE"); + var fastChargeCheckbox = widget.Get("INSTANT_CHARGE"); fastChargeCheckbox.IsChecked = () => devTrait.FastCharge; fastChargeCheckbox.OnClick = () => Order(world, "DevFastCharge"); - var allTechCheckbox = widget.GetWidget("ENABLE_TECH"); + var allTechCheckbox = widget.Get("ENABLE_TECH"); allTechCheckbox.IsChecked = () => devTrait.AllTech; allTechCheckbox.OnClick = () => Order(world, "DevEnableTech"); - var powerCheckbox = widget.GetWidget("UNLIMITED_POWER"); + var powerCheckbox = widget.Get("UNLIMITED_POWER"); powerCheckbox.IsChecked = () => devTrait.UnlimitedPower; powerCheckbox.OnClick = () => Order(world, "DevUnlimitedPower"); - var buildAnywhereCheckbox = widget.GetWidget("BUILD_ANYWHERE"); + var buildAnywhereCheckbox = widget.Get("BUILD_ANYWHERE"); buildAnywhereCheckbox.IsChecked = () => devTrait.BuildAnywhere; buildAnywhereCheckbox.OnClick = () => Order(world, "DevBuildAnywhere"); - widget.GetWidget("GIVE_EXPLORATION").OnClick = () => + widget.Get("GIVE_EXPLORATION").OnClick = () => world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false)); - widget.GetWidget("CLOSE").OnClick = () => { Ui.CloseWindow(); onExit(); }; + widget.Get("CLOSE").OnClick = () => { Ui.CloseWindow(); onExit(); }; } public void Order(World world, string order) diff --git a/OpenRA.Mods.RA/Widgets/Logic/ColorPickerLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ColorPickerLogic.cs index 0c5e520d4a..b539e8b8e9 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ColorPickerLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ColorPickerLogic.cs @@ -25,9 +25,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var panel = widget; ramp = initialRamp; - var hueSlider = panel.GetWidget("HUE"); - var satSlider = panel.GetWidget("SAT"); - var lumSlider = panel.GetWidget("LUM"); + var hueSlider = panel.Get("HUE"); + var satSlider = panel.Get("SAT"); + var lumSlider = panel.Get("LUM"); Action sliderChanged = () => { @@ -49,9 +49,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic lumSlider.Value = ramp.L / 255f; }; - panel.GetWidget("SAVE_BUTTON").OnClick = () => onSelect(ramp); + panel.Get("SAVE_BUTTON").OnClick = () => onSelect(ramp); - var randomButton = panel.GetWidget("RANDOM_BUTTON"); + var randomButton = panel.Get("RANDOM_BUTTON"); if (randomButton != null) randomButton.OnClick = () => { diff --git a/OpenRA.Mods.RA/Widgets/Logic/ConnectionLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ConnectionLogic.cs index 3afb99aba8..43ed14b4d0 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ConnectionLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ConnectionLogic.cs @@ -59,9 +59,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic Game.ConnectionStateChanged += ConnectionStateChanged; var panel = widget; - panel.GetWidget("ABORT_BUTTON").OnClick = () => { CloseWindow(); onAbort(); }; + panel.Get("ABORT_BUTTON").OnClick = () => { CloseWindow(); onAbort(); }; - widget.GetWidget("CONNECTING_DESC").GetText = () => + widget.Get("CONNECTING_DESC").GetText = () => "Connecting to {0}:{1}...".F(host, port); } @@ -85,10 +85,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic public ConnectionFailedLogic(Widget widget, string host, int port, Action onRetry, Action onAbort) { var panel = widget; - panel.GetWidget("ABORT_BUTTON").OnClick = () => { Ui.CloseWindow(); onAbort(); }; - panel.GetWidget("RETRY_BUTTON").OnClick = () => { Ui.CloseWindow(); onRetry(); }; + panel.Get("ABORT_BUTTON").OnClick = () => { Ui.CloseWindow(); onAbort(); }; + panel.Get("RETRY_BUTTON").OnClick = () => { Ui.CloseWindow(); onRetry(); }; - widget.GetWidget("CONNECTING_DESC").GetText = () => + widget.Get("CONNECTING_DESC").GetText = () => "Could not connect to {0}:{1}".F(host, port); } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs index 7b317ce6db..ea12dc4de9 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs @@ -28,9 +28,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic public DiplomacyLogic(World world) { this.world = world; - var root = Ui.Root.GetWidget("INGAME_ROOT"); - var diplomacyBG = root.GetWidget("DIPLOMACY_BG"); - var diplomacy = root.GetWidget("INGAME_DIPLOMACY_BUTTON"); + var root = Ui.Root.Get("INGAME_ROOT"); + var diplomacyBG = root.Get("DIPLOMACY_BG"); + var diplomacy = root.Get("INGAME_DIPLOMACY_BUTTON"); diplomacy.OnClick = () => { @@ -129,7 +129,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic () => s == world.LocalPlayer.Stances[ p ], () => SetStance(dropdown, p, s)); - item.GetWidget("LABEL").GetText = () => s.ToString(); + item.Get("LABEL").GetText = () => s.ToString(); return item; }; diff --git a/OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs index 23b8b69914..098892a2b2 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs @@ -19,14 +19,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic public DirectConnectLogic(Widget widget, Action onExit, Action openLobby) { var panel = widget; - var ipField = panel.GetWidget("IP"); - var portField = panel.GetWidget("PORT"); + var ipField = panel.Get("IP"); + var portField = panel.Get("PORT"); var last = Game.Settings.Player.LastServer.Split(':'); ipField.Text = last.Length > 1 ? last[0] : "localhost"; portField.Text = last.Length > 2 ? last[1] : "1234"; - panel.GetWidget("JOIN_BUTTON").OnClick = () => + panel.Get("JOIN_BUTTON").OnClick = () => { var port = Exts.WithDefault(1234, () => int.Parse(portField.Text)); @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic ConnectionLogic.Connect(ipField.Text, port, openLobby, onExit); }; - panel.GetWidget("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; + panel.Get("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs index 2d86351484..7e18a35525 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/DownloadPackagesLogic.cs @@ -33,9 +33,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic this.installData = installData; this.afterInstall = afterInstall; - panel = widget.GetWidget("INSTALL_DOWNLOAD_PANEL"); - progressBar = panel.GetWidget("PROGRESS_BAR"); - statusLabel = panel.GetWidget("STATUS_LABEL"); + panel = widget.Get("INSTALL_DOWNLOAD_PANEL"); + progressBar = panel.Get("PROGRESS_BAR"); + statusLabel = panel.Get("STATUS_LABEL"); ShowDownloadDialog(); } @@ -44,10 +44,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic { statusLabel.GetText = () => "Initializing..."; progressBar.SetIndeterminate(true); - var retryButton = panel.GetWidget("RETRY_BUTTON"); + var retryButton = panel.Get("RETRY_BUTTON"); retryButton.IsVisible = () => false; - var cancelButton = panel.GetWidget("CANCEL_BUTTON"); + var cancelButton = panel.Get("CANCEL_BUTTON"); // Save the package to a temp file var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs index 07608f583e..b9e17cfb6d 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs @@ -25,38 +25,38 @@ namespace OpenRA.Mods.RA.Widgets.Logic Game.BeforeGameStart += UnregisterEvents; var r = Ui.Root; - gameRoot = r.GetWidget("INGAME_ROOT"); - var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG"); + gameRoot = r.Get("INGAME_ROOT"); + var optionsBG = gameRoot.Get("INGAME_OPTIONS_BG"); - r.GetWidget("INGAME_OPTIONS_BUTTON").OnClick = () => + r.Get("INGAME_OPTIONS_BUTTON").OnClick = () => optionsBG.Visible = !optionsBG.Visible; - var cheatsButton = gameRoot.GetWidget("CHEATS_BUTTON"); + var cheatsButton = gameRoot.Get("CHEATS_BUTTON"); cheatsButton.OnClick = () => { Game.OpenWindow("CHEATS_PANEL", new WidgetArgs() {{"onExit", () => {} }}); }; cheatsButton.IsVisible = () => world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats; - optionsBG.GetWidget("DISCONNECT").OnClick = () => LeaveGame(optionsBG); + optionsBG.Get("DISCONNECT").OnClick = () => LeaveGame(optionsBG); - optionsBG.GetWidget("SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU"); - optionsBG.GetWidget("MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU"); - optionsBG.GetWidget("RESUME").OnClick = () => optionsBG.Visible = false; + optionsBG.Get("SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU"); + optionsBG.Get("MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU"); + optionsBG.Get("RESUME").OnClick = () => optionsBG.Visible = false; - optionsBG.GetWidget("SURRENDER").OnClick = () => + optionsBG.Get("SURRENDER").OnClick = () => { optionsBG.Visible = false; world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); }; - optionsBG.GetWidget("SURRENDER").IsVisible = () => (world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined); + optionsBG.Get("SURRENDER").IsVisible = () => (world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined); - var postgameBG = gameRoot.GetWidget("POSTGAME_BG"); - var postgameText = postgameBG.GetWidget("TEXT"); - var postGameObserve = postgameBG.GetWidget("POSTGAME_OBSERVE"); + var postgameBG = gameRoot.Get("POSTGAME_BG"); + var postgameText = postgameBG.Get("TEXT"); + var postGameObserve = postgameBG.Get("POSTGAME_OBSERVE"); - var postgameQuit = postgameBG.GetWidget("POSTGAME_QUIT"); + var postgameQuit = postgameBG.Get("POSTGAME_QUIT"); postgameQuit.OnClick = () => LeaveGame(postgameQuit); postGameObserve.OnClick = () => postgameQuit.Visible = false; @@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic void AddChatLine(Color c, string from, string text) { - gameRoot.GetWidget("CHAT_DISPLAY").AddLine(c, from, text); + gameRoot.Get("CHAT_DISPLAY").AddLine(c, from, text); } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameObserverChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameObserverChromeLogic.cs index 941e31a787..7fb99de8fe 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/IngameObserverChromeLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/IngameObserverChromeLogic.cs @@ -26,13 +26,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic Game.BeforeGameStart += UnregisterEvents; var r = Ui.Root; - gameRoot = r.GetWidget("OBSERVER_ROOT"); - var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG"); + gameRoot = r.Get("OBSERVER_ROOT"); + var optionsBG = gameRoot.Get("INGAME_OPTIONS_BG"); - r.GetWidget("INGAME_OPTIONS_BUTTON").OnClick = () => + r.Get("INGAME_OPTIONS_BUTTON").OnClick = () => optionsBG.Visible = !optionsBG.Visible; - optionsBG.GetWidget("DISCONNECT").OnClick = () => + optionsBG.Get("DISCONNECT").OnClick = () => { optionsBG.Visible = false; Game.Disconnect(); @@ -41,10 +41,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic Ui.OpenWindow("MAINMENU_BG"); }; - optionsBG.GetWidget("SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU"); - optionsBG.GetWidget("MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU"); - optionsBG.GetWidget("RESUME").OnClick = () => optionsBG.Visible = false; - optionsBG.GetWidget("SURRENDER").IsVisible = () => false; + optionsBG.Get("SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU"); + optionsBG.Get("MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU"); + optionsBG.Get("RESUME").OnClick = () => optionsBG.Visible = false; + optionsBG.Get("SURRENDER").IsVisible = () => false; } void UnregisterEvents() @@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic void AddChatLine(Color c, string from, string text) { - gameRoot.GetWidget("CHAT_DISPLAY").AddLine(c, from, text); + gameRoot.Get("CHAT_DISPLAY").AddLine(c, from, text); } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index 631a022089..2cb45a5bab 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -98,21 +98,21 @@ namespace OpenRA.Mods.RA.Widgets.Logic UpdateCurrentMap(); PlayerPalettePreview = world.WorldActor.Trait(); PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp; - Players = lobby.GetWidget("PLAYERS"); - EditablePlayerTemplate = Players.GetWidget("TEMPLATE_EDITABLE_PLAYER"); - NonEditablePlayerTemplate = Players.GetWidget("TEMPLATE_NONEDITABLE_PLAYER"); - EmptySlotTemplate = Players.GetWidget("TEMPLATE_EMPTY"); - EditableSpectatorTemplate = Players.GetWidget("TEMPLATE_EDITABLE_SPECTATOR"); - NonEditableSpectatorTemplate = Players.GetWidget("TEMPLATE_NONEDITABLE_SPECTATOR"); - NewSpectatorTemplate = Players.GetWidget("TEMPLATE_NEW_SPECTATOR"); + Players = lobby.Get("PLAYERS"); + EditablePlayerTemplate = Players.Get("TEMPLATE_EDITABLE_PLAYER"); + NonEditablePlayerTemplate = Players.Get("TEMPLATE_NONEDITABLE_PLAYER"); + EmptySlotTemplate = Players.Get("TEMPLATE_EMPTY"); + EditableSpectatorTemplate = Players.Get("TEMPLATE_EDITABLE_SPECTATOR"); + NonEditableSpectatorTemplate = Players.Get("TEMPLATE_NONEDITABLE_SPECTATOR"); + NewSpectatorTemplate = Players.Get("TEMPLATE_NEW_SPECTATOR"); - var mapPreview = lobby.GetWidget("MAP_PREVIEW"); + var mapPreview = lobby.Get("MAP_PREVIEW"); mapPreview.IsVisible = () => Map != null; mapPreview.Map = () => Map; mapPreview.OnMouseDown = mi => LobbyUtils.SelectSpawnPoint( orderManager, mapPreview, Map, mi ); mapPreview.SpawnColors = () => LobbyUtils.GetSpawnColors( orderManager, Map ); - var mapTitle = lobby.GetWidget("MAP_TITLE"); + var mapTitle = lobby.GetOrNull("MAP_TITLE"); if (mapTitle != null) { mapTitle.IsVisible = () => Map != null; @@ -124,7 +124,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic .ToDictionary(a => a.Race, a => a.Name); CountryNames.Add("random", "Any"); - var mapButton = lobby.GetWidget("CHANGEMAP_BUTTON"); + var mapButton = lobby.Get("CHANGEMAP_BUTTON"); mapButton.OnClick = () => { var onSelect = new Action(m => @@ -143,19 +143,19 @@ namespace OpenRA.Mods.RA.Widgets.Logic }; mapButton.IsVisible = () => mapButton.Visible && Game.IsHost; - var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON"); + var disconnectButton = lobby.Get("DISCONNECT_BUTTON"); disconnectButton.OnClick = () => { CloseWindow(); onExit(); }; var gameStarting = false; - var allowCheats = lobby.GetWidget("ALLOWCHEATS_CHECKBOX"); + var allowCheats = lobby.Get("ALLOWCHEATS_CHECKBOX"); allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats; allowCheats.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null || orderManager.LocalClient.IsReady; allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command( "allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats))); - var startGameButton = lobby.GetWidget("START_GAME_BUTTON"); + var startGameButton = lobby.Get("START_GAME_BUTTON"); startGameButton.IsVisible = () => Game.IsHost; startGameButton.IsDisabled = () => gameStarting; startGameButton.OnClick = () => @@ -165,8 +165,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic }; bool teamChat = false; - var chatLabel = lobby.GetWidget("LABEL_CHATTYPE"); - var chatTextField = lobby.GetWidget("CHAT_TEXTFIELD"); + var chatLabel = lobby.Get("LABEL_CHATTYPE"); + var chatTextField = lobby.Get("CHAT_TEXTFIELD"); chatTextField.OnEnterKey = () => { @@ -185,11 +185,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic return true; }; - chatPanel = lobby.GetWidget("CHAT_DISPLAY"); - chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE"); + chatPanel = lobby.Get("CHAT_DISPLAY"); + chatTemplate = chatPanel.Get("CHAT_TEMPLATE"); chatPanel.RemoveChildren(); - var musicButton = lobby.GetWidget("MUSIC_BUTTON"); + var musicButton = lobby.GetOrNull("MUSIC_BUTTON"); if (musicButton != null) musicButton.OnClick = () => Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs { { "onExit", () => {} } }); @@ -208,9 +208,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic void AddChatLine(Color c, string from, string text) { var template = chatTemplate.Clone(); - var nameLabel = template.GetWidget("NAME"); - var timeLabel = template.GetWidget("TIME"); - var textLabel = template.GetWidget("TEXT"); + var nameLabel = template.Get("NAME"); + var timeLabel = template.Get("TIME"); + var textLabel = template.Get("TEXT"); var name = from + ":"; var font = Game.Renderer.Fonts[nameLabel.Font]; @@ -246,7 +246,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic MapUid = orderManager.LobbyInfo.GlobalSettings.Map; Map = new Map(Game.modData.AvailableMaps[MapUid].Path); - var title = Ui.Root.GetWidget("TITLE"); + var title = Ui.Root.Get("TITLE"); title.Text = orderManager.LobbyInfo.GlobalSettings.ServerName; } @@ -272,7 +272,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (Game.IsHost) { - var name = template.GetWidget("NAME_HOST"); + var name = template.Get("NAME_HOST"); name.IsVisible = () => true; name.IsDisabled = () => ready; name.GetText = getText; @@ -280,12 +280,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic } else { - var name = template.GetWidget("NAME"); + var name = template.Get("NAME"); name.IsVisible = () => true; name.GetText = getText; } - var join = template.GetWidget("JOIN"); + var join = template.Get("JOIN"); join.IsVisible = () => !slot.Closed; join.IsDisabled = () => ready; join.OnClick = () => orderManager.IssueOrder(Order.Command("slot " + key)); @@ -300,7 +300,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (client.Bot != null) { - var name = template.GetWidget("BOT_DROPDOWN"); + var name = template.Get("BOT_DROPDOWN"); name.IsVisible = () => true; name.IsDisabled = () => ready; name.GetText = () => client.Name; @@ -308,30 +308,30 @@ namespace OpenRA.Mods.RA.Widgets.Logic } else { - var name = template.GetWidget("NAME"); + var name = template.Get("NAME"); name.IsVisible = () => true; name.IsDisabled = () => ready; LobbyUtils.SetupNameWidget(orderManager, client, name); } - var color = template.GetWidget("COLOR"); + var color = template.Get("COLOR"); color.IsDisabled = () => slot.LockColor || ready; color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, client, orderManager, PlayerPalettePreview); - var colorBlock = color.GetWidget("COLORBLOCK"); + var colorBlock = color.Get("COLORBLOCK"); colorBlock.GetColor = () => client.ColorRamp.GetColor(0); - var faction = template.GetWidget("FACTION"); + var faction = template.Get("FACTION"); faction.IsDisabled = () => slot.LockRace || ready; faction.OnMouseDown = _ => LobbyUtils.ShowRaceDropDown(faction, client, orderManager, CountryNames); - var factionname = faction.GetWidget("FACTIONNAME"); + var factionname = faction.Get("FACTIONNAME"); factionname.GetText = () => CountryNames[client.Country]; - var factionflag = faction.GetWidget("FACTIONFLAG"); + var factionflag = faction.Get("FACTIONFLAG"); factionflag.GetImageName = () => client.Country; factionflag.GetImageCollection = () => "flags"; - var team = template.GetWidget("TEAM"); + var team = template.Get("TEAM"); team.IsDisabled = () => slot.LockTeam || ready; team.OnMouseDown = _ => LobbyUtils.ShowTeamDropDown(team, client, orderManager, Map); team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString(); @@ -339,35 +339,35 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (client.Bot == null) { // local player - var status = template.GetWidget("STATUS_CHECKBOX"); + var status = template.Get("STATUS_CHECKBOX"); status.IsChecked = () => ready; status.IsVisible = () => true; status.OnClick += CycleReady; } else // Bot - template.GetWidget("STATUS_IMAGE").IsVisible = () => true; + template.Get("STATUS_IMAGE").IsVisible = () => true; } else { // Non-editable player in slot template = NonEditablePlayerTemplate.Clone(); - template.GetWidget("NAME").GetText = () => client.Name; - var color = template.GetWidget("COLOR"); + template.Get("NAME").GetText = () => client.Name; + var color = template.Get("COLOR"); color.GetColor = () => client.ColorRamp.GetColor(0); - var faction = template.GetWidget("FACTION"); - var factionname = faction.GetWidget("FACTIONNAME"); + var faction = template.Get("FACTION"); + var factionname = faction.Get("FACTIONNAME"); factionname.GetText = () => CountryNames[client.Country]; - var factionflag = faction.GetWidget("FACTIONFLAG"); + var factionflag = faction.Get("FACTIONFLAG"); factionflag.GetImageName = () => client.Country; factionflag.GetImageCollection = () => "flags"; - var team = template.GetWidget("TEAM"); + var team = template.Get("TEAM"); team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString(); - template.GetWidget("STATUS_IMAGE").IsVisible = () => + template.Get("STATUS_IMAGE").IsVisible = () => client.Bot != null || client.IsReady; - var kickButton = template.GetWidget("KICK"); + var kickButton = template.Get("KICK"); kickButton.IsVisible = () => Game.IsHost && client.Index != orderManager.LocalClient.Index; kickButton.IsDisabled = () => orderManager.LocalClient.IsReady; kickButton.OnClick = () => orderManager.IssueOrder(Order.Command("kick " + client.Index)); @@ -388,18 +388,18 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (c.Index == orderManager.LocalClient.Index) { template = EditableSpectatorTemplate.Clone(); - var name = template.GetWidget("NAME"); + var name = template.Get("NAME"); name.IsDisabled = () => ready; LobbyUtils.SetupNameWidget(orderManager, c, name); - var color = template.GetWidget("COLOR"); + var color = template.Get("COLOR"); color.IsDisabled = () => ready; color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, c, orderManager, PlayerPalettePreview); - var colorBlock = color.GetWidget("COLORBLOCK"); + var colorBlock = color.Get("COLORBLOCK"); colorBlock.GetColor = () => c.ColorRamp.GetColor(0); - var status = template.GetWidget("STATUS_CHECKBOX"); + var status = template.Get("STATUS_CHECKBOX"); status.IsChecked = () => ready; status.OnClick += CycleReady; } @@ -407,13 +407,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic else { template = NonEditableSpectatorTemplate.Clone(); - template.GetWidget("NAME").GetText = () => c.Name; - var color = template.GetWidget("COLOR"); + template.Get("NAME").GetText = () => c.Name; + var color = template.Get("COLOR"); color.GetColor = () => c.ColorRamp.GetColor(0); - template.GetWidget("STATUS_IMAGE").IsVisible = () => c.Bot != null || c.IsReady; + template.Get("STATUS_IMAGE").IsVisible = () => c.Bot != null || c.IsReady; - var kickButton = template.GetWidget("KICK"); + var kickButton = template.Get("KICK"); kickButton.IsVisible = () => Game.IsHost && c.Index != orderManager.LocalClient.Index; kickButton.IsDisabled = () => orderManager.LocalClient.IsReady; kickButton.OnClick = () => orderManager.IssueOrder(Order.Command("kick " + c.Index)); @@ -427,7 +427,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (orderManager.LocalClient.Slot != null) { var spec = NewSpectatorTemplate.Clone(); - var btn = spec.GetWidget("SPECTATE"); + var btn = spec.Get("SPECTATE"); btn.OnClick = () => orderManager.IssueOrder(Order.Command("spectate")); btn.IsDisabled = () => orderManager.LocalClient.IsReady; spec.IsVisible = () => true; diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs index 80f574f9f0..38048cfda7 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs @@ -79,7 +79,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup(itemTemplate, o.Selected, () => orderManager.IssueOrder(Order.Command(o.Order))); - item.GetWidget("LABEL").GetText = () => o.Title; + item.Get("LABEL").GetText = () => o.Title; return item; }; @@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup(itemTemplate, () => client.Team == ii, () => orderManager.IssueOrder(Order.Command("team {0} {1}".F(client.Index, ii)))); - item.GetWidget("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString(); + item.Get("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString(); return item; }; @@ -110,8 +110,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup(itemTemplate, () => client.Country == race, () => orderManager.IssueOrder(Order.Command("race {0} {1}".F(client.Index, race)))); - item.GetWidget("LABEL").GetText = () => countryNames[race]; - var flag = item.GetWidget("FLAG"); + item.Get("LABEL").GetText = () => countryNames[race]; + var flag = item.Get("FLAG"); flag.GetImageCollection = () => "flags"; flag.GetImageName = () => race; return item; diff --git a/OpenRA.Mods.RA/Widgets/Logic/MainMenuButtonsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MainMenuButtonsLogic.cs index d18f639395..4008a4c7f5 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MainMenuButtonsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MainMenuButtonsLogic.cs @@ -22,26 +22,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic rootMenu = widget; Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Ui.Root, "PERF_BG" ); - widget.GetWidget("MAINMENU_BUTTON_JOIN").OnClick = () => OpenGamePanel("JOINSERVER_BG"); - widget.GetWidget("MAINMENU_BUTTON_CREATE").OnClick = () => OpenGamePanel("CREATESERVER_BG"); - widget.GetWidget("MAINMENU_BUTTON_DIRECTCONNECT").OnClick = () => OpenGamePanel("DIRECTCONNECT_BG"); - widget.GetWidget("MAINMENU_BUTTON_SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU"); - widget.GetWidget("MAINMENU_BUTTON_MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU"); + widget.Get("MAINMENU_BUTTON_JOIN").OnClick = () => OpenGamePanel("JOINSERVER_BG"); + widget.Get("MAINMENU_BUTTON_CREATE").OnClick = () => OpenGamePanel("CREATESERVER_BG"); + widget.Get("MAINMENU_BUTTON_DIRECTCONNECT").OnClick = () => OpenGamePanel("DIRECTCONNECT_BG"); + widget.Get("MAINMENU_BUTTON_SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU"); + widget.Get("MAINMENU_BUTTON_MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU"); - widget.GetWidget("MAINMENU_BUTTON_MODS").OnClick = () => + widget.Get("MAINMENU_BUTTON_MODS").OnClick = () => Ui.OpenWindow("MODS_PANEL", new WidgetArgs() { { "onExit", () => {} }, { "onSwitch", RemoveShellmapUI } }); - widget.GetWidget("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () => + widget.Get("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () => Ui.OpenWindow("REPLAYBROWSER_BG", new WidgetArgs() { { "onExit", () => {} }, { "onStart", RemoveShellmapUI } }); - widget.GetWidget("MAINMENU_BUTTON_QUIT").OnClick = () => Game.Exit(); + widget.Get("MAINMENU_BUTTON_QUIT").OnClick = () => Game.Exit(); } void RemoveShellmapUI() diff --git a/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs index 95a67021bd..6a26231134 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MapChooserLogic.cs @@ -27,13 +27,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic { map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)]; - widget.GetWidget("BUTTON_OK").OnClick = () => { Ui.CloseWindow(); onSelect(map); }; - widget.GetWidget("BUTTON_CANCEL").OnClick = () => { Ui.CloseWindow(); onExit(); }; + widget.Get("BUTTON_OK").OnClick = () => { Ui.CloseWindow(); onSelect(map); }; + widget.Get("BUTTON_CANCEL").OnClick = () => { Ui.CloseWindow(); onExit(); }; - scrollpanel = widget.GetWidget("MAP_LIST"); - itemTemplate = scrollpanel.GetWidget("MAP_TEMPLATE"); + scrollpanel = widget.Get("MAP_LIST"); + itemTemplate = scrollpanel.Get("MAP_TEMPLATE"); - var gameModeDropdown = widget.GetWidget("GAMEMODE_FILTER"); + var gameModeDropdown = widget.GetOrNull("GAMEMODE_FILTER"); if (gameModeDropdown != null) { var selectableMaps = Game.modData.AvailableMaps.Where(m => m.Value.Selectable); @@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup(template, () => gameMode == ii.First, () => { gameMode = ii.First; EnumerateMaps(); }); - item.GetWidget("LABEL").GetText = () => showItem(ii); + item.Get("LABEL").GetText = () => showItem(ii); return item; }; @@ -82,19 +82,19 @@ namespace OpenRA.Mods.RA.Widgets.Logic var m = kv.Value; var item = ScrollItemWidget.Setup(itemTemplate, () => m == map, () => map = m); - var titleLabel = item.GetWidget("TITLE"); + var titleLabel = item.Get("TITLE"); titleLabel.GetText = () => m.Title; - var previewWidget = item.GetWidget("PREVIEW"); + var previewWidget = item.Get("PREVIEW"); previewWidget.IgnoreMouseOver = true; previewWidget.IgnoreMouseInput = true; previewWidget.Map = () => m; - var detailsWidget = item.GetWidget("DETAILS"); + var detailsWidget = item.Get("DETAILS"); if (detailsWidget != null) detailsWidget.GetText = () => "{0} ({1})".F(m.Type, m.PlayerCount); - var authorWidget = item.GetWidget("AUTHOR"); + var authorWidget = item.Get("AUTHOR"); if (authorWidget != null) authorWidget.GetText = () => m.Author; diff --git a/OpenRA.Mods.RA/Widgets/Logic/ModBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ModBrowserLogic.cs index 4247b5d859..f635a4fb0a 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ModBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ModBrowserLogic.cs @@ -23,24 +23,24 @@ namespace OpenRA.Mods.RA.Widgets.Logic public ModBrowserLogic(Widget widget, Action onSwitch, Action onExit) { var panel = widget; - var modList = panel.GetWidget("MOD_LIST"); - var loadButton = panel.GetWidget("LOAD_BUTTON"); + var modList = panel.Get("MOD_LIST"); + var loadButton = panel.Get("LOAD_BUTTON"); loadButton.OnClick = () => LoadMod(currentMod.Id, onSwitch); loadButton.IsDisabled = () => currentMod.Id == Game.CurrentMods.Keys.First(); - panel.GetWidget("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; + panel.Get("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; currentMod = Mod.AllMods[Game.modData.Manifest.Mods[0]]; // Mod list - var modTemplate = modList.GetWidget("MOD_TEMPLATE"); + var modTemplate = modList.Get("MOD_TEMPLATE"); foreach (var m in Mod.AllMods) { var mod = m.Value; var item = ScrollItemWidget.Setup(modTemplate, () => currentMod == mod, () => currentMod = mod); - item.GetWidget("TITLE").GetText = () => mod.Title; - item.GetWidget("VERSION").GetText = () => mod.Version; - item.GetWidget("AUTHOR").GetText = () => mod.Author; + item.Get("TITLE").GetText = () => mod.Title; + item.Get("VERSION").GetText = () => mod.Version; + item.Get("AUTHOR").GetText = () => mod.Author; modList.AddChild(item); } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/MusicPlayerLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MusicPlayerLogic.cs index 01fd29d830..1cf3c614b6 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/MusicPlayerLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/MusicPlayerLogic.cs @@ -34,32 +34,32 @@ namespace OpenRA.Mods.RA.Widgets.Logic public MusicPlayerLogic() { - bg = Ui.Root.GetWidget("MUSIC_MENU"); + bg = Ui.Root.Get("MUSIC_MENU"); CurrentSong = GetNextSong(); - bg.GetWidget( "BUTTON_PAUSE" ).IsVisible = () => Sound.MusicPlaying; - bg.GetWidget( "BUTTON_PLAY" ).IsVisible = () => !Sound.MusicPlaying; + bg.Get( "BUTTON_PAUSE" ).IsVisible = () => Sound.MusicPlaying; + bg.Get( "BUTTON_PLAY" ).IsVisible = () => !Sound.MusicPlaying; - bg.GetWidget("BUTTON_CLOSE").OnClick = + bg.Get("BUTTON_CLOSE").OnClick = () => { Game.Settings.Save(); Ui.CloseWindow(); }; - bg.GetWidget("BUTTON_INSTALL").IsVisible = () => false; + bg.Get("BUTTON_INSTALL").IsVisible = () => false; - bg.GetWidget("BUTTON_PLAY").OnClick = () => Play( CurrentSong ); - bg.GetWidget("BUTTON_PAUSE").OnClick = Sound.PauseMusic; - bg.GetWidget("BUTTON_STOP").OnClick = Sound.StopMusic; - bg.GetWidget("BUTTON_NEXT").OnClick = () => Play( GetNextSong() ); - bg.GetWidget("BUTTON_PREV").OnClick = () => Play( GetPrevSong() ); + bg.Get("BUTTON_PLAY").OnClick = () => Play( CurrentSong ); + bg.Get("BUTTON_PAUSE").OnClick = Sound.PauseMusic; + bg.Get("BUTTON_STOP").OnClick = Sound.StopMusic; + bg.Get("BUTTON_NEXT").OnClick = () => Play( GetNextSong() ); + bg.Get("BUTTON_PREV").OnClick = () => Play( GetPrevSong() ); - var shuffleCheckbox = bg.GetWidget("SHUFFLE"); + var shuffleCheckbox = bg.Get("SHUFFLE"); shuffleCheckbox.IsChecked = () => Game.Settings.Sound.Shuffle; shuffleCheckbox.OnClick = () => Game.Settings.Sound.Shuffle ^= true; - var repeatCheckbox = bg.GetWidget("REPEAT"); + var repeatCheckbox = bg.Get("REPEAT"); repeatCheckbox.IsChecked = () => Game.Settings.Sound.Repeat; repeatCheckbox.OnClick = () => Game.Settings.Sound.Repeat ^= true; - bg.GetWidget("TIME").GetText = () => + bg.Get("TIME").GetText = () => { if (CurrentSong == null) return ""; @@ -68,14 +68,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic WidgetUtils.FormatTimeSeconds( Rules.Music[CurrentSong].Length )); }; - var ml = bg.GetWidget("MUSIC_LIST"); - var itemTemplate = ml.GetWidget("MUSIC_TEMPLATE"); + var ml = bg.Get("MUSIC_LIST"); + var itemTemplate = ml.Get("MUSIC_TEMPLATE"); if (!Rules.InstalledMusic.Any()) { itemTemplate.IsVisible = () => true; - itemTemplate.GetWidget("TITLE").GetText = () => "No Music Installed"; - itemTemplate.GetWidget("TITLE").Align = TextAlign.Center; + itemTemplate.Get("TITLE").GetText = () => "No Music Installed"; + itemTemplate.Get("TITLE").Align = TextAlign.Center; } foreach (var kv in Rules.InstalledMusic) @@ -84,8 +84,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup(itemTemplate, () => CurrentSong == song, () => Play( song )); - item.GetWidget("TITLE").GetText = () => Rules.Music[song].Title; - item.GetWidget("LENGTH").GetText = + item.Get("TITLE").GetText = () => Rules.Music[song].Title; + item.Get("LENGTH").GetText = () => WidgetUtils.FormatTimeSeconds( Rules.Music[song].Length ); ml.AddChild(item); } diff --git a/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs index 702cdf64e2..907f21b5cb 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs @@ -21,9 +21,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic { /* todo: attach this to the correct widget, to remove the lookups below */ var r = Ui.Root; - var gameRoot = r.GetWidget("INGAME_ROOT"); + var gameRoot = r.Get("INGAME_ROOT"); - var moneybin = gameRoot.GetWidget("INGAME_MONEY_BIN"); + var moneybin = gameRoot.Get("INGAME_MONEY_BIN"); moneybin.IsVisible = () => { return world.LocalPlayer.WinState == WinState.Undefined; }; @@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic static void BindOrderButton(World world, Widget parent, string button) where T : IOrderGenerator, new() { - var w = parent.GetWidget(button); + var w = parent.GetOrNull(button); if (w != null) { w.Pressed = () => world.OrderGenerator is T; diff --git a/OpenRA.Mods.RA/Widgets/Logic/PerfDebugLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/PerfDebugLogic.cs index e1192696dc..50516ee730 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/PerfDebugLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/PerfDebugLogic.cs @@ -18,11 +18,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic public PerfDebugLogic() { var r = Ui.Root; - var perfRoot = r.GetWidget("PERF_BG"); + var perfRoot = r.Get("PERF_BG"); perfRoot.IsVisible = () => perfRoot.Visible && Game.Settings.Debug.PerfGraph; // Perf text - var perfText = perfRoot.GetWidget("TEXT"); + var perfText = perfRoot.Get("TEXT"); perfText.GetText = () => "Render {0} ({5}={2:F1} ms)\nTick {4} ({3:F1} ms)".F( Game.RenderFrame, Game.NetFrameNumber, diff --git a/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs index bfa6444094..ff02f8d221 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs @@ -31,18 +31,18 @@ namespace OpenRA.Mods.RA.Widgets.Logic public RAInstallFromCDLogic(Widget widget, Action continueLoading) { this.continueLoading = continueLoading; - panel = widget.GetWidget("INSTALL_FROMCD_PANEL"); - progressBar = panel.GetWidget("PROGRESS_BAR"); - statusLabel = panel.GetWidget("STATUS_LABEL"); + panel = widget.Get("INSTALL_FROMCD_PANEL"); + progressBar = panel.Get("PROGRESS_BAR"); + statusLabel = panel.Get("STATUS_LABEL"); - backButton = panel.GetWidget("BACK_BUTTON"); + backButton = panel.Get("BACK_BUTTON"); backButton.OnClick = Ui.CloseWindow; - retryButton = panel.GetWidget("RETRY_BUTTON"); + retryButton = panel.Get("RETRY_BUTTON"); retryButton.OnClick = CheckForDisk; - installingContainer = panel.GetWidget("INSTALLING"); - insertDiskContainer = panel.GetWidget("INSERT_DISK"); + installingContainer = panel.Get("INSTALLING"); + insertDiskContainer = panel.Get("INSERT_DISK"); CheckForDisk(); } diff --git a/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs index 42463ac76e..c6924ed54f 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs @@ -19,20 +19,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic [ObjectCreator.UseCtor] public RAInstallLogic(Widget widget, Dictionary installData, Action continueLoading) { - var panel = widget.GetWidget("INSTALL_PANEL"); + var panel = widget.Get("INSTALL_PANEL"); var args = new WidgetArgs() { { "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } }, { "installData", installData } }; - panel.GetWidget("DOWNLOAD_BUTTON").OnClick = () => + panel.Get("DOWNLOAD_BUTTON").OnClick = () => Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", args); - panel.GetWidget("INSTALL_BUTTON").OnClick = () => + panel.Get("INSTALL_BUTTON").OnClick = () => Ui.OpenWindow("INSTALL_FROMCD_PANEL", args); - panel.GetWidget("QUIT_BUTTON").OnClick = Game.Exit; + panel.Get("QUIT_BUTTON").OnClick = Game.Exit; } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs index 018eef6e65..915cb04abe 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs @@ -25,12 +25,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic { panel = widget; - panel.GetWidget("CANCEL_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; + panel.Get("CANCEL_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; - var rl = panel.GetWidget("REPLAY_LIST"); + var rl = panel.Get("REPLAY_LIST"); var replayDir = Path.Combine(Platform.SupportDir, "Replays"); - var template = panel.GetWidget("REPLAY_TEMPLATE"); + var template = panel.Get("REPLAY_TEMPLATE"); rl.RemoveChildren(); if (Directory.Exists(replayDir)) @@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic SelectReplay(files.FirstOrDefault()); } - var watch = panel.GetWidget("WATCH_BUTTON"); + var watch = panel.Get("WATCH_BUTTON"); watch.IsDisabled = () => currentReplay == null || currentMap == null || currentReplay.Duration == 0; watch.OnClick = () => { @@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic } }; - panel.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null; + panel.Get("REPLAY_INFO").IsVisible = () => currentReplay != null; } Replay currentReplay; @@ -70,15 +70,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic currentReplay = new Replay(filename); currentMap = currentReplay.Map(); - panel.GetWidget("DURATION").GetText = + panel.Get("DURATION").GetText = () => WidgetUtils.FormatTime(currentReplay.Duration * 3 /* todo: 3:1 ratio isnt always true. */); - panel.GetWidget("MAP_PREVIEW").Map = () => currentMap; - panel.GetWidget("MAP_TITLE").GetText = + panel.Get("MAP_PREVIEW").Map = () => currentMap; + panel.Get("MAP_TITLE").GetText = () => currentMap != null ? currentMap.Title : "(Unknown Map)"; var players = currentReplay.LobbyInfo.Slots .Count(s => currentReplay.LobbyInfo.ClientInSlot(s.Key) != null); - panel.GetWidget("PLAYERS").GetText = () => players.ToString(); + panel.Get("PLAYERS").GetText = () => players.ToString(); } catch (Exception e) { @@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic () => currentReplay != null && currentReplay.Filename == filename, () => SelectReplay(filename)); var f = Path.GetFileName(filename); - item.GetWidget("TITLE").GetText = () => f; + item.Get("TITLE").GetText = () => f; list.AddChild(item); } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs index b9d06774fb..d2cd7fea0f 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs @@ -41,10 +41,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic public ServerBrowserLogic(Widget widget, Action openLobby, Action onExit) { var panel = widget; - var sl = panel.GetWidget("SERVER_LIST"); + var sl = panel.Get("SERVER_LIST"); // Menu buttons - var refreshButton = panel.GetWidget("REFRESH_BUTTON"); + var refreshButton = panel.Get("REFRESH_BUTTON"); refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching; refreshButton.OnClick = () => { @@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic ServerList.Query(games => RefreshServerList(panel, games)); }; - var join = panel.GetWidget("JOIN_BUTTON"); + var join = panel.Get("JOIN_BUTTON"); join.IsDisabled = () => currentServer == null || !currentServer.CanJoin(); join.OnClick = () => { @@ -68,14 +68,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic ConnectionLogic.Connect(host, port, openLobby, onExit); }; - panel.GetWidget("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; + panel.Get("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; // Server list - serverTemplate = sl.GetWidget("SERVER_TEMPLATE"); + serverTemplate = sl.Get("SERVER_TEMPLATE"); // Display the progress label over the server list // The text is only visible when the list is empty - var progressText = panel.GetWidget("PROGRESS_LABEL"); + var progressText = panel.Get("PROGRESS_LABEL"); progressText.IsVisible = () => searchStatus != SearchStatus.Hidden; progressText.GetText = ProgressLabelText; @@ -123,7 +123,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic public void RefreshServerList(Widget panel, IEnumerable games) { - var sl = panel.GetWidget("SERVER_LIST"); + var sl = panel.Get("SERVER_LIST"); sl.RemoveChildren(); currentServer = null; @@ -151,15 +151,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game); - var preview = item.GetWidget("MAP_PREVIEW"); + var preview = item.Get("MAP_PREVIEW"); preview.Map = () => GetMapPreview(game); preview.IsVisible = () => GetMapPreview(game) != null; - var title = item.GetWidget("TITLE"); + var title = item.Get("TITLE"); title.GetText = () => game.Name; // TODO: Use game.MapTitle once the server supports it - var maptitle = item.GetWidget("MAP"); + var maptitle = item.Get("MAP"); maptitle.GetText = () => { var map = Game.modData.FindMapByUid(game.Map); @@ -167,16 +167,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic }; // TODO: Use game.MaxPlayers once the server supports it - var players = item.GetWidget("PLAYERS"); + var players = item.Get("PLAYERS"); players.GetText = () => GetPlayersLabel(game); - var state = item.GetWidget("STATE"); + var state = item.Get("STATE"); state.GetText = () => GetStateLabel(game); - var ip = item.GetWidget("IP"); + var ip = item.Get("IP"); ip.GetText = () => game.Address; - var version = item.GetWidget("VERSION"); + var version = item.Get("VERSION"); version.GetText = () => GenerateModsLabel(game); version.IsVisible = () => !game.CompatibleVersion(); diff --git a/OpenRA.Mods.RA/Widgets/Logic/ServerCreationLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ServerCreationLogic.cs index 4d3e4f5814..abe2a490e7 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ServerCreationLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ServerCreationLogic.cs @@ -31,15 +31,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic this.onExit = onExit; var settings = Game.Settings; - panel.GetWidget("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; - panel.GetWidget("CREATE_BUTTON").OnClick = CreateAndJoin; + panel.Get("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; + panel.Get("CREATE_BUTTON").OnClick = CreateAndJoin; map = Game.modData.AvailableMaps[ WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map) ]; - var mapButton = panel.GetWidget("MAP_BUTTON"); + var mapButton = panel.GetOrNull("MAP_BUTTON"); if (mapButton != null) { - panel.GetWidget("MAP_BUTTON").OnClick = () => + panel.Get("MAP_BUTTON").OnClick = () => { Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs() { @@ -49,31 +49,31 @@ namespace OpenRA.Mods.RA.Widgets.Logic }); }; - panel.GetWidget("MAP_PREVIEW").Map = () => map; - panel.GetWidget("MAP_NAME").GetText = () => map.Title; + panel.Get("MAP_PREVIEW").Map = () => map; + panel.Get("MAP_NAME").GetText = () => map.Title; } - panel.GetWidget("SERVER_NAME").Text = settings.Server.Name ?? ""; - panel.GetWidget("LISTEN_PORT").Text = settings.Server.ListenPort.ToString(); + panel.Get("SERVER_NAME").Text = settings.Server.Name ?? ""; + panel.Get("LISTEN_PORT").Text = settings.Server.ListenPort.ToString(); advertiseOnline = Game.Settings.Server.AdvertiseOnline; - var externalPort = panel.GetWidget("EXTERNAL_PORT"); + var externalPort = panel.Get("EXTERNAL_PORT"); externalPort.Text = settings.Server.ExternalPort.ToString(); externalPort.IsDisabled = () => !advertiseOnline; - var advertiseCheckbox = panel.GetWidget("ADVERTISE_CHECKBOX"); + var advertiseCheckbox = panel.Get("ADVERTISE_CHECKBOX"); advertiseCheckbox.IsChecked = () => advertiseOnline; advertiseCheckbox.OnClick = () => advertiseOnline ^= true; } void CreateAndJoin() { - var name = panel.GetWidget("SERVER_NAME").Text; + var name = panel.Get("SERVER_NAME").Text; int listenPort, externalPort; - if (!int.TryParse(panel.GetWidget("LISTEN_PORT").Text, out listenPort)) + if (!int.TryParse(panel.Get("LISTEN_PORT").Text, out listenPort)) listenPort = 1234; - if (!int.TryParse(panel.GetWidget("EXTERNAL_PORT").Text, out externalPort)) + if (!int.TryParse(panel.Get("EXTERNAL_PORT").Text, out externalPort)) externalPort = 1234; // Save new settings diff --git a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs index 3e6c20cd04..89eff81fb6 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs @@ -23,20 +23,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic public SettingsMenuLogic() { - bg = Ui.Root.GetWidget("SETTINGS_MENU"); - var tabs = bg.GetWidget("TAB_CONTAINER"); + bg = Ui.Root.Get("SETTINGS_MENU"); + var tabs = bg.Get("TAB_CONTAINER"); //Tabs - tabs.GetWidget("GENERAL").OnClick = () => FlipToTab("GENERAL_PANE"); - tabs.GetWidget("AUDIO").OnClick = () => FlipToTab("AUDIO_PANE"); - tabs.GetWidget("DISPLAY").OnClick = () => FlipToTab("DISPLAY_PANE"); - tabs.GetWidget("DEBUG").OnClick = () => FlipToTab("DEBUG_PANE"); + tabs.Get("GENERAL").OnClick = () => FlipToTab("GENERAL_PANE"); + tabs.Get("AUDIO").OnClick = () => FlipToTab("AUDIO_PANE"); + tabs.Get("DISPLAY").OnClick = () => FlipToTab("DISPLAY_PANE"); + tabs.Get("DEBUG").OnClick = () => FlipToTab("DEBUG_PANE"); FlipToTab("GENERAL_PANE"); //General - var general = bg.GetWidget("GENERAL_PANE"); + var general = bg.Get("GENERAL_PANE"); - var name = general.GetWidget("NAME"); + var name = general.Get("NAME"); name.Text = Game.Settings.Player.Name; name.OnLoseFocus = () => { @@ -49,54 +49,54 @@ namespace OpenRA.Mods.RA.Widgets.Logic }; name.OnEnterKey = () => { name.LoseFocus(); return true; }; - var edgescrollCheckbox = general.GetWidget("EDGE_SCROLL"); + var edgescrollCheckbox = general.Get("EDGE_SCROLL"); edgescrollCheckbox.IsChecked = () => Game.Settings.Game.ViewportEdgeScroll; edgescrollCheckbox.OnClick = () => Game.Settings.Game.ViewportEdgeScroll ^= true; - var edgeScrollSlider = general.GetWidget("EDGE_SCROLL_AMOUNT"); + var edgeScrollSlider = general.Get("EDGE_SCROLL_AMOUNT"); edgeScrollSlider.Value = Game.Settings.Game.ViewportEdgeScrollStep; edgeScrollSlider.OnChange += x => Game.Settings.Game.ViewportEdgeScrollStep = x; - var inversescroll = general.GetWidget("INVERSE_SCROLL"); + var inversescroll = general.Get("INVERSE_SCROLL"); inversescroll.IsChecked = () => Game.Settings.Game.MouseScroll == MouseScrollType.Inverted; inversescroll.OnClick = () => Game.Settings.Game.MouseScroll = (Game.Settings.Game.MouseScroll == MouseScrollType.Inverted) ? MouseScrollType.Standard : MouseScrollType.Inverted; - var teamchatCheckbox = general.GetWidget("TEAMCHAT_TOGGLE"); + var teamchatCheckbox = general.Get("TEAMCHAT_TOGGLE"); teamchatCheckbox.IsChecked = () => Game.Settings.Game.TeamChatToggle; teamchatCheckbox.OnClick = () => Game.Settings.Game.TeamChatToggle ^= true; - var showShellmapCheckbox = general.GetWidget("SHOW_SHELLMAP"); + var showShellmapCheckbox = general.Get("SHOW_SHELLMAP"); showShellmapCheckbox.IsChecked = () => Game.Settings.Game.ShowShellmap; showShellmapCheckbox.OnClick = () => Game.Settings.Game.ShowShellmap ^= true; // Audio - var audio = bg.GetWidget("AUDIO_PANE"); + var audio = bg.Get("AUDIO_PANE"); - var soundslider = audio.GetWidget("SOUND_VOLUME"); + var soundslider = audio.Get("SOUND_VOLUME"); soundslider.OnChange += x => Sound.SoundVolume = x; soundslider.Value = Sound.SoundVolume; - var musicslider = audio.GetWidget("MUSIC_VOLUME"); + var musicslider = audio.Get("MUSIC_VOLUME"); musicslider.OnChange += x => Sound.MusicVolume = x; musicslider.Value = Sound.MusicVolume; // Display - var display = bg.GetWidget("DISPLAY_PANE"); + var display = bg.Get("DISPLAY_PANE"); var gs = Game.Settings.Graphics; - var windowModeDropdown = display.GetWidget("MODE_DROPDOWN"); + var windowModeDropdown = display.Get("MODE_DROPDOWN"); windowModeDropdown.OnMouseDown = _ => ShowWindowModeDropdown(windowModeDropdown, gs); windowModeDropdown.GetText = () => gs.Mode == WindowMode.Windowed ? "Windowed" : gs.Mode == WindowMode.Fullscreen ? "Fullscreen" : "Pseudo-Fullscreen"; - display.GetWidget("WINDOW_RESOLUTION").IsVisible = () => gs.Mode == WindowMode.Windowed; - var windowWidth = display.GetWidget("WINDOW_WIDTH"); + display.Get("WINDOW_RESOLUTION").IsVisible = () => gs.Mode == WindowMode.Windowed; + var windowWidth = display.Get("WINDOW_WIDTH"); windowWidth.Text = gs.WindowedSize.X.ToString(); - var windowHeight = display.GetWidget("WINDOW_HEIGHT"); + var windowHeight = display.Get("WINDOW_HEIGHT"); windowHeight.Text = gs.WindowedSize.Y.ToString(); - var pixelDoubleCheckbox = display.GetWidget("PIXELDOUBLE_CHECKBOX"); + var pixelDoubleCheckbox = display.Get("PIXELDOUBLE_CHECKBOX"); pixelDoubleCheckbox.IsChecked = () => gs.PixelDouble; pixelDoubleCheckbox.OnClick = () => { @@ -105,17 +105,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic }; // Debug - var debug = bg.GetWidget("DEBUG_PANE"); + var debug = bg.Get("DEBUG_PANE"); - var perfgraphCheckbox = debug.GetWidget("PERFDEBUG_CHECKBOX"); + var perfgraphCheckbox = debug.Get("PERFDEBUG_CHECKBOX"); perfgraphCheckbox.IsChecked = () => Game.Settings.Debug.PerfGraph; perfgraphCheckbox.OnClick = () => Game.Settings.Debug.PerfGraph ^= true; - var checkunsyncedCheckbox = debug.GetWidget("CHECKUNSYNCED_CHECKBOX"); + var checkunsyncedCheckbox = debug.Get("CHECKUNSYNCED_CHECKBOX"); checkunsyncedCheckbox.IsChecked = () => Game.Settings.Debug.SanityCheckUnsyncedCode; checkunsyncedCheckbox.OnClick = () => Game.Settings.Debug.SanityCheckUnsyncedCode ^= true; - bg.GetWidget("BUTTON_CLOSE").OnClick = () => + bg.Get("BUTTON_CLOSE").OnClick = () => { int x, y; int.TryParse(windowWidth.Text, out x); @@ -131,10 +131,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic bool FlipToTab(string id) { if (open != null) - bg.GetWidget(open).Visible = false; + bg.Get(open).Visible = false; open = id; - bg.GetWidget(open).Visible = true; + bg.Get(open).Visible = true; return true; } @@ -152,7 +152,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var item = ScrollItemWidget.Setup(itemTemplate, () => s.Mode == options[o], () => s.Mode = options[o]); - item.GetWidget("LABEL").GetText = () => o; + item.Get("LABEL").GetText = () => o; return item; }; diff --git a/OpenRA.Mods.RA/Widgets/PowerBinWidget.cs b/OpenRA.Mods.RA/Widgets/PowerBinWidget.cs index 4b96290618..42798b0756 100755 --- a/OpenRA.Mods.RA/Widgets/PowerBinWidget.cs +++ b/OpenRA.Mods.RA/Widgets/PowerBinWidget.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Widgets if( world.LocalPlayer == null ) return; if( world.LocalPlayer.WinState != WinState.Undefined ) return; - var radarBin = Ui.Root.GetWidget(RadarBin); + var radarBin = Ui.Root.Get(RadarBin); powerCollection = "power-" + world.LocalPlayer.Country.Race; diff --git a/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs b/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs index bc780fa532..ba840b8c37 100755 --- a/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs +++ b/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs @@ -113,7 +113,7 @@ namespace OpenRA.Mods.RA.Widgets if (WorldInteractionController != null) { - var controller = Ui.Root.GetWidget(WorldInteractionController); + var controller = Ui.Root.Get(WorldInteractionController); controller.HandleMouseInput(fakemi); fakemi.Event = MouseInputEvent.Up; controller.HandleMouseInput(fakemi); diff --git a/OpenRA.Mods.RA/Widgets/RadarWidget.cs b/OpenRA.Mods.RA/Widgets/RadarWidget.cs index f997f01474..8ab6801137 100755 --- a/OpenRA.Mods.RA/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.RA/Widgets/RadarWidget.cs @@ -110,7 +110,7 @@ namespace OpenRA.Mods.RA.Widgets if (WorldInteractionController != null) { - var controller = Ui.Root.GetWidget(WorldInteractionController); + var controller = Ui.Root.Get(WorldInteractionController); controller.HandleMouseInput(fakemi); fakemi.Event = MouseInputEvent.Up; controller.HandleMouseInput(fakemi); diff --git a/OpenRA.Mods.RA/World/ChooseBuildTabOnSelect.cs b/OpenRA.Mods.RA/World/ChooseBuildTabOnSelect.cs index 36bbaf5cdd..31272702be 100644 --- a/OpenRA.Mods.RA/World/ChooseBuildTabOnSelect.cs +++ b/OpenRA.Mods.RA/World/ChooseBuildTabOnSelect.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA public void SelectionChanged() { - var palette = Ui.Root.GetWidget("INGAME_BUILD_PALETTE"); + var palette = Ui.Root.Get("INGAME_BUILD_PALETTE"); if (palette == null) return;