render control group overlay

This commit is contained in:
Chris Forbes
2009-12-21 19:50:50 +13:00
parent d6be783ccf
commit 746cb90171
2 changed files with 19 additions and 1 deletions

View File

@@ -15,7 +15,6 @@ namespace OpenRa.Game.Graphics
public readonly TerrainRenderer terrainRenderer;
public readonly SpriteRenderer spriteRenderer;
public readonly LineRenderer lineRenderer;
//public readonly Region region;
public readonly UiOverlay uiOverlay;
readonly Renderer renderer;
@@ -115,6 +114,7 @@ namespace OpenRa.Game.Graphics
if (drawHealthBar)
{
DrawHealthBar(selectedUnit, xy, Xy);
DrawControlGroup(selectedUnit, xy);
// Only display pips and tags to the owner
if (selectedUnit.Owner == Game.LocalPlayer)
@@ -176,6 +176,17 @@ namespace OpenRa.Game.Graphics
static readonly string[] pipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray" };
static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" };
void DrawControlGroup(Actor selectedUnit, float2 basePosition)
{
var group = Game.controller.GetControlGroupForActor(selectedUnit);
if (group == null) return;
var pipImages = new Animation("pips");
pipImages.PlayFetchIndex("groups", () => (int)group);
pipImages.Tick();
spriteRenderer.DrawSprite(pipImages.Image, basePosition + new float2(-8, 1), 0);
}
void DrawPips(Actor selectedUnit, float2 basePosition)
{
// If a mod wants to implement a unit with multiple pip sources, then they are placed on multiple rows