remove ObjectCreator.Param and all associated nonsense

This commit is contained in:
Chris Forbes
2011-10-21 18:16:07 +13:00
parent 4c8e048c2c
commit 6010034b4a
69 changed files with 120 additions and 213 deletions

View File

@@ -21,7 +21,7 @@ namespace OpenRA
{ {
public static PlatformType CurrentPlatform { get { return currentPlatform.Value; } } public static PlatformType CurrentPlatform { get { return currentPlatform.Value; } }
static Lazy<PlatformType> currentPlatform = new Lazy<PlatformType>(GetCurrentPlatform); static Lazy<PlatformType> currentPlatform = Lazy.New(GetCurrentPlatform);
static PlatformType GetCurrentPlatform() static PlatformType GetCurrentPlatform()
{ {

View File

@@ -78,8 +78,7 @@ namespace OpenRA
var a = new object[ p.Length ]; var a = new object[ p.Length ];
for( int i = 0 ; i < p.Length ; i++ ) for( int i = 0 ; i < p.Length ; i++ )
{ {
var attr = p[ i ].GetCustomAttributes<ParamAttribute>().FirstOrDefault(); var key = p[i].Name;
var key = (attr != null ? attr.ParamName : null) ?? p[i].Name;
if ( !args.ContainsKey(key) ) throw new InvalidOperationException("ObjectCreator: key `{0}' not found".F(key)); if ( !args.ContainsKey(key) ) throw new InvalidOperationException("ObjectCreator: key `{0}' not found".F(key));
a[ i ] = args[ key ]; a[ i ] = args[ key ];
} }
@@ -94,22 +93,7 @@ namespace OpenRA
.Where(t => t != it && it.IsAssignableFrom(t))); .Where(t => t != it && it.IsAssignableFrom(t)));
} }
[AttributeUsage( AttributeTargets.Parameter )]
public class ParamAttribute : Attribute
{
public string ParamName { get; private set; }
public ParamAttribute() { }
public ParamAttribute( string paramName )
{
ParamName = paramName;
}
}
[AttributeUsage( AttributeTargets.Constructor )] [AttributeUsage( AttributeTargets.Constructor )]
public class UseCtorAttribute : Attribute public class UseCtorAttribute : Attribute {}
{
}
} }
} }

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
@@ -26,7 +26,7 @@ namespace OpenRA.Widgets
readonly OrderManager orderManager; readonly OrderManager orderManager;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
internal ChatEntryWidget( [ObjectCreator.Param] OrderManager orderManager ) internal ChatEntryWidget( OrderManager orderManager )
{ {
this.orderManager = orderManager; this.orderManager = orderManager;
} }

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Widgets
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ShpImageWidget([ObjectCreator.Param] WorldRenderer worldRenderer) public ShpImageWidget( WorldRenderer worldRenderer)
: base() : base()
{ {
GetImage = () => { return Image; }; GetImage = () => { return Image; };

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Widgets
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public VqaPlayerWidget( [ObjectCreator.Param] World world ) public VqaPlayerWidget( World world )
{ {
this.world = world; this.world = world;
} }

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Widgets
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public WorldInteractionControllerWidget([ObjectCreator.Param] World world, [ObjectCreator.Param] WorldRenderer worldRenderer) public WorldInteractionControllerWidget(World world, WorldRenderer worldRenderer)
{ {
this.world = world; this.world = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;

View File

@@ -32,6 +32,7 @@ namespace OpenRA.Mods.Cnc
EffectType to = EffectType.Black; EffectType to = EffectType.Black;
public CncMenuPaletteEffect(CncMenuPaletteEffectInfo info) { Info = info; } public CncMenuPaletteEffect(CncMenuPaletteEffectInfo info) { Info = info; }
public void Fade(EffectType type) public void Fade(EffectType type)
{ {
remainingFrames = Info.FadeLength; remainingFrames = Info.FadeLength;

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.Cnc
class DeadBuildingStateInfo : ITraitInfo, Requires<HealthInfo>, Requires<RenderSimpleInfo> class DeadBuildingStateInfo : ITraitInfo, Requires<HealthInfo>, Requires<RenderSimpleInfo>
{ {
public readonly int LingerTime = 20; public readonly int LingerTime = 20;
public object Create(ActorInitializer init) { return new DeadBuildingState(init.self, this); } public object Create(ActorInitializer init) { return new DeadBuildingState(init.self, this); }
} }
@@ -23,6 +24,7 @@ namespace OpenRA.Mods.Cnc
{ {
DeadBuildingStateInfo info; DeadBuildingStateInfo info;
RenderSimple rs; RenderSimple rs;
public DeadBuildingState(Actor self, DeadBuildingStateInfo info) public DeadBuildingState(Actor self, DeadBuildingStateInfo info)
{ {
this.info = info; this.info = info;

View File

@@ -15,8 +15,7 @@ namespace OpenRA.Mods.Cnc
{ {
class PoisonedByTiberiumInfo : ITraitInfo class PoisonedByTiberiumInfo : ITraitInfo
{ {
[WeaponReference] [WeaponReference] public readonly string Weapon = "Tiberium";
public readonly string Weapon = "Tiberium";
public readonly string[] Resources = { "Tiberium", "BlueTiberium" }; public readonly string[] Resources = { "Tiberium", "BlueTiberium" };
public object Create(ActorInitializer init) { return new PoisonedByTiberium(this); } public object Create(ActorInitializer init) { return new PoisonedByTiberium(this); }

View File

@@ -22,6 +22,7 @@ namespace OpenRA.Mods.Cnc
{ {
public readonly string ReadyAudio = "reinfor1.aud"; public readonly string ReadyAudio = "reinfor1.aud";
[ActorReference] public readonly string ActorType = "c17"; [ActorReference] public readonly string ActorType = "c17";
public override object Create(ActorInitializer init) { return new ProductionAirdrop(this); } public override object Create(ActorInitializer init) { return new ProductionAirdrop(this); }
} }

View File

@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Cnc.Widgets
class ProductionQueueFromSelectionInfo : ITraitInfo class ProductionQueueFromSelectionInfo : ITraitInfo
{ {
public string ProductionTabsWidget = null; public string ProductionTabsWidget = null;
public object Create( ActorInitializer init ) { return new ProductionQueueFromSelection(init.world, this); } public object Create( ActorInitializer init ) { return new ProductionQueueFromSelection(init.world, this); }
} }
@@ -31,7 +32,7 @@ namespace OpenRA.Mods.Cnc.Widgets
{ {
this.world = world; this.world = world;
tabsWidget = new Lazy<ProductionTabsWidget>(() => tabsWidget = Lazy.New(() =>
Widget.RootWidget.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget)); Widget.RootWidget.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget));
} }

View File

@@ -22,6 +22,8 @@ namespace OpenRA.Mods.RA.Render
class RenderGunboat : RenderSimple, INotifyDamageStateChanged class RenderGunboat : RenderSimple, INotifyDamageStateChanged
{ {
IFacing facing; IFacing facing;
string lastDir = "left";
string lastDamage = "";
public RenderGunboat(Actor self) public RenderGunboat(Actor self)
: base(self, () => self.HasTrait<Turreted>() ? self.Trait<Turreted>().turretFacing : 0) : base(self, () => self.HasTrait<Turreted>() ? self.Trait<Turreted>().turretFacing : 0)
@@ -35,8 +37,6 @@ namespace OpenRA.Mods.RA.Render
anims.Add( "wake", new AnimationWithOffset( wake, offset, () => false ) { ZOffset = -2 } ); anims.Add( "wake", new AnimationWithOffset( wake, offset, () => false ) { ZOffset = -2 } );
} }
string lastDir = "left";
string lastDamage = "";
public override void Tick(Actor self) public override void Tick(Actor self)
{ {
var dir = (facing.Facing > 128) ? "right" : "left"; var dir = (facing.Facing > 128) ? "right" : "left";

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Cnc
public class TiberiumRefinery : OreRefinery public class TiberiumRefinery : OreRefinery
{ {
public TiberiumRefinery(Actor self, TiberiumRefineryInfo info) public TiberiumRefinery(Actor self, TiberiumRefineryInfo info)
: base(self, info as OreRefineryInfo) {} : base(self, info) {}
public override Activity DockSequence(Actor harv, Actor self) public override Activity DockSequence(Actor harv, Actor self)
{ {

View File

@@ -32,18 +32,18 @@ namespace OpenRA.Mods.Cnc.Widgets
ScrollDirection Edge; ScrollDirection Edge;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncWorldInteractionControllerWidget([ObjectCreator.Param] World world, public CncWorldInteractionControllerWidget(World world, WorldRenderer worldRenderer)
[ObjectCreator.Param] WorldRenderer worldRenderer)
: base(world, worldRenderer) : base(world, worldRenderer)
{ {
tooltipContainer = new Lazy<TooltipContainerWidget>(() => tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
} }
public override void MouseEntered() public override void MouseEntered()
{ {
if (TooltipContainer == null) return; if (TooltipContainer == null) return;
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() {{ "world", world }, { "wic", this }}); tooltipContainer.Value.SetTooltip(TooltipTemplate,
new WidgetArgs() {{ "world", world }, { "wic", this }});
} }
public override void MouseExited() public override void MouseExited()

View File

@@ -16,8 +16,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class ButtonTooltipLogic public class ButtonTooltipLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ButtonTooltipLogic([ObjectCreator.Param] Widget widget, public ButtonTooltipLogic(Widget widget, ToggleButtonWidget button)
[ObjectCreator.Param] ToggleButtonWidget button)
{ {
var label = widget.GetWidget<LabelWidget>("LABEL"); var label = widget.GetWidget<LabelWidget>("LABEL");
var hotkey = widget.GetWidget<LabelWidget>("HOTKEY"); var hotkey = widget.GetWidget<LabelWidget>("HOTKEY");

View File

@@ -27,9 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class CncCheatsLogic public class CncCheatsLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncCheatsLogic([ObjectCreator.Param] Widget widget, public CncCheatsLogic(Widget widget, Action onExit, World world)
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] World world)
{ {
var panel = widget.GetWidget("CHEATS_PANEL"); var panel = widget.GetWidget("CHEATS_PANEL");

View File

@@ -19,11 +19,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{ {
ColorRamp ramp; ColorRamp ramp;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncColorPickerLogic([ObjectCreator.Param] Widget widget, public CncColorPickerLogic(Widget widget, ColorRamp initialRamp, Action<ColorRamp> onChange,
[ObjectCreator.Param] ColorRamp initialRamp, Action<ColorRamp> onSelect, WorldRenderer worldRenderer)
[ObjectCreator.Param] Action<ColorRamp> onChange,
[ObjectCreator.Param] Action<ColorRamp> onSelect,
[ObjectCreator.Param] WorldRenderer worldRenderer)
{ {
var panel = widget.GetWidget("COLOR_CHOOSER"); var panel = widget.GetWidget("COLOR_CHOOSER");
ramp = initialRamp; ramp = initialRamp;

View File

@@ -48,12 +48,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
} }
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncConnectingLogic([ObjectCreator.Param] Widget widget, public CncConnectingLogic(Widget widget, string host, int port, Action onConnect, Action onRetry, Action onAbort)
[ObjectCreator.Param] string host,
[ObjectCreator.Param] int port,
[ObjectCreator.Param] Action onConnect,
[ObjectCreator.Param] Action onRetry,
[ObjectCreator.Param] Action onAbort)
{ {
this.host = host; this.host = host;
this.port = port; this.port = port;
@@ -87,11 +82,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class CncConnectionFailedLogic public class CncConnectionFailedLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncConnectionFailedLogic([ObjectCreator.Param] Widget widget, public CncConnectionFailedLogic(Widget widget, string host, int port, Action onRetry, Action onAbort)
[ObjectCreator.Param] string host,
[ObjectCreator.Param] int port,
[ObjectCreator.Param] Action onRetry,
[ObjectCreator.Param] Action onAbort)
{ {
var panel = widget.GetWidget("CONNECTIONFAILED_PANEL"); var panel = widget.GetWidget("CONNECTIONFAILED_PANEL");
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); }; panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); };

View File

@@ -19,8 +19,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class CncConquestObjectivesLogic public class CncConquestObjectivesLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncConquestObjectivesLogic([ObjectCreator.Param] Widget widget, public CncConquestObjectivesLogic(Widget widget, World world)
[ObjectCreator.Param] World world)
{ {
var panel = widget.GetWidget("CONQUEST_OBJECTIVES"); var panel = widget.GetWidget("CONQUEST_OBJECTIVES");
panel.GetWidget<LabelWidget>("TITLE").GetText = () => "Conquest: " + world.Map.Title; panel.GetWidget<LabelWidget>("TITLE").GetText = () => "Conquest: " + world.Map.Title;

View File

@@ -17,9 +17,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class CncDirectConnectLogic public class CncDirectConnectLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncDirectConnectLogic([ObjectCreator.Param] Widget widget, public CncDirectConnectLogic(Widget widget, Action onExit, Action openLobby)
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action openLobby)
{ {
var panel = widget.GetWidget("DIRECTCONNECT_PANEL"); var panel = widget.GetWidget("DIRECTCONNECT_PANEL");
var ipField = panel.GetWidget<TextFieldWidget>("IP"); var ipField = panel.GetWidget<TextFieldWidget>("IP");

View File

@@ -65,8 +65,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
} }
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncIngameChromeLogic([ObjectCreator.Param] Widget widget, public CncIngameChromeLogic(Widget widget, World world)
[ObjectCreator.Param] World world )
{ {
this.world = world; this.world = world;
world.WorldActor.Trait<CncMenuPaletteEffect>() world.WorldActor.Trait<CncMenuPaletteEffect>()

View File

@@ -20,9 +20,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Widget menu; Widget menu;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncIngameMenuLogic([ObjectCreator.Param] Widget widget, public CncIngameMenuLogic(Widget widget, World world, Action onExit)
[ObjectCreator.Param] World world,
[ObjectCreator.Param] Action onExit)
{ {
var resumeDisabled = false; var resumeDisabled = false;
menu = widget.GetWidget("INGAME_MENU"); menu = widget.GetWidget("INGAME_MENU");

View File

@@ -29,10 +29,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
string[] filesToCopy, filesToExtract; string[] filesToCopy, filesToExtract;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncInstallFromCDLogic([ObjectCreator.Param] Widget widget, public CncInstallFromCDLogic(Widget widget, Action afterInstall, string[] filesToCopy, string[] filesToExtract)
[ObjectCreator.Param] Action afterInstall,
[ObjectCreator.Param] string[] filesToCopy,
[ObjectCreator.Param] string[] filesToExtract)
{ {
this.afterInstall = afterInstall; this.afterInstall = afterInstall;
this.filesToCopy = filesToCopy; this.filesToCopy = filesToCopy;

View File

@@ -17,9 +17,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class CncInstallLogic public class CncInstallLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncInstallLogic([ObjectCreator.Param] Widget widget, public CncInstallLogic(Widget widget, Dictionary<string,string> installData, Action continueLoading)
[ObjectCreator.Param] Dictionary<string,string> installData,
[ObjectCreator.Param] Action continueLoading)
{ {
var panel = widget.GetWidget("INSTALL_PANEL"); var panel = widget.GetWidget("INSTALL_PANEL");
var args = new WidgetArgs() var args = new WidgetArgs()

View File

@@ -85,13 +85,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
} }
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
internal CncLobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby, internal CncLobbyLogic(Widget widget, World world, OrderManager orderManager,
[ObjectCreator.Param] World world, // Shellmap world Action onExit, Action onStart, bool addBots)
[ObjectCreator.Param] OrderManager orderManager,
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action onStart,
[ObjectCreator.Param] bool addBots)
{ {
var lobby = widget;
this.orderManager = orderManager; this.orderManager = orderManager;
this.OnGameStart = () => { CloseWindow(); onStart(); }; this.OnGameStart = () => { CloseWindow(); onStart(); };
this.onExit = onExit; this.onExit = onExit;

View File

@@ -23,8 +23,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Widget rootMenu; Widget rootMenu;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncMenuLogic([ObjectCreator.Param] Widget widget, public CncMenuLogic(Widget widget, World world)
[ObjectCreator.Param] World world)
{ {
world.WorldActor.Trait<CncMenuPaletteEffect>() world.WorldActor.Trait<CncMenuPaletteEffect>()
.Fade(CncMenuPaletteEffect.EffectType.Desaturated); .Fade(CncMenuPaletteEffect.EffectType.Desaturated);

View File

@@ -21,9 +21,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Mod currentMod; Mod currentMod;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncModBrowserLogic([ObjectCreator.Param] Widget widget, public CncModBrowserLogic(Widget widget, Action onSwitch, Action onExit)
[ObjectCreator.Param] Action onSwitch,
[ObjectCreator.Param] Action onExit)
{ {
var panel = widget.GetWidget("MODS_PANEL"); var panel = widget.GetWidget("MODS_PANEL");
var modList = panel.GetWidget<ScrollPanelWidget>("MOD_LIST"); var modList = panel.GetWidget<ScrollPanelWidget>("MOD_LIST");

View File

@@ -30,8 +30,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
ScrollItemWidget itemTemplate; ScrollItemWidget itemTemplate;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncMusicPlayerLogic([ObjectCreator.Param] Widget widget, public CncMusicPlayerLogic(Widget widget, Action onExit)
[ObjectCreator.Param] Action onExit)
{ {
panel = widget.GetWidget("MUSIC_PANEL"); panel = widget.GetWidget("MUSIC_PANEL");

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class CncPerfDebugLogic public class CncPerfDebugLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncPerfDebugLogic([ObjectCreator.Param] Widget widget) public CncPerfDebugLogic(Widget widget)
{ {
// Performance info // Performance info
var perfRoot = widget.GetWidget("PERFORMANCE_INFO"); var perfRoot = widget.GetWidget("PERFORMANCE_INFO");

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
@@ -21,9 +21,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Widget panel; Widget panel;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncReplayBrowserLogic([ObjectCreator.Param] Widget widget, public CncReplayBrowserLogic(Widget widget, Action onExit, Action onStart)
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action onStart)
{ {
panel = widget.GetWidget("REPLAYBROWSER_PANEL"); panel = widget.GetWidget("REPLAYBROWSER_PANEL");

View File

@@ -41,9 +41,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
} }
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncServerBrowserLogic([ObjectCreator.Param] Widget widget, public CncServerBrowserLogic(Widget widget, Action openLobby, Action onExit)
[ObjectCreator.Param] Action openLobby,
[ObjectCreator.Param] Action onExit)
{ {
var panel = widget.GetWidget("SERVERBROWSER_PANEL"); var panel = widget.GetWidget("SERVERBROWSER_PANEL");
var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST"); var sl = panel.GetWidget<ScrollPanelWidget>("SERVER_LIST");

View File

@@ -25,9 +25,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
bool advertiseOnline; bool advertiseOnline;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncServerCreationLogic([ObjectCreator.Param] Widget widget, public CncServerCreationLogic(Widget widget, Action onExit, Action openLobby)
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action openLobby)
{ {
panel = widget.GetWidget("CREATESERVER_PANEL"); panel = widget.GetWidget("CREATESERVER_PANEL");
onCreate = openLobby; onCreate = openLobby;

View File

@@ -29,9 +29,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
World world; World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncSettingsLogic([ObjectCreator.Param] Widget widget, public CncSettingsLogic(Widget widget, World world, Action onExit)
[ObjectCreator.Param] World world,
[ObjectCreator.Param] Action onExit)
{ {
this.world = world; this.world = world;
var panel = widget.GetWidget("SETTINGS_PANEL"); var panel = widget.GetWidget("SETTINGS_PANEL");

View File

@@ -22,9 +22,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class ProductionTooltipLogic public class ProductionTooltipLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ProductionTooltipLogic([ObjectCreator.Param] Widget widget, public ProductionTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, ProductionPaletteWidget palette)
[ObjectCreator.Param] TooltipContainerWidget tooltipContainer,
[ObjectCreator.Param] ProductionPaletteWidget palette)
{ {
var pm = palette.world.LocalPlayer.PlayerActor.Trait<PowerManager>(); var pm = palette.world.LocalPlayer.PlayerActor.Trait<PowerManager>();
var pr = palette.world.LocalPlayer.PlayerActor.Trait<PlayerResources>(); var pr = palette.world.LocalPlayer.PlayerActor.Trait<PlayerResources>();

View File

@@ -17,9 +17,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class SimpleTooltipLogic public class SimpleTooltipLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public SimpleTooltipLogic([ObjectCreator.Param] Widget widget, public SimpleTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, Func<string> getText)
[ObjectCreator.Param] TooltipContainerWidget tooltipContainer,
[ObjectCreator.Param] Func<string> getText)
{ {
var label = widget.GetWidget<LabelWidget>("LABEL"); var label = widget.GetWidget<LabelWidget>("LABEL");

View File

@@ -18,9 +18,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class SupportPowerTooltipLogic public class SupportPowerTooltipLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public SupportPowerTooltipLogic([ObjectCreator.Param] Widget widget, public SupportPowerTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, SupportPowersWidget palette)
[ObjectCreator.Param] TooltipContainerWidget tooltipContainer,
[ObjectCreator.Param] SupportPowersWidget palette)
{ {
widget.IsVisible = () => palette.TooltipPower != null; widget.IsVisible = () => palette.TooltipPower != null;
var nameLabel = widget.GetWidget<LabelWidget>("NAME"); var nameLabel = widget.GetWidget<LabelWidget>("NAME");

View File

@@ -12,18 +12,16 @@ using System;
using System.Drawing; using System.Drawing;
using OpenRA.Support; using OpenRA.Support;
using OpenRA.Widgets; using OpenRA.Widgets;
using Type = OpenRA.Mods.Cnc.Widgets.CncWorldInteractionControllerWidget.WorldTooltipType; using TooltipType = OpenRA.Mods.Cnc.Widgets.CncWorldInteractionControllerWidget.WorldTooltipType;
namespace OpenRA.Mods.Cnc.Widgets.Logic namespace OpenRA.Mods.Cnc.Widgets.Logic
{ {
public class WorldTooltipLogic public class WorldTooltipLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public WorldTooltipLogic([ObjectCreator.Param] Widget widget, public WorldTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, CncWorldInteractionControllerWidget wic)
[ObjectCreator.Param] TooltipContainerWidget tooltipContainer,
[ObjectCreator.Param] CncWorldInteractionControllerWidget wic)
{ {
widget.IsVisible = () => wic.TooltipType != Type.None; widget.IsVisible = () => wic.TooltipType != TooltipType.None;
var label = widget.GetWidget<LabelWidget>("LABEL"); var label = widget.GetWidget<LabelWidget>("LABEL");
var flag = widget.GetWidget<ImageWidget>("FLAG"); var flag = widget.GetWidget<ImageWidget>("FLAG");
var owner = widget.GetWidget<LabelWidget>("OWNER"); var owner = widget.GetWidget<LabelWidget>("OWNER");
@@ -41,10 +39,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
tooltipContainer.BeforeRender = () => tooltipContainer.BeforeRender = () =>
{ {
if (wic == null || wic.TooltipType == Type.None) if (wic == null || wic.TooltipType == TooltipType.None)
return; return;
labelText = wic.TooltipType == Type.Unexplored ? "Unexplored Terrain" : labelText = wic.TooltipType == TooltipType.Unexplored ? "Unexplored Terrain" :
wic.ActorTooltip.Name(); wic.ActorTooltip.Name();
var textWidth = font.Measure(labelText).X; var textWidth = font.Measure(labelText).X;
if (textWidth != cachedWidth) if (textWidth != cachedWidth)
@@ -53,7 +51,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
widget.Bounds.Width = 2*label.Bounds.X + textWidth; widget.Bounds.Width = 2*label.Bounds.X + textWidth;
} }
var o = wic.ActorTooltip != null ? wic.ActorTooltip.Owner() : null; var o = wic.ActorTooltip != null ? wic.ActorTooltip.Owner() : null;
showOwner = wic.TooltipType == Type.Actor && o != null && !o.NonCombatant; showOwner = wic.TooltipType == TooltipType.Actor && o != null && !o.NonCombatant;
if (showOwner) if (showOwner)
{ {

View File

@@ -28,10 +28,10 @@ namespace OpenRA.Mods.Cnc.Widgets
readonly PowerManager pm; readonly PowerManager pm;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public PowerBarWidget( [ObjectCreator.Param] World world ) public PowerBarWidget(World world)
{ {
pm = world.LocalPlayer.PlayerActor.Trait<PowerManager>(); pm = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
tooltipContainer = new Lazy<TooltipContainerWidget>(() => tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
} }

View File

@@ -43,17 +43,11 @@ namespace OpenRA.Mods.Cnc.Widgets
Lazy<TooltipContainerWidget> tooltipContainer; Lazy<TooltipContainerWidget> tooltipContainer;
ProductionQueue currentQueue; ProductionQueue currentQueue;
public ProductionQueue CurrentQueue public ProductionQueue CurrentQueue
{ {
get get { return currentQueue; }
{ set { currentQueue = value; RefreshIcons(); }
return currentQueue;
}
set
{
currentQueue = value;
RefreshIcons();
}
} }
public override Rectangle EventBounds { get { return eventBounds; } } public override Rectangle EventBounds { get { return eventBounds; } }
@@ -66,12 +60,11 @@ namespace OpenRA.Mods.Cnc.Widgets
readonly float2 holdOffset, readyOffset, timeOffset, queuedOffset; readonly float2 holdOffset, readyOffset, timeOffset, queuedOffset;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ProductionPaletteWidget([ObjectCreator.Param] World world, public ProductionPaletteWidget(World world, WorldRenderer worldRenderer)
[ObjectCreator.Param] WorldRenderer worldRenderer)
{ {
this.world = world; this.world = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;
tooltipContainer = new Lazy<TooltipContainerWidget>(() => tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
cantBuild = new Animation("clock"); cantBuild = new Animation("clock");

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Cnc.Widgets
string queueGroup; string queueGroup;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ProductionTabsWidget([ObjectCreator.Param] World world) public ProductionTabsWidget(World world)
{ {
Groups = Rules.Info.Values.SelectMany(a => a.Traits.WithInterface<ProductionQueueInfo>()) Groups = Rules.Info.Values.SelectMany(a => a.Traits.WithInterface<ProductionQueueInfo>())
.Select(q => q.Group).Distinct().ToDictionary(g => g, g => new ProductionTabGroup() { Group = g }); .Select(q => q.Group).Distinct().ToDictionary(g => g, g => new ProductionTabGroup() { Group = g });
@@ -86,8 +86,7 @@ namespace OpenRA.Mods.Cnc.Widgets
// Only visible if the production palette has icons to display // Only visible if the production palette has icons to display
IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0; IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0;
paletteWidget = new Lazy<ProductionPaletteWidget>(() => paletteWidget = Lazy.New(() => Widget.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget));
Widget.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget));
} }
public void SelectNextTab(bool reverse) public void SelectNextTab(bool reverse)
@@ -108,10 +107,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public string QueueGroup public string QueueGroup
{ {
get get { return queueGroup; }
{
return queueGroup;
}
set set
{ {
ListOffset = 0; ListOffset = 0;
@@ -122,10 +118,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public ProductionQueue CurrentQueue public ProductionQueue CurrentQueue
{ {
get get { return paletteWidget.Value.CurrentQueue; }
{
return paletteWidget.Value.CurrentQueue;
}
set set
{ {
paletteWidget.Value.CurrentQueue = value; paletteWidget.Value.CurrentQueue = value;
@@ -268,7 +261,7 @@ namespace OpenRA.Mods.Cnc.Widgets
return true; return true;
} }
return (leftPressed || rightPressed); return leftPressed || rightPressed;
} }
public override bool HandleKeyPress(KeyInput e) public override bool HandleKeyPress(KeyInput e)

View File

@@ -28,11 +28,12 @@ namespace OpenRA.Mods.Cnc.Widgets
float? lastStoredFrac; float? lastStoredFrac;
readonly PlayerResources pr; readonly PlayerResources pr;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public SiloBarWidget( [ObjectCreator.Param] World world ) public SiloBarWidget(World world)
{ {
pr = world.LocalPlayer.PlayerActor.Trait<PlayerResources>(); pr = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
tooltipContainer = new Lazy<TooltipContainerWidget>(() => tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
} }

View File

@@ -40,12 +40,11 @@ namespace OpenRA.Mods.Cnc.Widgets
readonly float2 holdOffset, readyOffset, timeOffset; readonly float2 holdOffset, readyOffset, timeOffset;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public SupportPowersWidget([ObjectCreator.Param] World world, public SupportPowersWidget(World world, WorldRenderer worldRenderer)
[ObjectCreator.Param] WorldRenderer worldRenderer)
{ {
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;
spm = world.LocalPlayer.PlayerActor.Trait<SupportPowerManager>(); spm = world.LocalPlayer.PlayerActor.Trait<SupportPowerManager>();
tooltipContainer = new Lazy<TooltipContainerWidget>(() => tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
iconSprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface<SupportPowerInfo>() ) iconSprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface<SupportPowerInfo>() )
@@ -117,16 +116,16 @@ namespace OpenRA.Mods.Cnc.Widgets
{ {
if (p.Power.Ready) if (p.Power.Ready)
overlayFont.DrawTextWithContrast("Ready", overlayFont.DrawTextWithContrast("Ready",
p.Pos + readyOffset, p.Pos + readyOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
else if (!p.Power.Active) else if (!p.Power.Active)
overlayFont.DrawTextWithContrast("On Hold", overlayFont.DrawTextWithContrast("On Hold",
p.Pos + holdOffset, p.Pos + holdOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
else else
overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(p.Power.RemainingTime), overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(p.Power.RemainingTime),
p.Pos + timeOffset, p.Pos + timeOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
} }
} }
@@ -139,7 +138,8 @@ namespace OpenRA.Mods.Cnc.Widgets
public override void MouseEntered() public override void MouseEntered()
{ {
if (TooltipContainer == null) return; if (TooltipContainer == null) return;
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() {{ "palette", this }}); tooltipContainer.Value.SetTooltip(TooltipTemplate,
new WidgetArgs() {{ "palette", this }});
} }
public override void MouseExited() public override void MouseExited()

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public ToggleButtonWidget() public ToggleButtonWidget()
: base() : base()
{ {
tooltipContainer = new Lazy<TooltipContainerWidget>(() => tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
} }
@@ -36,14 +36,15 @@ namespace OpenRA.Mods.Cnc.Widgets
TooltipTemplate = other.TooltipTemplate; TooltipTemplate = other.TooltipTemplate;
TooltipText = other.TooltipText; TooltipText = other.TooltipText;
TooltipContainer = other.TooltipContainer; TooltipContainer = other.TooltipContainer;
tooltipContainer = new Lazy<TooltipContainerWidget>(() => tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
} }
public override void MouseEntered() public override void MouseEntered()
{ {
if (TooltipContainer == null) return; if (TooltipContainer == null) return;
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() {{ "button", this }}); tooltipContainer.Value.SetTooltip(TooltipTemplate,
new WidgetArgs() {{ "button", this }});
} }
public override void MouseExited() public override void MouseExited()

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Widgets
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public BuildPaletteWidget( [ObjectCreator.Param] World world, [ObjectCreator.Param] WorldRenderer worldRenderer ) public BuildPaletteWidget(World world, WorldRenderer worldRenderer)
{ {
this.world = world; this.world = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;

View File

@@ -16,10 +16,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class ConnectionDialogsLogic public class ConnectionDialogsLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ConnectionDialogsLogic( public ConnectionDialogsLogic(Widget widget, string host, int port)
[ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] string host,
[ObjectCreator.Param] int port )
{ {
widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_ABORT").OnClick = () => { widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_ABORT").OnClick = () => {
widget.GetWidget("CONNECTION_BUTTON_ABORT").Parent.Visible = false; widget.GetWidget("CONNECTION_BUTTON_ABORT").Parent.Visible = false;
@@ -37,9 +34,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class ConnectionFailedLogic public class ConnectionFailedLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ConnectionFailedLogic( public ConnectionFailedLogic(Widget widget, OrderManager orderManager)
[ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] OrderManager orderManager)
{ {
widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_CANCEL").OnClick = () => { widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_CANCEL").OnClick = () => {
widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false; widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false;

View File

@@ -18,9 +18,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class CreateServerMenuLogic public class CreateServerMenuLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CreateServerMenuLogic( [ObjectCreator.Param( "widget" )] Widget cs ) public CreateServerMenuLogic(Widget widget)
{ {
var settings = Game.Settings; var settings = Game.Settings;
var cs = widget;
cs.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => Widget.CloseWindow(); cs.GetWidget<ButtonWidget>("BUTTON_CANCEL").OnClick = () => Widget.CloseWindow();
cs.GetWidget<ButtonWidget>("BUTTON_START").OnClick = () => cs.GetWidget<ButtonWidget>("BUTTON_START").OnClick = () =>

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class DeveloperModeLogic public class DeveloperModeLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public DeveloperModeLogic( [ObjectCreator.Param] World world ) public DeveloperModeLogic(World world)
{ {
var devmodeBG = Widget.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG"); var devmodeBG = Widget.RootWidget.GetWidget("INGAME_ROOT").GetWidget("DEVELOPERMODE_BG");
var devModeButton = Widget.RootWidget.GetWidget<ButtonWidget>("INGAME_DEVELOPERMODE_BUTTON"); var devModeButton = Widget.RootWidget.GetWidget<ButtonWidget>("INGAME_DEVELOPERMODE_BUTTON");

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public DiplomacyLogic( [ObjectCreator.Param] World world ) public DiplomacyLogic(World world)
{ {
this.world = world; this.world = world;
var root = Widget.RootWidget.GetWidget("INGAME_ROOT"); var root = Widget.RootWidget.GetWidget("INGAME_ROOT");

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class DirectConnectLogic public class DirectConnectLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public DirectConnectLogic( [ObjectCreator.Param] Widget widget ) public DirectConnectLogic(Widget widget)
{ {
var dc = widget.GetWidget("DIRECTCONNECT_BG"); var dc = widget.GetWidget("DIRECTCONNECT_BG");

View File

@@ -26,11 +26,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ProgressBarWidget progressBar; ProgressBarWidget progressBar;
LabelWidget statusLabel; LabelWidget statusLabel;
Action afterInstall; Action afterInstall;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public DownloadPackagesLogic([ObjectCreator.Param] Widget widget, public DownloadPackagesLogic(Widget widget, Dictionary<string,string> installData, Action afterInstall)
[ObjectCreator.Param] Dictionary<string,string> installData,
[ObjectCreator.Param] Action afterInstall)
{ {
this.installData = installData; this.installData = installData;
this.afterInstall = afterInstall; this.afterInstall = afterInstall;

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Widget gameRoot; Widget gameRoot;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public IngameChromeLogic( [ObjectCreator.Param] World world ) public IngameChromeLogic(World world)
{ {
Game.AddChatLine += AddChatLine; Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents; Game.BeforeGameStart += UnregisterEvents;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
// WTF duplication // WTF duplication
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public IngameObserverChromeLogic([ObjectCreator.Param] World world) public IngameObserverChromeLogic(World world)
{ {
Game.AddChatLine += AddChatLine; Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents; Game.BeforeGameStart += UnregisterEvents;

View File

@@ -36,14 +36,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
internal LobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby, internal LobbyLogic(Widget widget, World world, OrderManager orderManager, WorldRenderer worldRenderer)
[ObjectCreator.Param] World world, // Shellmap world
[ObjectCreator.Param] OrderManager orderManager,
[ObjectCreator.Param] WorldRenderer worldRenderer)
{ {
this.orderManager = orderManager; this.orderManager = orderManager;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;
this.lobby = lobby; this.lobby = widget;
Game.BeforeGameStart += CloseWindow; Game.BeforeGameStart += CloseWindow;
Game.LobbyInfoChanged += UpdateCurrentMap; Game.LobbyInfoChanged += UpdateCurrentMap;
Game.LobbyInfoChanged += UpdatePlayerList; Game.LobbyInfoChanged += UpdatePlayerList;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class MainMenuButtonsLogic public class MainMenuButtonsLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public MainMenuButtonsLogic([ObjectCreator.Param] Widget widget) public MainMenuButtonsLogic(Widget widget)
{ {
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "PERF_BG" ); Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "PERF_BG" );
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_JOIN").OnClick = () => Widget.OpenWindow("JOINSERVER_BG"); widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_JOIN").OnClick = () => Widget.OpenWindow("JOINSERVER_BG");

View File

@@ -21,12 +21,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ScrollPanelWidget scrollpanel; ScrollPanelWidget scrollpanel;
ScrollItemWidget itemTemplate; ScrollItemWidget itemTemplate;
string gameMode; string gameMode;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
internal MapChooserLogic([ObjectCreator.Param] Widget widget, internal MapChooserLogic(Widget widget, string initialMap, Action onExit, Action<Map> onSelect)
[ObjectCreator.Param] string initialMap,
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action<Map> onSelect)
{ {
map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)]; map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)];

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class OrderButtonsChromeLogic public class OrderButtonsChromeLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public OrderButtonsChromeLogic( [ObjectCreator.Param] World world ) public OrderButtonsChromeLogic(World world)
{ {
var r = Widget.RootWidget; var r = Widget.RootWidget;
var gameRoot = r.GetWidget("INGAME_ROOT"); var gameRoot = r.GetWidget("INGAME_ROOT");

View File

@@ -28,8 +28,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Widget installingContainer, insertDiskContainer; Widget installingContainer, insertDiskContainer;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public RAInstallFromCDLogic([ObjectCreator.Param] Widget widget, public RAInstallFromCDLogic(Widget widget, Action continueLoading)
[ObjectCreator.Param] Action continueLoading)
{ {
this.continueLoading = continueLoading; this.continueLoading = continueLoading;
panel = widget.GetWidget("INSTALL_FROMCD_PANEL"); panel = widget.GetWidget("INSTALL_FROMCD_PANEL");

View File

@@ -17,9 +17,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class RAInstallLogic public class RAInstallLogic
{ {
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public RAInstallLogic([ObjectCreator.Param] Widget widget, public RAInstallLogic(Widget widget, Dictionary<string,string> installData, Action continueLoading)
[ObjectCreator.Param] Dictionary<string,string> installData,
[ObjectCreator.Param] Action continueLoading)
{ {
var panel = widget.GetWidget("INSTALL_PANEL"); var panel = widget.GetWidget("INSTALL_PANEL");
var args = new WidgetArgs() var args = new WidgetArgs()

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Widget widget; Widget widget;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ReplayBrowserLogic( [ObjectCreator.Param] Widget widget ) public ReplayBrowserLogic(Widget widget)
{ {
this.widget = widget; this.widget = widget;

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ScrollItemWidget ServerTemplate; ScrollItemWidget ServerTemplate;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ServerBrowserLogic( [ObjectCreator.Param] Widget widget ) public ServerBrowserLogic(Widget widget)
{ {
var bg = widget.GetWidget("JOINSERVER_BG"); var bg = widget.GetWidget("JOINSERVER_BG");

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class SettingsMenuLogic public class SettingsMenuLogic
{ {
Widget bg; Widget bg;
public SettingsMenuLogic() public SettingsMenuLogic()
{ {
bg = Widget.RootWidget.GetWidget<BackgroundWidget>("SETTINGS_MENU"); bg = Widget.RootWidget.GetWidget<BackgroundWidget>("SETTINGS_MENU");

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Widgets
readonly PlayerResources playerResources; readonly PlayerResources playerResources;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public MoneyBinWidget( [ObjectCreator.Param] World world ) public MoneyBinWidget(World world)
{ {
this.world = world; this.world = world;
playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>(); playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Widgets
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public PowerBinWidget( [ObjectCreator.Param] World world ) public PowerBinWidget(World world)
{ {
this.world = world; this.world = world;

View File

@@ -45,8 +45,9 @@ namespace OpenRA.Mods.RA.Widgets
public float2 RadarOrigin { get { return radarOrigin; } } public float2 RadarOrigin { get { return radarOrigin; } }
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public RadarBinWidget( [ObjectCreator.Param] World world ) public RadarBinWidget(World world)
{ {
this.world = world; this.world = world;
var size = Math.Max(world.Map.Bounds.Width, world.Map.Bounds.Height); var size = Math.Max(world.Map.Bounds.Width, world.Map.Bounds.Height);

View File

@@ -35,11 +35,9 @@ namespace OpenRA.Mods.RA.Widgets
Sprite shroudSprite; Sprite shroudSprite;
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public RadarWidget( [ObjectCreator.Param] World world ) public RadarWidget(World world) { this.world = world; }
{
this.world = world;
}
public override void Initialize(WidgetArgs args) public override void Initialize(WidgetArgs args)
{ {

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Widgets
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public StrategicProgressWidget([ObjectCreator.Param] World world) public StrategicProgressWidget(World world)
{ {
IsVisible = () => true; IsVisible = () => true;
this.world = world; this.world = world;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Widgets
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public SupportPowerBinWidget([ObjectCreator.Param] World world, [ObjectCreator.Param] WorldRenderer worldRenderer) public SupportPowerBinWidget(World world, WorldRenderer worldRenderer)
{ {
this.world = world; this.world = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;

View File

@@ -32,10 +32,7 @@ namespace OpenRA.Mods.RA.Widgets
public readonly OrderManager OrderManager; public readonly OrderManager OrderManager;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public WorldCommandWidget([ObjectCreator.Param] OrderManager orderManager ) public WorldCommandWidget(OrderManager orderManager) { OrderManager = orderManager; }
{
OrderManager = orderManager;
}
public override string GetCursor(int2 pos) { return null; } public override string GetCursor(int2 pos) { return null; }
public override Rectangle GetEventBounds() { return Rectangle.Empty; } public override Rectangle GetEventBounds() { return Rectangle.Empty; }

View File

@@ -21,11 +21,9 @@ namespace OpenRA.Mods.RA.Widgets
{ {
public int TooltipDelay = 10; public int TooltipDelay = 10;
readonly World world; readonly World world;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public WorldTooltipWidget( [ObjectCreator.Param] World world ) public WorldTooltipWidget(World world) { this.world = world; }
{
this.world = world;
}
public override void Draw() public override void Draw()
{ {