added PaletteType enum

This commit is contained in:
Alli
2009-12-23 22:24:20 +13:00
parent 8fa02ea6a3
commit 9e950c84ca
16 changed files with 50 additions and 39 deletions

View File

@@ -5,13 +5,10 @@ namespace OpenRa.Game.Graphics
{
class HardwarePalette : Sheet
{
public const int Shadow = 8;
public const int Invuln = 9;
public const int Chrome = 10;
const int maxEntries = 16;
int allocated = 0;
//Note: addPalette calls should match the ordering in PaletteType.cs
public HardwarePalette(Renderer renderer, Map map)
: base(renderer,new Size(256, maxEntries))
{

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Game.Graphics
{
//Note: should match the ordering in HardwarePalette.cs
enum PaletteType { Gold, Blue, Red, Orange, Teal, Salmon, Green, Gray, Shadow, Invuln, Chrome };
}

View File

@@ -54,13 +54,13 @@ namespace OpenRa.Game.Graphics
}
}
public void DrawSprite(Sprite s, float2 location, int palette)
public void DrawSprite(Sprite s, float2 location, PaletteType palette)
{
if (s.sheet != currentSheet)
Flush();
currentSheet = s.sheet;
Util.FastCreateQuad(vertices, indices, location, s, palette, nv, ni);
Util.FastCreateQuad(vertices, indices, location, s, (int) palette, nv, ni);
nv += 4; ni += 6;
if (++sprites >= spritesPerBatch)
Flush();

View File

@@ -197,7 +197,7 @@ namespace OpenRa.Game.Graphics
var pipImages = new Animation("pips");
pipImages.PlayFetchIndex("groups", () => (int)group);
pipImages.Tick();
spriteRenderer.DrawSprite(pipImages.Image, basePosition + new float2(-8, 1), HardwarePalette.Chrome);
spriteRenderer.DrawSprite(pipImages.Image, basePosition + new float2(-8, 1), PaletteType.Chrome);
}
void DrawPips(Actor selectedUnit, float2 basePosition)
@@ -212,7 +212,7 @@ namespace OpenRa.Game.Graphics
{
var pipImages = new Animation("pips");
pipImages.PlayRepeating(pipStrings[(int)pip]);
spriteRenderer.DrawSprite(pipImages.Image, pipxyBase + pipxyOffset, HardwarePalette.Chrome);
spriteRenderer.DrawSprite(pipImages.Image, pipxyBase + pipxyOffset, PaletteType.Chrome);
pipxyOffset += new float2(4, 0);
if (pipxyOffset.X+5 > selectedUnit.SelectedSize.X)
@@ -239,7 +239,7 @@ namespace OpenRa.Game.Graphics
{
var tagImages = new Animation("pips");
tagImages.PlayRepeating(tagStrings[(int)tag]);
spriteRenderer.DrawSprite(tagImages.Image, tagxyBase + tagxyOffset, HardwarePalette.Chrome);
spriteRenderer.DrawSprite(tagImages.Image, tagxyBase + tagxyOffset, PaletteType.Chrome);
// Increment row
tagxyOffset.Y += 8;