less fail
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Ijw.DirectX;
|
using Ijw.DirectX;
|
||||||
using OpenRa.FileFormats;
|
using OpenRa.FileFormats;
|
||||||
|
using IjwFramework.Collections;
|
||||||
|
|
||||||
namespace OpenRa.Game.Graphics
|
namespace OpenRa.Game.Graphics
|
||||||
{
|
{
|
||||||
@@ -9,36 +10,21 @@ namespace OpenRa.Game.Graphics
|
|||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
sprites = new List<Sprite>();
|
sprites = new List<Sprite>();
|
||||||
sequences = new Dictionary<string, Range<int>>();
|
sequences = new Cache<string, Range<int>>(AddUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Sprite> sprites;
|
public static List<Sprite> sprites;
|
||||||
static Dictionary<string, Range<int>> sequences;
|
static Cache<string, Range<int>> sequences;
|
||||||
|
|
||||||
public static Range<int> GetUnit(string name)
|
|
||||||
{
|
|
||||||
Range<int> result;
|
|
||||||
if (sequences.TryGetValue(name, out result))
|
|
||||||
return result;
|
|
||||||
|
|
||||||
return AddUnit(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static Range<int> GetUnit(string name) { return sequences[name]; }
|
||||||
|
|
||||||
static Range<int> AddUnit( string name )
|
static Range<int> AddUnit( string name )
|
||||||
{
|
{
|
||||||
Log.Write("Loading SHP for {0}", name);
|
var low = sprites.Count;
|
||||||
|
var reader = new ShpReader( FileSystem.OpenWithExts( name, ".tem", ".sno", ".int", ".shp" ) );
|
||||||
int low = sprites.Count;
|
foreach (var h in reader)
|
||||||
|
|
||||||
ShpReader reader = new ShpReader( FileSystem.OpenWithExts( name, ".tem", ".sno", ".int", ".shp" ) );
|
|
||||||
foreach (ImageHeader h in reader)
|
|
||||||
sprites.Add(SheetBuilder.Add(h.Image, reader.Size));
|
sprites.Add(SheetBuilder.Add(h.Image, reader.Size));
|
||||||
|
var sequence = new Range<int>(low, sprites.Count - 1);
|
||||||
Range<int> sequence = new Range<int>(low, sprites.Count - 1);
|
|
||||||
sequences.Add(name, sequence);
|
|
||||||
|
|
||||||
Log.Write("Loaded SHP for {0}", name);
|
|
||||||
|
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user