git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1195 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -24,28 +24,26 @@ namespace OpenRa.FileFormats
|
||||
if( countStr == null || startStr == null || pattern == null )
|
||||
break;
|
||||
|
||||
//try
|
||||
int count = int.Parse( countStr );
|
||||
int start = int.Parse( startStr, NumberStyles.HexNumber );
|
||||
for( int i = 0 ; i < count ; i++ )
|
||||
{
|
||||
int count = int.Parse( countStr );
|
||||
int start = int.Parse( startStr, NumberStyles.HexNumber );
|
||||
for( int i = 0 ; i < count ; i++ )
|
||||
Stream s;
|
||||
try
|
||||
{
|
||||
Stream s;
|
||||
try
|
||||
{
|
||||
s = mixFile.GetContent( string.Format( pattern, i + 1 ) );
|
||||
}
|
||||
catch { continue; }
|
||||
Terrain t = new Terrain( s, pal );
|
||||
if( tiles.ContainsKey( (ushort)( start + i ) ) )
|
||||
continue;
|
||||
tiles.Add( (ushort)( start + i ), t );
|
||||
s = mixFile.GetContent( string.Format( pattern, i + 1 ) );
|
||||
}
|
||||
catch { continue; }
|
||||
Terrain t = new Terrain( s, pal );
|
||||
if( tiles.ContainsKey( (ushort)( start + i ) ) )
|
||||
continue;
|
||||
tiles.Add( (ushort)( start + i ), t );
|
||||
}
|
||||
//catch { }
|
||||
}
|
||||
|
||||
tileIdFile.Close();
|
||||
}
|
||||
|
||||
public byte[] GetBytes(TileReference r) { return tiles[r.tile].TileBitmapBytes[r.image]; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user