Merge branches 'bugfixes', 'shroud', 'cargo' and 'minimap'
This commit is contained in:
@@ -3,7 +3,12 @@ using OpenRa.FileFormats;
|
||||
|
||||
namespace OpenRa.Game.Graphics
|
||||
{
|
||||
public enum PaletteType { Gold, Blue, Red, Orange, Teal, Salmon, Green, Gray, Shadow, Invuln, Chrome };
|
||||
public enum PaletteType
|
||||
{
|
||||
Gold, Blue, Red, Orange, Teal, Salmon, Green, Gray,
|
||||
Shadow, Invuln, Chrome, Shroud,
|
||||
};
|
||||
|
||||
class HardwarePalette : Sheet
|
||||
{
|
||||
const int maxEntries = 16;
|
||||
@@ -21,6 +26,7 @@ namespace OpenRa.Game.Graphics
|
||||
AddPalette(new Palette(pal, new PaletteRemap(Color.FromArgb(140, 0, 0, 0))));
|
||||
AddPalette(pal); // iron curtain. todo: remap!
|
||||
AddPalette(pal); // chrome (it's like gold, but we're not going to hax it in palettemods)
|
||||
AddPalette(new Palette(pal, new ShroudPaletteRemap()));
|
||||
}
|
||||
|
||||
int AddPalette(Palette p)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.Traits;
|
||||
using OpenRa.FileFormats;
|
||||
|
||||
namespace OpenRa.Game.Graphics
|
||||
{
|
||||
@@ -9,7 +10,7 @@ namespace OpenRa.Game.Graphics
|
||||
Sheet sheet;
|
||||
SpriteRenderer spriteRenderer;
|
||||
Sprite sprite;
|
||||
Bitmap terrain;
|
||||
Bitmap terrain, oreLayer;
|
||||
|
||||
public void Tick() { }
|
||||
|
||||
@@ -21,20 +22,29 @@ namespace OpenRa.Game.Graphics
|
||||
}
|
||||
|
||||
// todo: extract these from the palette
|
||||
static readonly Color[] terrainTypeColors = {
|
||||
Color.Green,
|
||||
Color.Red,
|
||||
Color.Blue,
|
||||
Color.Yellow,
|
||||
Color.Purple,
|
||||
Color.Turquoise,
|
||||
Color.Violet,
|
||||
Color.Tomato,
|
||||
Color.Teal,
|
||||
};
|
||||
Color[] terrainTypeColors;
|
||||
|
||||
public void InvalidateOre() { oreLayer = null; }
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (terrainTypeColors == null)
|
||||
{
|
||||
var pal = new Palette(FileSystem.Open(Rules.Map.Theater + ".pal"));
|
||||
terrainTypeColors = new[] {
|
||||
pal.GetColor(0x1a),
|
||||
pal.GetColor(0x63),
|
||||
pal.GetColor(0x2f),
|
||||
pal.GetColor(0x1f),
|
||||
pal.GetColor(0x14),
|
||||
pal.GetColor(0x64),
|
||||
pal.GetColor(0x1f),
|
||||
pal.GetColor(0x68),
|
||||
pal.GetColor(0x6b),
|
||||
pal.GetColor(0x6d),
|
||||
};
|
||||
}
|
||||
|
||||
if (terrain == null)
|
||||
{
|
||||
terrain = new Bitmap(128, 128);
|
||||
@@ -45,14 +55,23 @@ namespace OpenRa.Game.Graphics
|
||||
: Color.Black);
|
||||
}
|
||||
|
||||
var bitmap = new Bitmap(terrain);
|
||||
if (oreLayer == null)
|
||||
{
|
||||
oreLayer = new Bitmap(terrain);
|
||||
for (var y = 0; y < 128; y++)
|
||||
for (var x = 0; x < 128; x++)
|
||||
if (Rules.Map.ContainsResource(new int2(x, y)))
|
||||
oreLayer.SetPixel(x, y, terrainTypeColors[(int)TerrainMovementType.Ore]);
|
||||
}
|
||||
|
||||
var bitmap = new Bitmap(oreLayer);
|
||||
|
||||
for( var y = 0; y < 128; y++ )
|
||||
for (var x = 0; x < 128; x++)
|
||||
{
|
||||
var b = Game.BuildingInfluence.GetBuildingAt(new int2(x, y));
|
||||
if (b != null)
|
||||
bitmap.SetPixel(x, y, b.Owner != null ? Chat.paletteColors[(int)b.Owner.Palette] : Color.Gray);
|
||||
bitmap.SetPixel(x, y, b.Owner != null ? Chat.paletteColors[(int)b.Owner.Palette] : terrainTypeColors[4]);
|
||||
}
|
||||
|
||||
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<Unit>()))
|
||||
@@ -63,7 +82,7 @@ namespace OpenRa.Game.Graphics
|
||||
|
||||
public void Draw(float2 pos)
|
||||
{
|
||||
spriteRenderer.DrawSprite(sprite, pos, PaletteType.Chrome);
|
||||
spriteRenderer.DrawSprite(sprite, pos, PaletteType.Chrome, new float2(256,256));
|
||||
spriteRenderer.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,12 +55,17 @@ namespace OpenRa.Game.Graphics
|
||||
}
|
||||
|
||||
public void DrawSprite(Sprite s, float2 location, PaletteType palette)
|
||||
{
|
||||
DrawSprite(s, location, palette, s.size);
|
||||
}
|
||||
|
||||
public void DrawSprite(Sprite s, float2 location, PaletteType palette, float2 size)
|
||||
{
|
||||
if (s.sheet != currentSheet)
|
||||
Flush();
|
||||
|
||||
currentSheet = s.sheet;
|
||||
Util.FastCreateQuad(vertices, indices, location.ToInt2(), s, (int) palette, nv, ni);
|
||||
Util.FastCreateQuad(vertices, indices, location.ToInt2(), s, (int)palette, nv, ni, size);
|
||||
nv += 4; ni += 6;
|
||||
if (++sprites >= spritesPerBatch)
|
||||
Flush();
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRa.Game.Graphics
|
||||
for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ )
|
||||
{
|
||||
Sprite tile = tileMapping[map.MapTiles[i, j]];
|
||||
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni);
|
||||
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size);
|
||||
nv += 4;
|
||||
ni += 6;
|
||||
}
|
||||
|
||||
@@ -57,14 +57,14 @@ namespace OpenRa.Game.Graphics
|
||||
|
||||
static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
|
||||
|
||||
public static void FastCreateQuad(Vertex[] vertices, ushort[] indices, float2 o, Sprite r, int palette, int nv, int ni)
|
||||
public static void FastCreateQuad(Vertex[] vertices, ushort[] indices, float2 o, Sprite r, int palette, int nv, int ni, float2 size)
|
||||
{
|
||||
float2 attrib = new float2(palette / 16.0f, channelSelect[(int)r.channel]);
|
||||
|
||||
vertices[nv] = new Vertex(KLerp(o, r.size, 0), r.FastMapTextureCoords(0), attrib);
|
||||
vertices[nv + 1] = new Vertex(KLerp(o, r.size, 1), r.FastMapTextureCoords(1), attrib);
|
||||
vertices[nv + 2] = new Vertex(KLerp(o, r.size, 2), r.FastMapTextureCoords(2), attrib);
|
||||
vertices[nv + 3] = new Vertex(KLerp(o, r.size, 3), r.FastMapTextureCoords(3), attrib);
|
||||
vertices[nv] = new Vertex(KLerp(o, size, 0), r.FastMapTextureCoords(0), attrib);
|
||||
vertices[nv + 1] = new Vertex(KLerp(o, size, 1), r.FastMapTextureCoords(1), attrib);
|
||||
vertices[nv + 2] = new Vertex(KLerp(o, size, 2), r.FastMapTextureCoords(2), attrib);
|
||||
vertices[nv + 3] = new Vertex(KLerp(o, size, 3), r.FastMapTextureCoords(3), attrib);
|
||||
|
||||
indices[ni] = (ushort)(nv);
|
||||
indices[ni + 1] = indices[ni + 3] = (ushort)(nv + 1);
|
||||
|
||||
@@ -87,6 +87,8 @@ namespace OpenRa.Game.Graphics
|
||||
if (Game.controller.orderGenerator != null)
|
||||
Game.controller.orderGenerator.Render();
|
||||
|
||||
Game.LocalPlayer.Shroud.Draw(spriteRenderer);
|
||||
|
||||
lineRenderer.Flush();
|
||||
spriteRenderer.Flush();
|
||||
}
|
||||
@@ -211,7 +213,7 @@ namespace OpenRa.Game.Graphics
|
||||
|
||||
foreach (var pips in selectedUnit.traits.WithInterface<IPips>())
|
||||
{
|
||||
foreach (var pip in pips.GetPips())
|
||||
foreach (var pip in pips.GetPips(selectedUnit))
|
||||
{
|
||||
var pipImages = new Animation("pips");
|
||||
pipImages.PlayRepeating(pipStrings[(int)pip]);
|
||||
|
||||
Reference in New Issue
Block a user