Support sprites with an internal offset.
This commit is contained in:
@@ -77,7 +77,8 @@ namespace OpenRA.Graphics
|
|||||||
return (TextureChannel)nextChannel;
|
return (TextureChannel)nextChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sprite Allocate(Size imageSize)
|
public Sprite Allocate(Size imageSize) { return Allocate(imageSize, float2.Zero); }
|
||||||
|
public Sprite Allocate(Size imageSize, float2 spriteOffset)
|
||||||
{
|
{
|
||||||
if (imageSize.Width + p.X > current.Size.Width)
|
if (imageSize.Width + p.X > current.Size.Width)
|
||||||
{
|
{
|
||||||
@@ -103,7 +104,7 @@ namespace OpenRA.Graphics
|
|||||||
p = new Point(0,0);
|
p = new Point(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
var rect = new Sprite(current, new Rectangle(p, imageSize), channel);
|
var rect = new Sprite(current, new Rectangle(p, imageSize), spriteOffset, channel);
|
||||||
p.X += imageSize.Width;
|
p.X += imageSize.Width;
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
|
|||||||
@@ -18,12 +18,17 @@ namespace OpenRA.Graphics
|
|||||||
public readonly Sheet sheet;
|
public readonly Sheet sheet;
|
||||||
public readonly TextureChannel channel;
|
public readonly TextureChannel channel;
|
||||||
public readonly float2 size;
|
public readonly float2 size;
|
||||||
|
public readonly float2 offset;
|
||||||
readonly float2[] textureCoords;
|
readonly float2[] textureCoords;
|
||||||
|
|
||||||
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
|
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
|
||||||
|
: this(sheet, bounds, float2.Zero, channel) {}
|
||||||
|
|
||||||
|
public Sprite(Sheet sheet, Rectangle bounds, float2 offset, TextureChannel channel)
|
||||||
{
|
{
|
||||||
this.bounds = bounds;
|
|
||||||
this.sheet = sheet;
|
this.sheet = sheet;
|
||||||
|
this.bounds = bounds;
|
||||||
|
this.offset = offset;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.size = new float2(bounds.Size);
|
this.size = new float2(bounds.Size);
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace OpenRA.Graphics
|
|||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
currentSheet = s.sheet;
|
currentSheet = s.sheet;
|
||||||
Util.FastCreateQuad(vertices, location.ToInt2(), s, paletteIndex, nv, size);
|
Util.FastCreateQuad(vertices, (location + s.offset).ToInt2(), s, paletteIndex, nv, size);
|
||||||
nv += 4;
|
nv += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user