Split pip artwork into their own files and kill the hardcoded size/offset junk. Add a blue pip to support C&C blue tib. Fixes #836.

This commit is contained in:
Paul Chote
2011-07-24 00:31:49 +12:00
parent c793e8571f
commit 6c129eed3c
7 changed files with 40 additions and 37 deletions

View File

@@ -25,9 +25,9 @@ namespace OpenRA.Traits
public class Selectable : IPostRenderSelection public class Selectable : 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" }; static readonly string[] pipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue" };
static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" }; static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" };
public void RenderAfterWorld (WorldRenderer wr, Actor self) public void RenderAfterWorld (WorldRenderer wr, Actor self)
{ {
var bounds = self.Bounds.Value; var bounds = self.Bounds.Value;
@@ -154,11 +154,18 @@ namespace OpenRA.Traits
{ {
if (self.Owner != self.World.LocalPlayer) return; if (self.Owner != self.World.LocalPlayer) return;
// If a mod wants to implement a unit with multiple pip sources, then they are placed on multiple rows var pipSources = self.TraitsImplementing<IPips>();
var pipxyBase = basePosition + new float2(-12, -7); // Correct for the offset in the shp file if (pipSources.Count() == 0)
return;
var pipImages = new Animation("pips");
pipImages.PlayRepeating(pipStrings[0]);
var pipSize = pipImages.Image.size;
var pipxyBase = basePosition + new float2(1, -pipSize.Y);
var pipxyOffset = new float2(0, 0); // Correct for offset due to multiple columns/rows var pipxyOffset = new float2(0, 0); // Correct for offset due to multiple columns/rows
foreach (var pips in self.TraitsImplementing<IPips>()) foreach (var pips in pipSources)
{ {
var thisRow = pips.GetPips(self); var thisRow = pips.GetPips(self);
if (thisRow == null) if (thisRow == null)
@@ -168,19 +175,19 @@ namespace OpenRA.Traits
foreach (var pip in thisRow) foreach (var pip in thisRow)
{ {
if (pipxyOffset.X+5 > width) if (pipxyOffset.X + pipSize.X >= width)
{ {
pipxyOffset.X = 0; pipxyOffset.X = 0;
pipxyOffset.Y -= 4; pipxyOffset.Y -= pipSize.Y;
} }
var pipImages = new Animation("pips");
pipImages.PlayRepeating(pipStrings[(int)pip]); pipImages.PlayRepeating(pipStrings[(int)pip]);
pipImages.Image.DrawAt(wr, pipxyBase + pipxyOffset, "chrome"); pipImages.Image.DrawAt(wr, pipxyBase + pipxyOffset, "chrome");
pipxyOffset += new float2(4, 0); pipxyOffset += new float2(pipSize.X, 0);
} }
// Increment row // Increment row
pipxyOffset.X = 0; pipxyOffset.X = 0;
pipxyOffset.Y -= 5; pipxyOffset.Y -= pipSize.Y + 1;
} }
} }

View File

@@ -19,7 +19,7 @@ using OpenRA.Network;
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 }; public enum PipType { Transparent, Green, Yellow, Red, Gray, Blue };
public enum TagType { None, Fake, Primary }; public enum TagType { None, Fake, Primary };
public enum Stance { Enemy, Neutral, Ally }; public enum Stance { Enemy, Neutral, Ally };

BIN
mods/cnc/bits/pips.shp Normal file

Binary file not shown.

View File

@@ -115,8 +115,7 @@ World:
SpriteNames: bti1,bti2,bti3,bti4,bti5,bti6,bti7,bti8,bti9,bti10,bti11,bti12 SpriteNames: bti1,bti2,bti3,bti4,bti5,bti6,bti7,bti8,bti9,bti10,bti11,bti12
ValuePerUnit: 60 ValuePerUnit: 60
Name: Blue Tiberium Name: Blue Tiberium
# todo: add a blue pip. PipColor: Blue
PipColor: Red
AllowedTerrainTypes: Clear,Road AllowedTerrainTypes: Clear,Road
AllowUnderActors: false AllowUnderActors: false
SmudgeLayer@SCORCH: SmudgeLayer@SCORCH:

View File

@@ -197,22 +197,18 @@ clock:
Start: 0 Start: 0
Length: * Length: *
pips: pips:
ready: hpips pip-empty:
Start: 3
hold: hpips
Start: 4
pip-empty: hpips
Start: 0 Start: 0
pip-green: hpips pip-green:
Start: 1 Start: 1
pip-yellow: hpips pip-yellow:
Start: 5
pip-gray: hpips
Start: 6
pip-red: hpips
Start: 7
tag-primary: hpips
Start: 2 Start: 2
pip-gray:
Start: 3
pip-red:
Start: 4
pip-blue:
Start: 5
groups: pdigits groups: pdigits
Start: 0 Start: 0
Length: * Length: *

BIN
mods/ra/bits/pips2.shp Normal file

Binary file not shown.

View File

@@ -843,21 +843,22 @@ pips:
Start: 3 Start: 3
hold: hold:
Start: 4 Start: 4
pip-empty:
Start: 0
pip-green:
Start: 1
pip-yellow:
Start: 5
pip-gray:
Start: 6
pip-red:
Start: 7
tag-fake: tag-fake:
Start: 18 Start: 18
tag-primary: tag-primary:
Start: 2 Start: 2
pip-empty: pips2
Start: 0
pip-green: pips2
Start: 1
pip-yellow: pips2
Start: 2
pip-gray: pips2
Start: 3
pip-red: pips2
Start: 4
pip-blue: pips2
Start: 5
mig: mig:
idle: idle:
Start: 0 Start: 0