Overlay rendering

- also, sequences for HBOX and PBOX
This commit is contained in:
Bob
2009-10-10 21:23:33 +13:00
parent 4fa05a6d40
commit b880f7d1bc
10 changed files with 152 additions and 76 deletions

View File

@@ -5,16 +5,24 @@ namespace OpenRa.Game.Graphics
{
static class SpriteSheetBuilder
{
static Dictionary<string, Sprite> sprites =
new Dictionary<string, Sprite>();
static Dictionary<string, Sprite[]> sprites =
new Dictionary<string, Sprite[]>();
public static Sprite LoadSprite(string filename)
public static Sprite LoadSprite(string filename, params string[] exts )
{
Sprite value;
if (!sprites.TryGetValue(filename, out value))
return LoadAllSprites( filename, exts )[ 0 ];
}
public static Sprite[] LoadAllSprites( string filename, params string[] exts )
{
Sprite[] value;
if( !sprites.TryGetValue( filename, out value ) )
{
ShpReader shp = new ShpReader(FileSystem.Open(filename));
sprites.Add(filename, value = SheetBuilder.Add(shp[0].Image, shp.Size));
ShpReader shp = new ShpReader( FileSystem.OpenWithExts( filename, exts ) );
value = new Sprite[ shp.ImageCount ];
for( int i = 0 ; i < shp.ImageCount ; i++ )
value[ i ] = SheetBuilder.Add( shp[ i ].Image, shp.Size );
sprites.Add( filename, value );
}
return value;