From 6c129eed3cc8b54eaba799a6cde79d67ec867d02 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 24 Jul 2011 00:31:49 +1200 Subject: [PATCH] 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. --- OpenRA.Game/Traits/Selectable.cs | 27 ++++++++++++++++--------- OpenRA.Game/Traits/TraitsInterfaces.cs | 2 +- mods/cnc/bits/pips.shp | Bin 0 -> 186 bytes mods/cnc/rules/system.yaml | 3 +-- mods/cnc/sequences/misc.yaml | 22 +++++++++----------- mods/ra/bits/pips2.shp | Bin 0 -> 186 bytes mods/ra/sequences.yaml | 23 +++++++++++---------- 7 files changed, 40 insertions(+), 37 deletions(-) create mode 100644 mods/cnc/bits/pips.shp create mode 100644 mods/ra/bits/pips2.shp diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index 6d47002c86..394e3c6f08 100644 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -25,9 +25,9 @@ namespace OpenRA.Traits public class Selectable : IPostRenderSelection { // 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" }; - + public void RenderAfterWorld (WorldRenderer wr, Actor self) { var bounds = self.Bounds.Value; @@ -154,11 +154,18 @@ namespace OpenRA.Traits { 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 pipxyBase = basePosition + new float2(-12, -7); // Correct for the offset in the shp file + var pipSources = self.TraitsImplementing(); + 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 - foreach (var pips in self.TraitsImplementing()) + foreach (var pips in pipSources) { var thisRow = pips.GetPips(self); if (thisRow == null) @@ -168,19 +175,19 @@ namespace OpenRA.Traits foreach (var pip in thisRow) { - if (pipxyOffset.X+5 > width) + if (pipxyOffset.X + pipSize.X >= width) { pipxyOffset.X = 0; - pipxyOffset.Y -= 4; + pipxyOffset.Y -= pipSize.Y; } - var pipImages = new Animation("pips"); pipImages.PlayRepeating(pipStrings[(int)pip]); pipImages.Image.DrawAt(wr, pipxyBase + pipxyOffset, "chrome"); - pipxyOffset += new float2(4, 0); + pipxyOffset += new float2(pipSize.X, 0); } + // Increment row pipxyOffset.X = 0; - pipxyOffset.Y -= 5; + pipxyOffset.Y -= pipSize.Y + 1; } } diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index e4bac039a0..4abc737c77 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -19,7 +19,7 @@ using OpenRA.Network; namespace OpenRA.Traits { // 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 Stance { Enemy, Neutral, Ally }; diff --git a/mods/cnc/bits/pips.shp b/mods/cnc/bits/pips.shp new file mode 100644 index 0000000000000000000000000000000000000000..ba16ae2ace23e4284607b07f989eaf3c19565279 GIT binary patch literal 186 zcmZQ$009;t1OYz=h6WIw0HuqdbPJT82BlX(>0KbjNMOP&D=QN#1_m%TF)=Z0fQT$z uW@5E$IZyyDGH;HF)ttG=B5z-qSiN|LEK*-ETW)jVx_1A5di>AG%2$H literal 0 HcmV?d00001 diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 1517c646b7..3d900d4cf8 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -115,8 +115,7 @@ World: SpriteNames: bti1,bti2,bti3,bti4,bti5,bti6,bti7,bti8,bti9,bti10,bti11,bti12 ValuePerUnit: 60 Name: Blue Tiberium - # todo: add a blue pip. - PipColor: Red + PipColor: Blue AllowedTerrainTypes: Clear,Road AllowUnderActors: false SmudgeLayer@SCORCH: diff --git a/mods/cnc/sequences/misc.yaml b/mods/cnc/sequences/misc.yaml index e34cc9ee84..a6127ba68a 100644 --- a/mods/cnc/sequences/misc.yaml +++ b/mods/cnc/sequences/misc.yaml @@ -197,22 +197,18 @@ clock: Start: 0 Length: * pips: - ready: hpips - Start: 3 - hold: hpips - Start: 4 - pip-empty: hpips + pip-empty: Start: 0 - pip-green: hpips + pip-green: Start: 1 - pip-yellow: hpips - Start: 5 - pip-gray: hpips - Start: 6 - pip-red: hpips - Start: 7 - tag-primary: hpips + pip-yellow: Start: 2 + pip-gray: + Start: 3 + pip-red: + Start: 4 + pip-blue: + Start: 5 groups: pdigits Start: 0 Length: * diff --git a/mods/ra/bits/pips2.shp b/mods/ra/bits/pips2.shp new file mode 100644 index 0000000000000000000000000000000000000000..c6f99ce727ad9552ed9213bcb0e8c136c47c45b1 GIT binary patch literal 186 zcmZQ$009;t1OYz=h6WIw0HuqdbPJT82BlX(>0KbjNMM4zn3#YV0|OWf06_ypq^4Ft sthNp$027%rPe5$md}I;-B?4kgmLZEgyDcDg`#iG9p~C`VhmSx+0CvwGlmGw# literal 0 HcmV?d00001 diff --git a/mods/ra/sequences.yaml b/mods/ra/sequences.yaml index 00366bd153..83970fbb33 100644 --- a/mods/ra/sequences.yaml +++ b/mods/ra/sequences.yaml @@ -843,21 +843,22 @@ pips: Start: 3 hold: Start: 4 - pip-empty: - Start: 0 - pip-green: - Start: 1 - pip-yellow: - Start: 5 - pip-gray: - Start: 6 - pip-red: - Start: 7 tag-fake: Start: 18 tag-primary: 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: idle: Start: 0