git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1195 993157c7-ee19-0410-b2c4-bb4e9862e678

This commit is contained in:
chrisf
2007-07-13 11:12:16 +00:00
parent 9ffe1d2845
commit d4a7e5fb9e
10 changed files with 102 additions and 100 deletions

View File

@@ -21,6 +21,24 @@ namespace OpenRa.FileFormats
T current = null;
int x = 0, y = 0, rowHeight = 0;
TextureChannel? channel;
TextureChannel? NextChannel(TextureChannel? t)
{
if (t == null)
return TextureChannel.Red;
if (t == TextureChannel.Red)
return TextureChannel.Green;
if (t == TextureChannel.Green)
return TextureChannel.Blue;
if (t == TextureChannel.Blue)
return TextureChannel.Alpha;
return null;
}
public SheetRectangle<T> AddImage(Size imageSize)
{
@@ -28,7 +46,10 @@ namespace OpenRa.FileFormats
return null;
if (current == null)
{
current = pageProvider();
channel = NextChannel(null);
}
if (rowHeight == 0 || imageSize.Width + x > pageSize.Width)
{
@@ -42,11 +63,17 @@ namespace OpenRa.FileFormats
if (y + imageSize.Height > pageSize.Height)
{
current = pageProvider();
if (null == (channel = NextChannel(channel)))
{
current = pageProvider();
channel = NextChannel(channel);
}
x = y = rowHeight = 0;
}
SheetRectangle<T> rect = new SheetRectangle<T>(current, new Point(x, y), imageSize);
SheetRectangle<T> rect = new SheetRectangle<T>(current, new Point(x, y), imageSize, channel.Value);
x += imageSize.Width;
return rect;
@@ -68,11 +95,6 @@ namespace OpenRa.FileFormats
this.sheet = sheet;
this.channel = channel;
}
internal SheetRectangle(T sheet, Point origin, Size size)
: this(sheet, origin, size, TextureChannel.Red)
{
}
}
public enum TextureChannel