Make support power icons configurable and testable.

This commit is contained in:
Matthias Mailänder
2020-03-21 11:57:52 +01:00
committed by atlimit8
parent 85096c4ba2
commit d187575a2c
3 changed files with 13 additions and 7 deletions

View File

@@ -17,7 +17,17 @@ namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Measured in ticks.")] [Desc("Measured in ticks.")]
public readonly int ChargeInterval = 0; 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; public readonly string Icon = null;
[PaletteReference]
[Desc("Palette used for the icon.")]
public readonly string IconPalette = "chrome";
public readonly string Description = ""; public readonly string Description = "";
public readonly string LongDesc = ""; public readonly string LongDesc = "";
public readonly bool AllowMultiple = false; public readonly bool AllowMultiple = false;
@@ -64,10 +74,6 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Defines to which players the timer is shown.")] [Desc("Defines to which players the timer is shown.")]
public readonly Stance DisplayTimerStances = Stance.None; 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")] [Desc("Beacons are only supported on the Airstrike, Paratroopers, and Nuke powers")]
public readonly bool DisplayBeacon = false; public readonly bool DisplayBeacon = false;

View File

@@ -23,7 +23,6 @@ namespace OpenRA.Mods.Common.Widgets
{ {
public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP"; public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP";
public readonly string TooltipContainer; public readonly string TooltipContainer;
readonly Animation icon;
readonly World world; readonly World world;
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
readonly Dictionary<string, Animation> clocks; readonly Dictionary<string, Animation> clocks;
@@ -45,6 +44,7 @@ namespace OpenRA.Mods.Common.Widgets
readonly List<SupportPowersWidget.SupportPowerIcon> supportPowerIconsIcons = new List<SupportPowersWidget.SupportPowerIcon>(); readonly List<SupportPowersWidget.SupportPowerIcon> supportPowerIconsIcons = new List<SupportPowersWidget.SupportPowerIcon>();
readonly List<Rectangle> supportPowerIconsBounds = new List<Rectangle>(); readonly List<Rectangle> supportPowerIconsBounds = new List<Rectangle>();
Animation icon;
int lastIconIdx; int lastIconIdx;
int currentTooltipToken; int currentTooltipToken;
@@ -54,7 +54,6 @@ namespace OpenRA.Mods.Common.Widgets
this.world = world; this.world = world;
this.worldRenderer = worldRenderer; this.worldRenderer = worldRenderer;
clocks = new Dictionary<string, Animation>(); clocks = new Dictionary<string, Animation>();
icon = new Animation(world, "icon");
// Timers in replays should be synced to the effective game time, not the playback time. // Timers in replays should be synced to the effective game time, not the playback time.
timestep = world.Timestep; timestep = world.Timestep;
@@ -125,6 +124,7 @@ namespace OpenRA.Mods.Common.Widgets
if (item == null || item.Info == null || item.Info.Icon == null) if (item == null || item.Info == null || item.Info.Icon == null)
continue; continue;
icon = new Animation(worldRenderer.World, item.Info.IconImage);
icon.Play(item.Info.Icon); icon.Play(item.Info.Icon);
var location = new float2(RenderBounds.Location) + new float2(power.i * (IconWidth + IconSpacing), 0); var location = new float2(RenderBounds.Location) + new float2(power.i * (IconWidth + IconSpacing), 0);

View File

@@ -98,7 +98,6 @@ namespace OpenRA.Mods.Common.Widgets
tooltipContainer = Exts.Lazy(() => tooltipContainer = Exts.Lazy(() =>
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer)); Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
icon = new Animation(world, "icon");
clock = new Animation(world, ClockAnimation); clock = new Animation(world, ClockAnimation);
} }
@@ -138,6 +137,7 @@ namespace OpenRA.Mods.Common.Widgets
else else
rect = new Rectangle(rb.X, rb.Y + IconCount * (IconSize.Y + IconMargin), IconSize.X, IconSize.Y); 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); icon.Play(p.Info.Icon);
var power = new SupportPowerIcon() var power = new SupportPowerIcon()