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
/*
* 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);