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; } }
static Lazy<PlatformType> currentPlatform = new Lazy<PlatformType>(GetCurrentPlatform);
static Lazy<PlatformType> currentPlatform = Lazy.New(GetCurrentPlatform);
static PlatformType GetCurrentPlatform()
{

View File

@@ -78,8 +78,7 @@ namespace OpenRA
var a = new object[ p.Length ];
for( int i = 0 ; i < p.Length ; i++ )
{
var attr = p[ i ].GetCustomAttributes<ParamAttribute>().FirstOrDefault();
var key = (attr != null ? attr.ParamName : null) ?? p[i].Name;
var key = p[i].Name;
if ( !args.ContainsKey(key) ) throw new InvalidOperationException("ObjectCreator: key `{0}' not found".F(key));
a[ i ] = args[ key ];
}
@@ -94,22 +93,7 @@ namespace OpenRA
.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 )]
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)
* This file is part of OpenRA, which is free software. It is made
@@ -26,7 +26,7 @@ namespace OpenRA.Widgets
readonly OrderManager orderManager;
[ObjectCreator.UseCtor]
internal ChatEntryWidget( [ObjectCreator.Param] OrderManager orderManager )
internal ChatEntryWidget( OrderManager orderManager )
{
this.orderManager = orderManager;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,8 +15,7 @@ namespace OpenRA.Mods.Cnc
{
class PoisonedByTiberiumInfo : ITraitInfo
{
[WeaponReference]
public readonly string Weapon = "Tiberium";
[WeaponReference] public readonly string Weapon = "Tiberium";
public readonly string[] Resources = { "Tiberium", "BlueTiberium" };
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";
[ActorReference] public readonly string ActorType = "c17";
public override object Create(ActorInitializer init) { return new ProductionAirdrop(this); }
}

View File

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

View File

@@ -22,6 +22,8 @@ namespace OpenRA.Mods.RA.Render
class RenderGunboat : RenderSimple, INotifyDamageStateChanged
{
IFacing facing;
string lastDir = "left";
string lastDamage = "";
public RenderGunboat(Actor self)
: 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 } );
}
string lastDir = "left";
string lastDamage = "";
public override void Tick(Actor self)
{
var dir = (facing.Facing > 128) ? "right" : "left";

View File

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

View File

@@ -32,18 +32,18 @@ namespace OpenRA.Mods.Cnc.Widgets
ScrollDirection Edge;
[ObjectCreator.UseCtor]
public CncWorldInteractionControllerWidget([ObjectCreator.Param] World world,
[ObjectCreator.Param] WorldRenderer worldRenderer)
public CncWorldInteractionControllerWidget(World world, WorldRenderer worldRenderer)
: base(world, worldRenderer)
{
tooltipContainer = new Lazy<TooltipContainerWidget>(() =>
tooltipContainer = Lazy.New(() =>
Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));
}
public override void MouseEntered()
{
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()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public class CncPerfDebugLogic
{
[ObjectCreator.UseCtor]
public CncPerfDebugLogic([ObjectCreator.Param] Widget widget)
public CncPerfDebugLogic(Widget widget)
{
// 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)
* 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;
[ObjectCreator.UseCtor]
public CncReplayBrowserLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action onStart)
public CncReplayBrowserLogic(Widget widget, Action onExit, Action onStart)
{
panel = widget.GetWidget("REPLAYBROWSER_PANEL");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Cnc.Widgets
string queueGroup;
[ObjectCreator.UseCtor]
public ProductionTabsWidget([ObjectCreator.Param] World world)
public ProductionTabsWidget(World world)
{
Groups = Rules.Info.Values.SelectMany(a => a.Traits.WithInterface<ProductionQueueInfo>())
.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
IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0;
paletteWidget = new Lazy<ProductionPaletteWidget>(() =>
Widget.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget));
paletteWidget = Lazy.New(() => Widget.RootWidget.GetWidget<ProductionPaletteWidget>(PaletteWidget));
}
public void SelectNextTab(bool reverse)
@@ -108,10 +107,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public string QueueGroup
{
get
{
return queueGroup;
}
get { return queueGroup; }
set
{
ListOffset = 0;
@@ -122,10 +118,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public ProductionQueue CurrentQueue
{
get
{
return paletteWidget.Value.CurrentQueue;
}
get { return paletteWidget.Value.CurrentQueue; }
set
{
paletteWidget.Value.CurrentQueue = value;
@@ -268,7 +261,7 @@ namespace OpenRA.Mods.Cnc.Widgets
return true;
}
return (leftPressed || rightPressed);
return leftPressed || rightPressed;
}
public override bool HandleKeyPress(KeyInput e)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
public class MainMenuButtonsLogic
{
[ObjectCreator.UseCtor]
public MainMenuButtonsLogic([ObjectCreator.Param] Widget widget)
public MainMenuButtonsLogic(Widget widget)
{
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Widget.RootWidget, "PERF_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;
ScrollItemWidget itemTemplate;
string gameMode;
[ObjectCreator.UseCtor]
internal MapChooserLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] string initialMap,
[ObjectCreator.Param] Action onExit,
[ObjectCreator.Param] Action<Map> onSelect)
internal MapChooserLogic(Widget widget, string initialMap, Action onExit, Action<Map> onSelect)
{
map = Game.modData.AvailableMaps[WidgetUtils.ChooseInitialMap(initialMap)];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -45,8 +45,9 @@ namespace OpenRA.Mods.RA.Widgets
public float2 RadarOrigin { get { return radarOrigin; } }
readonly World world;
[ObjectCreator.UseCtor]
public RadarBinWidget( [ObjectCreator.Param] World world )
public RadarBinWidget(World world)
{
this.world = world;
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;
readonly World world;
[ObjectCreator.UseCtor]
public RadarWidget( [ObjectCreator.Param] World world )
{
this.world = world;
}
public RadarWidget(World world) { this.world = world; }
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)
* 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;
[ObjectCreator.UseCtor]
public StrategicProgressWidget([ObjectCreator.Param] World world)
public StrategicProgressWidget(World world)
{
IsVisible = () => true;
this.world = world;

View File

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

View File

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

View File

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