From a6c4eb330a0f14efb3f740df1404d4eaf4eaa82a Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 17 Feb 2016 02:53:15 +0000 Subject: [PATCH] Remove modRules widget logic argument. --- OpenRA.Game/Widgets/WidgetLoader.cs | 3 --- OpenRA.Mods.Common/Widgets/ButtonWidget.cs | 4 ++-- OpenRA.Mods.Common/Widgets/CheckboxWidget.cs | 4 ++-- OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs | 4 ++-- OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs | 4 ++-- OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs | 6 ++++-- OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs | 4 ++-- OpenRA.Mods.Common/Widgets/MenuButtonWidget.cs | 4 ++-- OpenRA.Mods.Common/Widgets/ProductionTypeButtonWidget.cs | 4 ++-- OpenRA.Mods.Common/Widgets/ScrollItemWidget.cs | 4 ++-- OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs | 4 ++-- 11 files changed, 22 insertions(+), 23 deletions(-) diff --git a/OpenRA.Game/Widgets/WidgetLoader.cs b/OpenRA.Game/Widgets/WidgetLoader.cs index cc873bfc6c..73e883515a 100644 --- a/OpenRA.Game/Widgets/WidgetLoader.cs +++ b/OpenRA.Game/Widgets/WidgetLoader.cs @@ -46,9 +46,6 @@ namespace OpenRA public Widget LoadWidget(WidgetArgs args, Widget parent, MiniYamlNode node) { - if (!args.ContainsKey("modRules")) - args = new WidgetArgs(args) { { "modRules", modData.DefaultRules } }; - if (!args.ContainsKey("modData")) args = new WidgetArgs(args) { { "modData", modData } }; diff --git a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs index 8da38c9efe..0002b84ede 100644 --- a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs @@ -60,9 +60,9 @@ namespace OpenRA.Mods.Common.Widgets protected readonly Ruleset ModRules; [ObjectCreator.UseCtor] - public ButtonWidget(Ruleset modRules) + public ButtonWidget(ModData modData) { - ModRules = modRules; + ModRules = modData.DefaultRules; GetText = () => Text; GetColor = () => TextColor; diff --git a/OpenRA.Mods.Common/Widgets/CheckboxWidget.cs b/OpenRA.Mods.Common/Widgets/CheckboxWidget.cs index 8018461cf8..7d1261097d 100644 --- a/OpenRA.Mods.Common/Widgets/CheckboxWidget.cs +++ b/OpenRA.Mods.Common/Widgets/CheckboxWidget.cs @@ -25,8 +25,8 @@ namespace OpenRA.Mods.Common.Widgets public bool HasPressedState = ChromeMetrics.Get("CheckboxPressedState"); [ObjectCreator.UseCtor] - public CheckboxWidget(Ruleset modRules) - : base(modRules) + public CheckboxWidget(ModData modData) + : base(modData) { GetCheckType = () => CheckType; } diff --git a/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs b/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs index 93ac4c95f0..2f8b3f1728 100644 --- a/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs @@ -29,8 +29,8 @@ namespace OpenRA.Mods.Common.Widgets public string PanelRoot; [ObjectCreator.UseCtor] - public DropDownButtonWidget(Ruleset modRules) - : base(modRules) { } + public DropDownButtonWidget(ModData modData) + : base(modData) { } protected DropDownButtonWidget(DropDownButtonWidget widget) : base(widget) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs index c15888de7b..cfedf4e051 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs @@ -39,10 +39,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic bool teamChat; [ObjectCreator.UseCtor] - public IngameChatLogic(Widget widget, OrderManager orderManager, World world, Ruleset modRules) + public IngameChatLogic(Widget widget, OrderManager orderManager, World world, ModData modData) { this.orderManager = orderManager; - this.modRules = modRules; + this.modRules = modData.DefaultRules; chatTraits = world.WorldActor.TraitsImplementing().ToArray(); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 90819d8c33..836b8b4ed4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ObjectCreator.UseCtor] internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager, - Action onExit, Action onStart, bool skirmishMode, Ruleset modRules) + Action onExit, Action onStart, bool skirmishMode) { MapPreview = MapCache.UnknownMap; lobby = widget; @@ -121,7 +121,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic this.onStart = onStart; this.onExit = onExit; this.skirmishMode = skirmishMode; - this.modRules = modRules; + + // TODO: This needs to be reworked to support per-map tech levels, bots, etc. + this.modRules = modData.DefaultRules; shellmapWorld = worldRenderer.World; orderManager.AddChatLine += AddChatLine; diff --git a/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs index 590a454d68..3274f9a060 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic MusicInfo currentSong = null; [ObjectCreator.UseCtor] - public MusicPlayerLogic(Widget widget, ModData modData, Ruleset modRules, World world, Action onExit) + public MusicPlayerLogic(Widget widget, ModData modData, World world, Action onExit) { var panel = widget; @@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic Game.RunAfterTick(() => Game.InitializeMod("modchooser", new Arguments(args))); var installData = modData.Manifest.Get(); - installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks; + installButton.IsVisible = () => modData.DefaultRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks; } var songWatcher = widget.GetOrNull("SONG_WATCHER"); diff --git a/OpenRA.Mods.Common/Widgets/MenuButtonWidget.cs b/OpenRA.Mods.Common/Widgets/MenuButtonWidget.cs index c11ec7d378..140fcc4fca 100644 --- a/OpenRA.Mods.Common/Widgets/MenuButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/MenuButtonWidget.cs @@ -18,8 +18,8 @@ namespace OpenRA.Mods.Common.Widgets public readonly bool HideIngameUI = true; [ObjectCreator.UseCtor] - public MenuButtonWidget(Ruleset modRules) - : base(modRules) { } + public MenuButtonWidget(ModData modData) + : base(modData) { } protected MenuButtonWidget(MenuButtonWidget other) : base(other) diff --git a/OpenRA.Mods.Common/Widgets/ProductionTypeButtonWidget.cs b/OpenRA.Mods.Common/Widgets/ProductionTypeButtonWidget.cs index dad9c4cc04..b822a40d47 100644 --- a/OpenRA.Mods.Common/Widgets/ProductionTypeButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ProductionTypeButtonWidget.cs @@ -17,8 +17,8 @@ namespace OpenRA.Mods.Common.Widgets public readonly string HotkeyName; [ObjectCreator.UseCtor] - public ProductionTypeButtonWidget(Ruleset modRules) - : base(modRules) { } + public ProductionTypeButtonWidget(ModData modData) + : base(modData) { } protected ProductionTypeButtonWidget(ProductionTypeButtonWidget other) : base(other) diff --git a/OpenRA.Mods.Common/Widgets/ScrollItemWidget.cs b/OpenRA.Mods.Common/Widgets/ScrollItemWidget.cs index bb4b4c5558..b2dc28e050 100644 --- a/OpenRA.Mods.Common/Widgets/ScrollItemWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ScrollItemWidget.cs @@ -20,8 +20,8 @@ namespace OpenRA.Mods.Common.Widgets public string BaseName = "scrollitem"; [ObjectCreator.UseCtor] - public ScrollItemWidget(Ruleset modRules) - : base(modRules) + public ScrollItemWidget(ModData modData) + : base(modData) { IsVisible = () => false; VisualHeight = 0; diff --git a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs index 63c9f5fc47..4493e59e0e 100644 --- a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs @@ -86,9 +86,9 @@ namespace OpenRA.Mods.Common.Widgets } [ObjectCreator.UseCtor] - public ScrollPanelWidget(Ruleset modRules) + public ScrollPanelWidget(ModData modData) { - this.modRules = modRules; + this.modRules = modData.DefaultRules; Layout = new ListLayout(this); }