Support for Dune II SHP files used for cursors in Red Alert.

This commit is contained in:
Matthew Bowra-Dean
2009-10-12 09:45:15 +13:00
parent 99b508956e
commit 99ad09ddc2
7 changed files with 475 additions and 221 deletions

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.FileFormats;
namespace OpenRa.Game.Graphics
{
static class CursorSheetBuilder
{
static Dictionary<string, Sprite[]> cursors =
new Dictionary<string, Sprite[]>();
public static Sprite LoadSprite(string filename, params string[] exts)
{
return LoadAllSprites(filename, exts)[0];
}
public static Sprite[] LoadAllSprites(string filename, params string[] exts)
{
Sprite[] value;
if (!cursors.TryGetValue(filename, out value))
{
Dune2ShpReader shp = new Dune2ShpReader(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[i].Size);
cursors.Add(filename, value);
}
return value;
}
}
}