Fix graphic corruptions by returning the max palette number to 16
This commit is contained in:
@@ -36,7 +36,7 @@ namespace OpenRa
|
|||||||
|
|
||||||
if (name != null)
|
if (name != null)
|
||||||
{
|
{
|
||||||
Log.Write("Loading {0}",name.ToLowerInvariant());
|
//Log.Write("Loading {0}",name.ToLowerInvariant());
|
||||||
Info = Rules.Info[name.ToLowerInvariant()];
|
Info = Rules.Info[name.ToLowerInvariant()];
|
||||||
Health = this.GetMaxHP();
|
Health = this.GetMaxHP();
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,18 @@ namespace OpenRa.Graphics
|
|||||||
{
|
{
|
||||||
class HardwarePalette : Sheet
|
class HardwarePalette : Sheet
|
||||||
{
|
{
|
||||||
const int maxEntries = 32;
|
const int maxEntries = 16;
|
||||||
int allocated = 0;
|
int allocated = 0;
|
||||||
|
|
||||||
// We need to store the Palettes themselves for the remap palettes to work
|
// We need to store the Palettes themselves for the remap palettes to work
|
||||||
// We should probably try to fix this somehow
|
// We should probably try to fix this somehow
|
||||||
static Dictionary<string, Palette> palettes;
|
static Dictionary<string, Palette> palettes;
|
||||||
|
static Dictionary<string, int> indices;
|
||||||
public HardwarePalette(Renderer renderer, Map map)
|
public HardwarePalette(Renderer renderer, Map map)
|
||||||
: base(renderer,new Size(256, maxEntries))
|
: base(renderer,new Size(256, maxEntries))
|
||||||
{
|
{
|
||||||
palettes = new Dictionary<string, Palette>();
|
palettes = new Dictionary<string, Palette>();
|
||||||
|
indices = new Dictionary<string, int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Palette GetPalette(string name)
|
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)
|
public int AddPalette(string name, Palette p)
|
||||||
{
|
{
|
||||||
palettes.Add(name, p);
|
palettes.Add(name, p);
|
||||||
|
indices.Add(name, allocated);
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
this[new Point(i, allocated)] = p.GetColor(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++ )
|
for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ )
|
||||||
{
|
{
|
||||||
Sprite tile = tileMapping[map.MapTiles[i, j]];
|
Sprite tile = tileMapping[map.MapTiles[i, j]];
|
||||||
//var bar = Game.world.WorldRenderer;
|
// TODO: The zero below should explicitly refer to the terrain palette, but this code is called
|
||||||
var foo = wr.GetPaletteIndex("terrain");
|
// before the palettes are created
|
||||||
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, foo, nv, ni, tile.size);
|
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size);
|
||||||
nv += 4;
|
nv += 4;
|
||||||
ni += 6;
|
ni += 6;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRa.Graphics
|
|||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
public int GetPaletteIndex(string name)
|
public int GetPaletteIndex(string name)
|
||||||
{
|
{
|
||||||
return 0;
|
return palette.GetPaletteIndex(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Palette GetPalette(string name)
|
public Palette GetPalette(string name)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRa.Traits
|
|||||||
if (info.Theatre == null ||
|
if (info.Theatre == null ||
|
||||||
info.Theatre.ToLowerInvariant() == self.World.Map.Theater.ToLowerInvariant())
|
info.Theatre.ToLowerInvariant() == self.World.Map.Theater.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
Log.Write("Loading palette {0} from file {1}", info.Name, info.Filename);
|
//Log.Write("Loading palette {0} from file {1}", info.Name, info.Filename);
|
||||||
self.World.WorldRenderer.AddPalette(info.Name, new Palette(FileSystem.Open(info.Filename)));
|
self.World.WorldRenderer.AddPalette(info.Name, new Palette(FileSystem.Open(info.Filename)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace OpenRa.Traits
|
|||||||
// TODO: This shouldn't rely on a base palette
|
// TODO: This shouldn't rely on a base palette
|
||||||
var wr = self.World.WorldRenderer;
|
var wr = self.World.WorldRenderer;
|
||||||
var pal = wr.GetPalette("terrain");
|
var pal = wr.GetPalette("terrain");
|
||||||
|
|
||||||
wr.AddPalette("shroud", new Palette(pal, new ShroudPaletteRemap()));
|
wr.AddPalette("shroud", new Palette(pal, new ShroudPaletteRemap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ World:
|
|||||||
Name: player5
|
Name: player5
|
||||||
BasePalette: player
|
BasePalette: player
|
||||||
Remap: salmon.rem
|
Remap: salmon.rem
|
||||||
PaletteFromRemap@player6:
|
# PaletteFromRemap@player6:
|
||||||
Name: player6
|
# Name: player6
|
||||||
BasePalette: player
|
# BasePalette: player
|
||||||
Remap: green.rem
|
# Remap: green.rem
|
||||||
PaletteFromRemap@player7:
|
# PaletteFromRemap@player7:
|
||||||
Name: player7
|
# Name: player7
|
||||||
BasePalette: player
|
# BasePalette: player
|
||||||
Remap: gray.rem
|
# Remap: gray.rem
|
||||||
PaletteFromFile@chrome:
|
PaletteFromFile@chrome:
|
||||||
Name: chrome
|
Name: chrome
|
||||||
Filename: temperat.pal
|
Filename: temperat.pal
|
||||||
|
|||||||
Reference in New Issue
Block a user