Simplify PaletteReference interface.
This commit is contained in:
@@ -149,14 +149,14 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
s[starti, j].DrawAt(
|
s[starti, j].DrawAt(
|
||||||
Game.CellSize * new float2(starti, j),
|
Game.CellSize * new float2(starti, j),
|
||||||
pal.RowIndex(wr),
|
pal.Index,
|
||||||
new float2(Game.CellSize * (i - starti), Game.CellSize));
|
new float2(Game.CellSize * (i - starti), Game.CellSize));
|
||||||
starti = i + 1;
|
starti = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s[i, j].DrawAt(
|
s[i, j].DrawAt(
|
||||||
Game.CellSize * new float2(i, j),
|
Game.CellSize * new float2(i, j),
|
||||||
pal.RowIndex(wr));
|
pal.Index);
|
||||||
starti = i + 1;
|
starti = i + 1;
|
||||||
last = s[i, j];
|
last = s[i, j];
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ namespace OpenRA.Graphics
|
|||||||
if (starti < clip.Right)
|
if (starti < clip.Right)
|
||||||
s[starti, j].DrawAt(
|
s[starti, j].DrawAt(
|
||||||
Game.CellSize * new float2(starti, j),
|
Game.CellSize * new float2(starti, j),
|
||||||
pal.RowIndex(wr),
|
pal.Index,
|
||||||
new float2(Game.CellSize * (clip.Right - starti), Game.CellSize));
|
new float2(Game.CellSize * (clip.Right - starti), Game.CellSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,28 +19,12 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
public class PaletteReference
|
public class PaletteReference
|
||||||
{
|
{
|
||||||
string name;
|
public readonly string Name;
|
||||||
int index;
|
public readonly int Index;
|
||||||
public PaletteReference(string name, int index)
|
public PaletteReference(string name, int index)
|
||||||
{
|
{
|
||||||
this.name = name;
|
Name = name;
|
||||||
this.index = index;
|
Index = index;
|
||||||
}
|
|
||||||
|
|
||||||
public static PaletteReference FromName(string name)
|
|
||||||
{
|
|
||||||
return new PaletteReference(name, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int RowIndex(WorldRenderer wr)
|
|
||||||
{
|
|
||||||
if (index == -1)
|
|
||||||
{
|
|
||||||
// Too spammy to enable by default
|
|
||||||
//Log.Write("perf", "Late resolution of palette reference {0}", name);
|
|
||||||
index = wr.GetPaletteIndex(name);
|
|
||||||
}
|
|
||||||
return index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +97,7 @@ namespace OpenRA.Graphics
|
|||||||
terrainRenderer.Draw(this, Game.viewport);
|
terrainRenderer.Draw(this, Game.viewport);
|
||||||
foreach (var a in world.traitDict.ActorsWithTraitMultiple<IRenderAsTerrain>(world))
|
foreach (var a in world.traitDict.ActorsWithTraitMultiple<IRenderAsTerrain>(world))
|
||||||
foreach (var r in a.Trait.RenderAsTerrain(this, a.Actor))
|
foreach (var r in a.Trait.RenderAsTerrain(this, a.Actor))
|
||||||
r.Sprite.DrawAt(r.Pos, r.Palette.RowIndex(this), r.Scale);
|
r.Sprite.DrawAt(r.Pos, r.Palette.Index, r.Scale);
|
||||||
|
|
||||||
foreach (var a in world.Selection.Actors)
|
foreach (var a in world.Selection.Actors)
|
||||||
if (!a.Destroyed)
|
if (!a.Destroyed)
|
||||||
@@ -126,7 +110,7 @@ namespace OpenRA.Graphics
|
|||||||
world.OrderGenerator.RenderBeforeWorld(this, world);
|
world.OrderGenerator.RenderBeforeWorld(this, world);
|
||||||
|
|
||||||
foreach (var image in SpritesToRender())
|
foreach (var image in SpritesToRender())
|
||||||
image.Sprite.DrawAt(image.Pos, image.Palette.RowIndex(this), image.Scale);
|
image.Sprite.DrawAt(image.Pos, image.Palette.Index, image.Scale);
|
||||||
|
|
||||||
// added for contrails
|
// added for contrails
|
||||||
foreach (var a in world.ActorsWithTrait<IPostRender>())
|
foreach (var a in world.ActorsWithTrait<IPostRender>())
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
|
|
||||||
foreach (var r in preview)
|
foreach (var r in preview)
|
||||||
r.Sprite.DrawAt(topLeft.ToPPos().ToFloat2() + r.Pos,
|
r.Sprite.DrawAt(topLeft.ToPPos().ToFloat2() + r.Pos,
|
||||||
r.Palette.RowIndex(wr),
|
r.Palette.Index,
|
||||||
r.Scale*r.Sprite.size);
|
r.Scale*r.Sprite.size);
|
||||||
|
|
||||||
var res = world.WorldActor.Trait<ResourceLayer>();
|
var res = world.WorldActor.Trait<ResourceLayer>();
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ namespace OpenRA.Mods.RA
|
|||||||
var targetCell = unit.Location + (xy - sourceLocation);
|
var targetCell = unit.Location + (xy - sourceLocation);
|
||||||
foreach (var r in unit.Render(wr))
|
foreach (var r in unit.Render(wr))
|
||||||
r.Sprite.DrawAt(r.Pos - Traits.Util.CenterOfCell(unit.Location).ToFloat2() + Traits.Util.CenterOfCell(targetCell).ToFloat2(),
|
r.Sprite.DrawAt(r.Pos - Traits.Util.CenterOfCell(unit.Location).ToFloat2() + Traits.Util.CenterOfCell(targetCell).ToFloat2(),
|
||||||
r.Palette.RowIndex(wr),
|
r.Palette.Index,
|
||||||
r.Scale*r.Sprite.size);
|
r.Scale*r.Sprite.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user