Merge branch 'master' of git://github.com/chrisforbes/OpenRA

This commit is contained in:
Matthew Bowra-Dean
2009-12-21 21:36:50 +13:00
2 changed files with 23 additions and 1 deletions

View File

@@ -166,6 +166,10 @@ namespace OpenRa.Game
return;
controlGroups[group].Clear();
for (var i = 0; i < 10; i++) /* all control groups */
controlGroups[i].RemoveAll(a => uog.selection.Contains(a));
controlGroups[group].AddRange(uog.selection);
return;
}
@@ -179,5 +183,12 @@ namespace OpenRa.Game
if (uog == null) return;
CombineSelection(controlGroups[group], mods.HasModifier(Modifiers.Shift), false);
}
public int? GetControlGroupForActor(Actor a)
{
return controlGroups.Where(g => g.Value.Contains(a))
.Select(g => (int?)g.Key)
.FirstOrDefault();
}
}
}

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