From c8815e1413768990f5f07eb0a1e0a1112e07526a Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 28 Apr 2014 19:12:41 +0200 Subject: [PATCH] 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. --- OpenRA.Game/Traits/SelectionDecorations.cs | 22 ++++++++++++++------- OpenRA.Game/Traits/TraitsInterfaces.cs | 2 +- OpenRA.Mods.RA/LimitedAmmo.cs | 6 ++++-- mods/ts/bits/ammopips.shp | Bin 0 -> 128 bytes mods/ts/bits/pipsra.shp | Bin 0 -> 1225 bytes mods/ts/rules/aircraft.yaml | 10 ++++++++++ mods/ts/rules/defaults.yaml | 4 ++++ mods/ts/rules/structures.yaml | 4 ++++ mods/ts/rules/world.yaml | 5 +++++ mods/ts/sequences/misc.yaml | 13 +++++++----- 10 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 mods/ts/bits/ammopips.shp create mode 100644 mods/ts/bits/pipsra.shp diff --git a/OpenRA.Game/Traits/SelectionDecorations.cs b/OpenRA.Game/Traits/SelectionDecorations.cs index 87f6178675..58a1db9c0f 100644 --- a/OpenRA.Game/Traits/SelectionDecorations.cs +++ b/OpenRA.Game/Traits/SelectionDecorations.cs @@ -1,6 +1,6 @@ #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 * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -15,18 +15,25 @@ namespace OpenRA.Traits { 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 { // 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" }; + public SelectionDecorationsInfo Info; 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) { @@ -51,11 +58,12 @@ namespace OpenRA.Traits if (group == null) return; var pipImages = new Animation("pips"); + var pal = wr.Palette(Info.Palette); pipImages.PlayFetchIndex("groups", () => (int)group); pipImages.Tick(); 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) @@ -73,7 +81,7 @@ namespace OpenRA.Traits var pipSize = pipImages.Image.size.ToInt2(); var pipxyBase = wr.Viewport.WorldToViewPx(basePosition) + new int2(1 - pipSize.X / 2, - (3 + pipSize.Y / 2)); var pipxyOffset = new int2(0, 0); - var pal = wr.Palette("chrome"); + var pal = wr.Palette(Info.Palette); var width = self.Bounds.Value.Width; foreach (var pips in pipSources) @@ -108,7 +116,7 @@ namespace OpenRA.Traits return; var tagImages = new Animation("pips"); - var pal = wr.Palette("chrome"); + var pal = wr.Palette(Info.Palette); var tagxyOffset = new int2(0, 6); var tagBase = wr.Viewport.WorldToViewPx(basePosition); diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 20ff3898b5..203cf1e23a 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -21,7 +21,7 @@ using OpenRA.Primitives; namespace OpenRA.Traits { // 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 Stance { Enemy, Neutral, Ally }; diff --git a/OpenRA.Mods.RA/LimitedAmmo.cs b/OpenRA.Mods.RA/LimitedAmmo.cs index 2444163c1e..aad0afcf4f 100644 --- a/OpenRA.Mods.RA/LimitedAmmo.cs +++ b/OpenRA.Mods.RA/LimitedAmmo.cs @@ -1,6 +1,6 @@ #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 * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -19,6 +19,8 @@ namespace OpenRA.Mods.RA public readonly int Ammo = 0; [Desc("Defaults to value in Ammo.")] public readonly int PipCount = 0; + public readonly PipType PipType = PipType.Green; + public readonly PipType PipTypeEmpty = PipType.Transparent; [Desc("Time to reload measured in ticks.")] public readonly int ReloadTicks = 25 * 2; @@ -60,7 +62,7 @@ namespace OpenRA.Mods.RA { var pips = Info.PipCount != 0 ? Info.PipCount : Info.Ammo; return Exts.MakeArray(pips, - i => (ammo * pips) / Info.Ammo > i ? PipType.Green : PipType.Transparent); + i => (ammo * pips) / Info.Ammo > i ? Info.PipType : Info.PipTypeEmpty); } } } diff --git a/mods/ts/bits/ammopips.shp b/mods/ts/bits/ammopips.shp new file mode 100644 index 0000000000000000000000000000000000000000..93a98a2cb15da114aff80aca531eec9b241c0fa4 GIT binary patch literal 128 zcmZQzU}NB7U}9ioU|?Wj-~`h^CKy-%No?XVAlY^vhW5^0p7yR@p1|O66dW8H$pZom NAjHDLgA)VQ003yI3oHNt literal 0 HcmV?d00001 diff --git a/mods/ts/bits/pipsra.shp b/mods/ts/bits/pipsra.shp new file mode 100644 index 0000000000000000000000000000000000000000..da81c9bf5976450dffd5837fbc9475a1296f10d2 GIT binary patch literal 1225 zcmY*YOKclO82)C)YlnCyJ5*6rlr~H(IDiCf=z&)YLkS34k+^Ar0}_}6MMynVP;x*7 z?QBfoV%$(QpL zjA03{A%`J+1fU6o1h@&QOxf0Yg7=Mo&{gZ-l%HeNrM;GqORPR_rfeZ2mK!wdt@ z3o)>JP{79P7X^$W`CG~UWP;z5T$B7tqHj_IyL}0MnqVUpv;FUJ`1>88s7j@B`z0)v zfZo%XN3mQk%ik@+a0UE>g&JS@@M;J+Y>~3>`_g(&!b2J(g>70#zJ#zI#UY#*V%)-%^?FqZ$fP0OHr}T^&%6oQV>n6eoJ+Mfk4iwT3 zCQC6yB&E$XCSfOnTp`ogjo`juL?5&nlRi4`q#fV52f-}l`6tl$3T8(z)+nHU0cJAD z=`2$EO`R?%J!y1EF-4%@l> z>sQ~y#y;S&3txg#IfA=_cMX~9Y>>*Q@sN?4k>lH|SXu4PBU)YSe13Z+ckZe2J&(tg zjO+UTbd66Rh<9gFik@m(DJre1c* z{GEs4{H-~nxOEIT+@7LeX9baxV9gr{&oEVE$}t`>RY@x@gpd`k*dmh^l5;Lrx#BgF zoFwO8Gj*ErbtcwHvBsHjT(BAwr{ zqm=Z?AI0h23g+-DB}BtV1DB>Riybv=ubKt8)su5|G$w}WZVKD+<4a{aSyy}4?w@MxgUDFS^Duf`KCL!U(fu} GLii7Q9UH0u literal 0 HcmV?d00001 diff --git a/mods/ts/rules/aircraft.yaml b/mods/ts/rules/aircraft.yaml index 4c8cea05ce..23925251c2 100644 --- a/mods/ts/rules/aircraft.yaml +++ b/mods/ts/rules/aircraft.yaml @@ -30,6 +30,8 @@ DPOD: LimitedAmmo: Ammo: 5 PipCount: 5 + PipType: Ammo + PipTypeEmpty: AmmoEmpty AutoTarget: RenderSprites: RenderVoxels: @@ -97,6 +99,8 @@ ORCA: LimitedAmmo: Ammo: 5 PipCount: 5 + PipType: Ammo + PipTypeEmpty: AmmoEmpty AutoTarget: RenderSprites: RenderVoxels: @@ -132,6 +136,8 @@ ORCAB: LimitedAmmo: Ammo: 2 PipCount: 2 + PipType: Ammo + PipTypeEmpty: AmmoEmpty AutoTarget: RenderSprites: RenderVoxels: @@ -225,6 +231,8 @@ SCRIN: LimitedAmmo: Ammo: 3 PipCount: 3 + PipType: Ammo + PipTypeEmpty: AmmoEmpty AutoTarget: RenderSprites: RenderVoxels: @@ -260,6 +268,8 @@ APACHE: LimitedAmmo: Ammo: 12 PipCount: 4 + PipType: Ammo + PipTypeEmpty: AmmoEmpty AutoTarget: WithRotor: Offset: 85,0,384 diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 3f81a22b31..e47b5c1a6d 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -1,6 +1,7 @@ ^Building: AppearsOnRadar: SelectionDecorations: + Palette: pips Selectable: Priority: 3 TargetableBuilding: @@ -96,6 +97,7 @@ Gems: 80 Beach: 80 SelectionDecorations: + Palette: pips Selectable: Voice: Infantry TargetableUnit: @@ -167,6 +169,7 @@ Beach: 40 ROT: 5 SelectionDecorations: + Palette: pips Selectable: Voice: Vehicle TargetableUnit: @@ -203,6 +206,7 @@ TargetTypes: Air GroundedTargetTypes: Ground SelectionDecorations: + Palette: pips Selectable: Voice: Heli Helicopter: diff --git a/mods/ts/rules/structures.yaml b/mods/ts/rules/structures.yaml index 5ea2d05bff..135820928e 100644 --- a/mods/ts/rules/structures.yaml +++ b/mods/ts/rules/structures.yaml @@ -141,6 +141,7 @@ GAWEAP: ExitCell: 3,3 Production: Produces: Vehicle + PrimaryBuilding: ProductionBar: WithProductionOverlay@WHITELIGHTS: Sequence: production-lights-white @@ -244,6 +245,7 @@ NAWEAP: ExitCell: 3,3 Production: Produces: Vehicle + PrimaryBuilding: ProductionBar: WithProductionOverlay@LIGHTS: Sequence: production-lights @@ -623,6 +625,7 @@ GAHPAD: SpawnOffset: 0,-256,0 Production: Produces: Air + PrimaryBuilding: BelowUnits: Reservable: RepairsUnits: @@ -655,6 +658,7 @@ NAHPAD: SpawnOffset: 0,-256,0 Production: Produces: Air + PrimaryBuilding: BelowUnits: Reservable: RepairsUnits: diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index cb3a069b6f..13759eea64 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -17,6 +17,11 @@ World: Filename: cameo.pal AllowModifiers: false ShadowIndex: 242 + PaletteFromFile@pips: + Name: pips + Filename: palette.pal + AllowModifiers: false + ShadowIndex: 4 PaletteFromFile@ra: Name: ra Filename: palette.pal diff --git a/mods/ts/sequences/misc.yaml b/mods/ts/sequences/misc.yaml index 1e38009345..e5d763e0c0 100644 --- a/mods/ts/sequences/misc.yaml +++ b/mods/ts/sequences/misc.yaml @@ -79,13 +79,14 @@ clock: Start: 0 Length: * -# TODO: -# needs palette.pal pips: medic: Start: 6 - tag-primary: + groups: pipsra #TODO: backfall to RA asset Start: 8 + Length: 10 + tag-primary: pipsra #TODO: backfall to RA asset + Start: 2 pip-empty: pips2 Start: 0 pip-green: pips2 @@ -98,8 +99,10 @@ pips: Start: 4 pip-blue: pips2 Start: 5 - pip-ammo: pips2 - Start: 6 + pip-ammo: ammopips + Start: 0 + pip-ammoempty: ammopips + Start: 1 # TODO: pip-empty-building: Start: 0