Un-hardcodes pip/tag/group palettes.

-Palette for decorations can now be defined under SelectionDecorations trait.
-Adds pip types Ammo and AmmoEmpty.
-LimitedAmmo PipTypes are now customizable.
-Adds art, sequences and rules entries for TS mod decorations that were missing/using a wrong palette.
-Adds PrimaryBuilding trait to TS weapon factories and helipads.
This commit is contained in:
reaperrr
2014-04-28 19:12:41 +02:00
parent 0162cac91a
commit c8815e1413
10 changed files with 51 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -15,18 +15,25 @@ namespace OpenRA.Traits
{ {
public class SelectionDecorationsInfo : ITraitInfo public class SelectionDecorationsInfo : ITraitInfo
{ {
public object Create(ActorInitializer init) { return new SelectionDecorations(init.self); } public readonly string Palette = "chrome";
public object Create(ActorInitializer init) { return new SelectionDecorations(init.self, this); }
} }
public class SelectionDecorations : IPostRenderSelection public class SelectionDecorations : IPostRenderSelection
{ {
// depends on the order of pips in TraitsInterfaces.cs! // depends on the order of pips in TraitsInterfaces.cs!
static readonly string[] pipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue" }; static readonly string[] pipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue", "pip-ammo", "pip-ammoempty" };
static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" }; static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" };
public SelectionDecorationsInfo Info;
Actor self; Actor self;
public SelectionDecorations(Actor self) { this.self = self; } public SelectionDecorations(Actor self, SelectionDecorationsInfo info)
{
this.self = self;
Info = info;
}
public void RenderAfterWorld(WorldRenderer wr) public void RenderAfterWorld(WorldRenderer wr)
{ {
@@ -51,11 +58,12 @@ namespace OpenRA.Traits
if (group == null) return; if (group == null) return;
var pipImages = new Animation("pips"); var pipImages = new Animation("pips");
var pal = wr.Palette(Info.Palette);
pipImages.PlayFetchIndex("groups", () => (int)group); pipImages.PlayFetchIndex("groups", () => (int)group);
pipImages.Tick(); pipImages.Tick();
var pos = wr.Viewport.WorldToViewPx(basePosition) - (0.5f * pipImages.Image.size).ToInt2() + new int2(9, 5); var pos = wr.Viewport.WorldToViewPx(basePosition) - (0.5f * pipImages.Image.size).ToInt2() + new int2(9, 5);
Game.Renderer.SpriteRenderer.DrawSprite(pipImages.Image, pos, wr.Palette("chrome")); Game.Renderer.SpriteRenderer.DrawSprite(pipImages.Image, pos, pal);
} }
void DrawPips(WorldRenderer wr, Actor self, int2 basePosition) void DrawPips(WorldRenderer wr, Actor self, int2 basePosition)
@@ -73,7 +81,7 @@ namespace OpenRA.Traits
var pipSize = pipImages.Image.size.ToInt2(); var pipSize = pipImages.Image.size.ToInt2();
var pipxyBase = wr.Viewport.WorldToViewPx(basePosition) + new int2(1 - pipSize.X / 2, - (3 + pipSize.Y / 2)); var pipxyBase = wr.Viewport.WorldToViewPx(basePosition) + new int2(1 - pipSize.X / 2, - (3 + pipSize.Y / 2));
var pipxyOffset = new int2(0, 0); var pipxyOffset = new int2(0, 0);
var pal = wr.Palette("chrome"); var pal = wr.Palette(Info.Palette);
var width = self.Bounds.Value.Width; var width = self.Bounds.Value.Width;
foreach (var pips in pipSources) foreach (var pips in pipSources)
@@ -108,7 +116,7 @@ namespace OpenRA.Traits
return; return;
var tagImages = new Animation("pips"); var tagImages = new Animation("pips");
var pal = wr.Palette("chrome"); var pal = wr.Palette(Info.Palette);
var tagxyOffset = new int2(0, 6); var tagxyOffset = new int2(0, 6);
var tagBase = wr.Viewport.WorldToViewPx(basePosition); var tagBase = wr.Viewport.WorldToViewPx(basePosition);

View File

@@ -21,7 +21,7 @@ using OpenRA.Primitives;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
// depends on the order of pips in WorldRenderer.cs! // depends on the order of pips in WorldRenderer.cs!
public enum PipType { Transparent, Green, Yellow, Red, Gray, Blue }; public enum PipType { Transparent, Green, Yellow, Red, Gray, Blue, Ammo, AmmoEmpty };
public enum TagType { None, Fake, Primary }; public enum TagType { None, Fake, Primary };
public enum Stance { Enemy, Neutral, Ally }; public enum Stance { Enemy, Neutral, Ally };

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -19,6 +19,8 @@ namespace OpenRA.Mods.RA
public readonly int Ammo = 0; public readonly int Ammo = 0;
[Desc("Defaults to value in Ammo.")] [Desc("Defaults to value in Ammo.")]
public readonly int PipCount = 0; public readonly int PipCount = 0;
public readonly PipType PipType = PipType.Green;
public readonly PipType PipTypeEmpty = PipType.Transparent;
[Desc("Time to reload measured in ticks.")] [Desc("Time to reload measured in ticks.")]
public readonly int ReloadTicks = 25 * 2; public readonly int ReloadTicks = 25 * 2;
@@ -60,7 +62,7 @@ namespace OpenRA.Mods.RA
{ {
var pips = Info.PipCount != 0 ? Info.PipCount : Info.Ammo; var pips = Info.PipCount != 0 ? Info.PipCount : Info.Ammo;
return Exts.MakeArray(pips, return Exts.MakeArray(pips,
i => (ammo * pips) / Info.Ammo > i ? PipType.Green : PipType.Transparent); i => (ammo * pips) / Info.Ammo > i ? Info.PipType : Info.PipTypeEmpty);
} }
} }
} }

BIN
mods/ts/bits/ammopips.shp Normal file

Binary file not shown.

BIN
mods/ts/bits/pipsra.shp Normal file

Binary file not shown.

View File

@@ -30,6 +30,8 @@ DPOD:
LimitedAmmo: LimitedAmmo:
Ammo: 5 Ammo: 5
PipCount: 5 PipCount: 5
PipType: Ammo
PipTypeEmpty: AmmoEmpty
AutoTarget: AutoTarget:
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
@@ -97,6 +99,8 @@ ORCA:
LimitedAmmo: LimitedAmmo:
Ammo: 5 Ammo: 5
PipCount: 5 PipCount: 5
PipType: Ammo
PipTypeEmpty: AmmoEmpty
AutoTarget: AutoTarget:
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
@@ -132,6 +136,8 @@ ORCAB:
LimitedAmmo: LimitedAmmo:
Ammo: 2 Ammo: 2
PipCount: 2 PipCount: 2
PipType: Ammo
PipTypeEmpty: AmmoEmpty
AutoTarget: AutoTarget:
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
@@ -225,6 +231,8 @@ SCRIN:
LimitedAmmo: LimitedAmmo:
Ammo: 3 Ammo: 3
PipCount: 3 PipCount: 3
PipType: Ammo
PipTypeEmpty: AmmoEmpty
AutoTarget: AutoTarget:
RenderSprites: RenderSprites:
RenderVoxels: RenderVoxels:
@@ -260,6 +268,8 @@ APACHE:
LimitedAmmo: LimitedAmmo:
Ammo: 12 Ammo: 12
PipCount: 4 PipCount: 4
PipType: Ammo
PipTypeEmpty: AmmoEmpty
AutoTarget: AutoTarget:
WithRotor: WithRotor:
Offset: 85,0,384 Offset: 85,0,384

View File

@@ -1,6 +1,7 @@
^Building: ^Building:
AppearsOnRadar: AppearsOnRadar:
SelectionDecorations: SelectionDecorations:
Palette: pips
Selectable: Selectable:
Priority: 3 Priority: 3
TargetableBuilding: TargetableBuilding:
@@ -96,6 +97,7 @@
Gems: 80 Gems: 80
Beach: 80 Beach: 80
SelectionDecorations: SelectionDecorations:
Palette: pips
Selectable: Selectable:
Voice: Infantry Voice: Infantry
TargetableUnit: TargetableUnit:
@@ -167,6 +169,7 @@
Beach: 40 Beach: 40
ROT: 5 ROT: 5
SelectionDecorations: SelectionDecorations:
Palette: pips
Selectable: Selectable:
Voice: Vehicle Voice: Vehicle
TargetableUnit: TargetableUnit:
@@ -203,6 +206,7 @@
TargetTypes: Air TargetTypes: Air
GroundedTargetTypes: Ground GroundedTargetTypes: Ground
SelectionDecorations: SelectionDecorations:
Palette: pips
Selectable: Selectable:
Voice: Heli Voice: Heli
Helicopter: Helicopter:

View File

@@ -141,6 +141,7 @@ GAWEAP:
ExitCell: 3,3 ExitCell: 3,3
Production: Production:
Produces: Vehicle Produces: Vehicle
PrimaryBuilding:
ProductionBar: ProductionBar:
WithProductionOverlay@WHITELIGHTS: WithProductionOverlay@WHITELIGHTS:
Sequence: production-lights-white Sequence: production-lights-white
@@ -244,6 +245,7 @@ NAWEAP:
ExitCell: 3,3 ExitCell: 3,3
Production: Production:
Produces: Vehicle Produces: Vehicle
PrimaryBuilding:
ProductionBar: ProductionBar:
WithProductionOverlay@LIGHTS: WithProductionOverlay@LIGHTS:
Sequence: production-lights Sequence: production-lights
@@ -623,6 +625,7 @@ GAHPAD:
SpawnOffset: 0,-256,0 SpawnOffset: 0,-256,0
Production: Production:
Produces: Air Produces: Air
PrimaryBuilding:
BelowUnits: BelowUnits:
Reservable: Reservable:
RepairsUnits: RepairsUnits:
@@ -655,6 +658,7 @@ NAHPAD:
SpawnOffset: 0,-256,0 SpawnOffset: 0,-256,0
Production: Production:
Produces: Air Produces: Air
PrimaryBuilding:
BelowUnits: BelowUnits:
Reservable: Reservable:
RepairsUnits: RepairsUnits:

View File

@@ -17,6 +17,11 @@ World:
Filename: cameo.pal Filename: cameo.pal
AllowModifiers: false AllowModifiers: false
ShadowIndex: 242 ShadowIndex: 242
PaletteFromFile@pips:
Name: pips
Filename: palette.pal
AllowModifiers: false
ShadowIndex: 4
PaletteFromFile@ra: PaletteFromFile@ra:
Name: ra Name: ra
Filename: palette.pal Filename: palette.pal

View File

@@ -79,13 +79,14 @@ clock:
Start: 0 Start: 0
Length: * Length: *
# TODO:
# needs palette.pal
pips: pips:
medic: medic:
Start: 6 Start: 6
tag-primary: groups: pipsra #TODO: backfall to RA asset
Start: 8 Start: 8
Length: 10
tag-primary: pipsra #TODO: backfall to RA asset
Start: 2
pip-empty: pips2 pip-empty: pips2
Start: 0 Start: 0
pip-green: pips2 pip-green: pips2
@@ -98,8 +99,10 @@ pips:
Start: 4 Start: 4
pip-blue: pips2 pip-blue: pips2
Start: 5 Start: 5
pip-ammo: pips2 pip-ammo: ammopips
Start: 6 Start: 0
pip-ammoempty: ammopips
Start: 1
# TODO: # TODO:
pip-empty-building: pip-empty-building:
Start: 0 Start: 0