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

@@ -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()