added PaletteType enum
This commit is contained in:
@@ -48,7 +48,7 @@ namespace OpenRa.Game
|
||||
|
||||
public void AddLine(Player p, string text)
|
||||
{
|
||||
AddLine(paletteColors[p.Palette], p.PlayerName, text);
|
||||
AddLine(paletteColors[(int) p.Palette], p.PlayerName, text);
|
||||
}
|
||||
|
||||
public void AddLine(Color c, string from, string text)
|
||||
|
||||
@@ -9,6 +9,7 @@ using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.Support;
|
||||
using OpenRa.Game.GameRules;
|
||||
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
class Chrome : IHandleInput
|
||||
@@ -110,8 +111,8 @@ namespace OpenRa.Game
|
||||
|
||||
PerfHistory.Render(renderer, Game.worldRenderer.lineRenderer);
|
||||
|
||||
chromeRenderer.DrawSprite(specialBinSprite, float2.Zero, 0);
|
||||
chromeRenderer.DrawSprite(moneyBinSprite, new float2(Game.viewport.Width - 320, 0), 0);
|
||||
chromeRenderer.DrawSprite(specialBinSprite, float2.Zero, PaletteType.Gold);
|
||||
chromeRenderer.DrawSprite(moneyBinSprite, new float2(Game.viewport.Width - 320, 0), PaletteType.Gold);
|
||||
|
||||
DrawMoney();
|
||||
|
||||
@@ -158,8 +159,8 @@ namespace OpenRa.Game
|
||||
{
|
||||
x = Game.viewport.Width - tabWidth;
|
||||
}
|
||||
|
||||
chromeRenderer.DrawSprite(q.Value[index], new float2(x, y), 0);
|
||||
|
||||
chromeRenderer.DrawSprite(q.Value[index], new float2(x, y), PaletteType.Gold);
|
||||
|
||||
buttons.Add(Pair.New(new Rectangle(x, y, tabWidth, tabHeight),
|
||||
(Action<bool>)(isLmb => currentTab = groupName)));
|
||||
@@ -189,7 +190,7 @@ namespace OpenRa.Game
|
||||
var x = Game.viewport.Width - 155;
|
||||
foreach (var d in moneyDigits.Reverse())
|
||||
{
|
||||
chromeRenderer.DrawSprite(digitSprites[d - '0'], new float2(x, 6), 0);
|
||||
chromeRenderer.DrawSprite(digitSprites[d - '0'], new float2(x, 6), PaletteType.Gold);
|
||||
x -= 14;
|
||||
}
|
||||
}
|
||||
@@ -264,7 +265,7 @@ namespace OpenRa.Game
|
||||
var isBuildingThis = currentItem != null && currentItem.Item == item;
|
||||
var isBuildingSomethingElse = currentItem != null && currentItem.Item != item;
|
||||
|
||||
buildPaletteRenderer.DrawSprite(sprites[item], drawPos, HardwarePalette.Chrome);
|
||||
buildPaletteRenderer.DrawSprite(sprites[item], drawPos, PaletteType.Chrome);
|
||||
|
||||
if (rect.Contains(lastMousePos.ToPoint()))
|
||||
{
|
||||
@@ -279,7 +280,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
clockAnimations[queueName].Tick();
|
||||
buildPaletteRenderer.DrawSprite(clockAnimations[queueName].Image,
|
||||
drawPos, HardwarePalette.Chrome);
|
||||
drawPos, PaletteType.Chrome);
|
||||
|
||||
var overlayPos = drawPos + new float2((64 - ready.Image.size.X) / 2, 2);
|
||||
|
||||
@@ -305,26 +306,26 @@ namespace OpenRa.Game
|
||||
{
|
||||
var rect = new Rectangle(origin.X + x * 64, origin.Y + 48 * y, 64, 48);
|
||||
var drawPos = Game.viewport.Location + new float2(rect.Location);
|
||||
buildPaletteRenderer.DrawSprite(blank, drawPos, HardwarePalette.Chrome);
|
||||
buildPaletteRenderer.DrawSprite(blank, drawPos, PaletteType.Chrome);
|
||||
buttons.Add(Pair.New(rect, (Action<bool>)(_ => { })));
|
||||
if (++x == columns) { x = 0; y++; }
|
||||
}
|
||||
|
||||
foreach (var ob in overlayBits)
|
||||
buildPaletteRenderer.DrawSprite(ob.First, ob.Second, HardwarePalette.Chrome);
|
||||
buildPaletteRenderer.DrawSprite(ob.First, ob.Second, PaletteType.Chrome);
|
||||
|
||||
buildPaletteRenderer.Flush();
|
||||
|
||||
for (var j = 0; j < y; j++)
|
||||
chromeRenderer.DrawSprite(shimSprites[2], new float2(origin.X - 9, origin.Y + 48 * j), 0);
|
||||
chromeRenderer.DrawSprite(shimSprites[2], new float2(origin.X - 9, origin.Y + 48 * j), PaletteType.Gold);
|
||||
|
||||
chromeRenderer.DrawSprite(shimSprites[0], new float2(origin.X - 9, origin.Y - 9), 0);
|
||||
chromeRenderer.DrawSprite(shimSprites[1], new float2(origin.X - 9, origin.Y - 1 + 48 * y), 0);
|
||||
chromeRenderer.DrawSprite(shimSprites[0], new float2(origin.X - 9, origin.Y - 9), PaletteType.Gold);
|
||||
chromeRenderer.DrawSprite(shimSprites[1], new float2(origin.X - 9, origin.Y - 1 + 48 * y), PaletteType.Gold);
|
||||
|
||||
for (var i = 0; i < columns; i++)
|
||||
{
|
||||
chromeRenderer.DrawSprite(shimSprites[3], new float2(origin.X + 64 * i, origin.Y - 9), 0);
|
||||
chromeRenderer.DrawSprite(shimSprites[4], new float2(origin.X + 64 * i, origin.Y - 1 + 48 * y), 0);
|
||||
chromeRenderer.DrawSprite(shimSprites[3], new float2(origin.X + 64 * i, origin.Y - 9), PaletteType.Gold);
|
||||
chromeRenderer.DrawSprite(shimSprites[4], new float2(origin.X + 64 * i, origin.Y - 1 + 48 * y), PaletteType.Gold);
|
||||
}
|
||||
chromeRenderer.Flush();
|
||||
|
||||
@@ -414,7 +415,7 @@ namespace OpenRa.Game
|
||||
void DrawProductionTooltip(string unit, int2 pos)
|
||||
{
|
||||
var p = pos.ToFloat2() - new float2(tooltipSprite.size.X, 0);
|
||||
chromeRenderer.DrawSprite(tooltipSprite, p, 0);
|
||||
chromeRenderer.DrawSprite(tooltipSprite, p, PaletteType.Gold);
|
||||
chromeRenderer.Flush();
|
||||
|
||||
var info = Rules.UnitInfo[unit];
|
||||
|
||||
@@ -77,14 +77,14 @@ namespace OpenRa.Game.Effects
|
||||
if (Projectile.High || Projectile.Arcing)
|
||||
{
|
||||
if (Projectile.Shadow)
|
||||
yield return new Renderable(anim.Image, pos, 8);
|
||||
yield return new Renderable(anim.Image, pos, PaletteType.Shadow);
|
||||
|
||||
var highPos = pos - new float2(0, (VisualDest - Src).Length * height * 4 * at * (1 - at));
|
||||
|
||||
yield return new Renderable(anim.Image, highPos, Owner.Palette);
|
||||
}
|
||||
else
|
||||
yield return new Renderable(anim.Image, pos, Projectile.UnderWater ? 8 : Owner.Palette);
|
||||
yield return new Renderable(anim.Image, pos, Projectile.UnderWater ? PaletteType.Shadow : Owner.Palette);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRa.Game.Effects
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, 8);
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, PaletteType.Shadow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRa.Game
|
||||
var name = players.ContainsKey(i) ? players[i].PlayerName : "Player {0}".F(i+1);
|
||||
|
||||
var a = new Actor(null, new int2(int.MaxValue, int.MaxValue), null);
|
||||
players[i] = new Player(a, i, i, name, race, "Multi{0}".F(i));
|
||||
players[i] = new Player(a, i, (PaletteType) i, name, race, "Multi{0}".F(i));
|
||||
a.Owner = players[i];
|
||||
a.traits.Add(new Traits.ProductionQueue(a));
|
||||
Game.world.Add(a);
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
10
OpenRa.Game/Graphics/PaletteType.cs
Normal file
10
OpenRa.Game/Graphics/PaletteType.cs
Normal 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 };
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
<Compile Include="GameRules\TechTree.cs" />
|
||||
<Compile Include="GameRules\VoiceInfo.cs" />
|
||||
<Compile Include="Effects\IEffect.cs" />
|
||||
<Compile Include="Graphics\PaletteType.cs" />
|
||||
<Compile Include="IOrderSource.cs" />
|
||||
<Compile Include="LocalOrderSource.cs" />
|
||||
<Compile Include="Effects\Missile.cs" />
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.Traits;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
@@ -11,7 +12,7 @@ namespace OpenRa.Game
|
||||
class Player
|
||||
{
|
||||
public Actor PlayerActor;
|
||||
public int Palette;
|
||||
public PaletteType Palette;
|
||||
public int Kills;
|
||||
public string PlayerName;
|
||||
public string InternalName;
|
||||
@@ -26,7 +27,7 @@ namespace OpenRa.Game
|
||||
|
||||
public bool IsReady;
|
||||
|
||||
public Player( Actor playerActor, int index, int palette, string playerName, Race race, string internalName )
|
||||
public Player( Actor playerActor, int index, PaletteType palette, string playerName, Race race, string internalName )
|
||||
{
|
||||
this.PlayerActor = playerActor;
|
||||
this.Index = index;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRa.Game.Traits
|
||||
return rs;
|
||||
|
||||
if (self.Owner == Game.LocalPlayer)
|
||||
return rs.Select(a => a.WithPalette(8));
|
||||
return rs.Select(a => a.WithPalette(PaletteType.Shadow));
|
||||
else
|
||||
return new Renderable[] { };
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRa.Game.Traits
|
||||
return rs;
|
||||
|
||||
if (self.Owner == Game.LocalPlayer)
|
||||
return rs.Select(a => a.WithPalette(8));
|
||||
return rs.Select(a => a.WithPalette(PaletteType.Shadow));
|
||||
else
|
||||
return new Renderable[] { };
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
public readonly Sprite Sprite;
|
||||
public readonly float2 Pos;
|
||||
public readonly int Palette;
|
||||
public readonly PaletteType Palette;
|
||||
public readonly int ZOffset;
|
||||
|
||||
public Renderable(Sprite sprite, float2 pos, int palette, int zOffset)
|
||||
public Renderable(Sprite sprite, float2 pos, PaletteType palette, int zOffset)
|
||||
{
|
||||
Sprite = sprite;
|
||||
Pos = pos;
|
||||
@@ -26,10 +26,10 @@ namespace OpenRa.Game.Traits
|
||||
ZOffset = zOffset;
|
||||
}
|
||||
|
||||
public Renderable(Sprite sprite, float2 pos, int palette)
|
||||
public Renderable(Sprite sprite, float2 pos, PaletteType palette)
|
||||
: this(sprite, pos, palette, 0) { }
|
||||
|
||||
public Renderable WithPalette(int newPalette) { return new Renderable(Sprite, Pos, newPalette, ZOffset); }
|
||||
public Renderable WithPalette(PaletteType newPalette) { return new Renderable(Sprite, Pos, newPalette, ZOffset); }
|
||||
public Renderable WithZOffset(int newOffset) { return new Renderable(Sprite, Pos, Palette, newOffset); }
|
||||
public Renderable WithPos(float2 newPos) { return new Renderable(Sprite, newPos, Palette, ZOffset); }
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
var shadowSprites = r.Select(a => a.WithPalette(8));
|
||||
var shadowSprites = r.Select(a => a.WithPalette(PaletteType.Shadow));
|
||||
var flyingSprites = (unit.Altitude <= 0) ? r
|
||||
: r.Select(a => a.WithPos(a.Pos - new float2(0, unit.Altitude)).WithZOffset(3));
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.Traits;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
@@ -96,7 +97,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
int palette = int.Parse(order.TargetString);
|
||||
Game.chat.AddLine(order.Player, "has changed color to {0}".F(palette));
|
||||
order.Player.Palette = palette;
|
||||
order.Player.Palette = (PaletteType) palette;
|
||||
break;
|
||||
}
|
||||
case "StartGame":
|
||||
|
||||
Reference in New Issue
Block a user