Support for Dune II SHP files used for cursors in Red Alert.
This commit is contained in:
34
OpenRa.Game/Graphics/CursorSheetBuilder.cs
Normal file
34
OpenRa.Game/Graphics/CursorSheetBuilder.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user