Fix graphic corruptions by returning the max palette number to 16
This commit is contained in:
@@ -8,17 +8,18 @@ namespace OpenRa.Graphics
|
||||
{
|
||||
class HardwarePalette : Sheet
|
||||
{
|
||||
const int maxEntries = 32;
|
||||
const int maxEntries = 16;
|
||||
int allocated = 0;
|
||||
|
||||
// We need to store the Palettes themselves for the remap palettes to work
|
||||
// We should probably try to fix this somehow
|
||||
static Dictionary<string, Palette> palettes;
|
||||
|
||||
static Dictionary<string, int> indices;
|
||||
public HardwarePalette(Renderer renderer, Map map)
|
||||
: base(renderer,new Size(256, maxEntries))
|
||||
{
|
||||
palettes = new Dictionary<string, Palette>();
|
||||
indices = new Dictionary<string, int>();
|
||||
}
|
||||
|
||||
public Palette GetPalette(string name)
|
||||
@@ -31,9 +32,20 @@ namespace OpenRa.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
public int GetPaletteIndex(string name)
|
||||
{
|
||||
try { return indices[name]; }
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Palette `{0}` does not exist".F(name));
|
||||
}
|
||||
}
|
||||
|
||||
public int AddPalette(string name, Palette p)
|
||||
{
|
||||
palettes.Add(name, p);
|
||||
indices.Add(name, allocated);
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
this[new Point(i, allocated)] = p.GetColor(i);
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace OpenRa.Graphics
|
||||
for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ )
|
||||
{
|
||||
Sprite tile = tileMapping[map.MapTiles[i, j]];
|
||||
//var bar = Game.world.WorldRenderer;
|
||||
var foo = wr.GetPaletteIndex("terrain");
|
||||
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, foo, nv, ni, tile.size);
|
||||
// TODO: The zero below should explicitly refer to the terrain palette, but this code is called
|
||||
// before the palettes are created
|
||||
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size);
|
||||
nv += 4;
|
||||
ni += 6;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace OpenRa.Graphics
|
||||
// TODO: Implement
|
||||
public int GetPaletteIndex(string name)
|
||||
{
|
||||
return 0;
|
||||
return palette.GetPaletteIndex(name);
|
||||
}
|
||||
|
||||
|
||||
public Palette GetPalette(string name)
|
||||
{
|
||||
return palette.GetPalette(name);
|
||||
|
||||
Reference in New Issue
Block a user