diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs index cd6f81b786..be6f77d1c3 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs @@ -17,7 +17,17 @@ namespace OpenRA.Mods.Common.Traits { [Desc("Measured in ticks.")] public readonly int ChargeInterval = 0; + + public readonly string IconImage = "icon"; + + [SequenceReference("IconImage")] + [Desc("Icon sprite displayed in the support power palette.")] public readonly string Icon = null; + + [PaletteReference] + [Desc("Palette used for the icon.")] + public readonly string IconPalette = "chrome"; + public readonly string Description = ""; public readonly string LongDesc = ""; public readonly bool AllowMultiple = false; @@ -64,10 +74,6 @@ namespace OpenRA.Mods.Common.Traits [Desc("Defines to which players the timer is shown.")] public readonly Stance DisplayTimerStances = Stance.None; - [PaletteReference] - [Desc("Palette used for the icon.")] - public readonly string IconPalette = "chrome"; - [Desc("Beacons are only supported on the Airstrike, Paratroopers, and Nuke powers")] public readonly bool DisplayBeacon = false; diff --git a/OpenRA.Mods.Common/Widgets/ObserverSupportPowerIconsWidget.cs b/OpenRA.Mods.Common/Widgets/ObserverSupportPowerIconsWidget.cs index a4ee3b1dbd..daea82b545 100644 --- a/OpenRA.Mods.Common/Widgets/ObserverSupportPowerIconsWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ObserverSupportPowerIconsWidget.cs @@ -23,7 +23,6 @@ namespace OpenRA.Mods.Common.Widgets { public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP"; public readonly string TooltipContainer; - readonly Animation icon; readonly World world; readonly WorldRenderer worldRenderer; readonly Dictionary clocks; @@ -45,6 +44,7 @@ namespace OpenRA.Mods.Common.Widgets readonly List supportPowerIconsIcons = new List(); readonly List supportPowerIconsBounds = new List(); + Animation icon; int lastIconIdx; int currentTooltipToken; @@ -54,7 +54,6 @@ namespace OpenRA.Mods.Common.Widgets this.world = world; this.worldRenderer = worldRenderer; clocks = new Dictionary(); - icon = new Animation(world, "icon"); // Timers in replays should be synced to the effective game time, not the playback time. timestep = world.Timestep; @@ -125,6 +124,7 @@ namespace OpenRA.Mods.Common.Widgets if (item == null || item.Info == null || item.Info.Icon == null) continue; + icon = new Animation(worldRenderer.World, item.Info.IconImage); icon.Play(item.Info.Icon); var location = new float2(RenderBounds.Location) + new float2(power.i * (IconWidth + IconSpacing), 0); diff --git a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs index 40fe03032a..20aed21a1f 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs @@ -98,7 +98,6 @@ namespace OpenRA.Mods.Common.Widgets tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); - icon = new Animation(world, "icon"); clock = new Animation(world, ClockAnimation); } @@ -138,6 +137,7 @@ namespace OpenRA.Mods.Common.Widgets else rect = new Rectangle(rb.X, rb.Y + IconCount * (IconSize.Y + IconMargin), IconSize.X, IconSize.Y); + icon = new Animation(worldRenderer.World, p.Info.IconImage); icon.Play(p.Info.Icon); var power = new SupportPowerIcon()