Add remappable support to production icons.
This commit is contained in:
committed by
abcdefg30
parent
df4c363e9c
commit
9050a2447b
@@ -38,10 +38,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Sequence of the actor that contains the icon.")]
|
[Desc("Sequence of the actor that contains the icon.")]
|
||||||
public readonly string Icon = "icon";
|
public readonly string Icon = "icon";
|
||||||
|
|
||||||
[PaletteReference]
|
[PaletteReference("IconPaletteIsPlayerPalette")]
|
||||||
[Desc("Palette used for the production icon.")]
|
[Desc("Palette used for the production icon.")]
|
||||||
public readonly string IconPalette = "chrome";
|
public readonly string IconPalette = "chrome";
|
||||||
|
|
||||||
|
[Desc("Custom palette is a player palette BaseName")]
|
||||||
|
public readonly bool IconPaletteIsPlayerPalette = false;
|
||||||
|
|
||||||
[Desc("Base build time in frames (-1 indicates to use the unit's Value).")]
|
[Desc("Base build time in frames (-1 indicates to use the unit's Value).")]
|
||||||
public readonly int BuildDuration = -1;
|
public readonly int BuildDuration = -1;
|
||||||
|
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly ActorInfo ActorInfo;
|
public readonly ActorInfo ActorInfo;
|
||||||
public readonly Animation Icon;
|
public readonly Animation Icon;
|
||||||
public readonly string IconPalette;
|
public readonly string IconPalette;
|
||||||
|
public readonly bool IconPaletteIsPlayerPalette;
|
||||||
public readonly int ProductionQueueOrder;
|
public readonly int ProductionQueueOrder;
|
||||||
public readonly int BuildPaletteOrder;
|
public readonly int BuildPaletteOrder;
|
||||||
public readonly TooltipInfo TooltipInfo;
|
public readonly TooltipInfo TooltipInfo;
|
||||||
@@ -189,6 +190,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Icon = new Animation(owner.World, image);
|
Icon = new Animation(owner.World, image);
|
||||||
Icon.Play(BuildableInfo.Icon);
|
Icon.Play(BuildableInfo.Icon);
|
||||||
IconPalette = BuildableInfo.IconPalette;
|
IconPalette = BuildableInfo.IconPalette;
|
||||||
|
IconPaletteIsPlayerPalette = BuildableInfo.IconPaletteIsPlayerPalette;
|
||||||
BuildPaletteOrder = BuildableInfo.BuildPaletteOrder;
|
BuildPaletteOrder = BuildableInfo.BuildPaletteOrder;
|
||||||
ProductionQueueOrder = queues.Where(q => BuildableInfo.Queue.Contains(q.Type))
|
ProductionQueueOrder = queues.Where(q => BuildableInfo.Queue.Contains(q.Type))
|
||||||
.Select(q => q.DisplayOrder)
|
.Select(q => q.DisplayOrder)
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
var iconTopLeft = RenderOrigin + topLeftOffset;
|
var iconTopLeft = RenderOrigin + topLeftOffset;
|
||||||
var centerPosition = iconTopLeft;
|
var centerPosition = iconTopLeft;
|
||||||
|
|
||||||
WidgetUtils.DrawSHPCentered(icon.Image, centerPosition + 0.5f * iconSize, worldRenderer.Palette(unit.IconPalette), 0.5f);
|
var palette = unit.IconPaletteIsPlayerPalette ? unit.IconPalette + player.InternalName : unit.IconPalette;
|
||||||
|
WidgetUtils.DrawSHPCentered(icon.Image, centerPosition + 0.5f * iconSize, worldRenderer.Palette(palette), 0.5f);
|
||||||
|
|
||||||
armyIcons.Add(new ArmyIcon
|
armyIcons.Add(new ArmyIcon
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -146,7 +146,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
var iconTopLeft = RenderOrigin + topLeftOffset;
|
var iconTopLeft = RenderOrigin + topLeftOffset;
|
||||||
var centerPosition = iconTopLeft + 0.5f * iconSize;
|
var centerPosition = iconTopLeft + 0.5f * iconSize;
|
||||||
|
|
||||||
WidgetUtils.DrawSHPCentered(icon.Image, centerPosition, worldRenderer.Palette(bi.IconPalette), 0.5f);
|
var palette = bi.IconPaletteIsPlayerPalette ? bi.IconPalette + player.InternalName : bi.IconPalette;
|
||||||
|
WidgetUtils.DrawSHPCentered(icon.Image, centerPosition, worldRenderer.Palette(palette), 0.5f);
|
||||||
|
|
||||||
var rect = new Rectangle((int)iconTopLeft.X, (int)iconTopLeft.Y, (int)iconSize.X, (int)iconSize.Y);
|
var rect = new Rectangle((int)iconTopLeft.X, (int)iconTopLeft.Y, (int)iconSize.X, (int)iconSize.Y);
|
||||||
productionIcons.Add(new ProductionIcon
|
productionIcons.Add(new ProductionIcon
|
||||||
|
|||||||
@@ -433,13 +433,15 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
var bi = item.TraitInfo<BuildableInfo>();
|
var bi = item.TraitInfo<BuildableInfo>();
|
||||||
icon.Play(bi.Icon);
|
icon.Play(bi.Icon);
|
||||||
|
|
||||||
|
var palette = bi.IconPaletteIsPlayerPalette ? bi.IconPalette + producer.Actor.Owner.InternalName : bi.IconPalette;
|
||||||
|
|
||||||
var pi = new ProductionIcon()
|
var pi = new ProductionIcon()
|
||||||
{
|
{
|
||||||
Actor = item,
|
Actor = item,
|
||||||
Name = item.Name,
|
Name = item.Name,
|
||||||
Hotkey = DisplayedIconCount < HotkeyCount ? hotkeys[DisplayedIconCount] : null,
|
Hotkey = DisplayedIconCount < HotkeyCount ? hotkeys[DisplayedIconCount] : null,
|
||||||
Sprite = icon.Image,
|
Sprite = icon.Image,
|
||||||
Palette = worldRenderer.Palette(bi.IconPalette),
|
Palette = worldRenderer.Palette(palette),
|
||||||
IconClockPalette = worldRenderer.Palette(ClockPalette),
|
IconClockPalette = worldRenderer.Palette(ClockPalette),
|
||||||
IconDarkenPalette = worldRenderer.Palette(NotBuildablePalette),
|
IconDarkenPalette = worldRenderer.Palette(NotBuildablePalette),
|
||||||
Pos = new float2(rect.Location),
|
Pos = new float2(rect.Location),
|
||||||
|
|||||||
Reference in New Issue
Block a user