using System; using System.Collections.Generic; using System.Text; using OpenRa.FileFormats; using System.Drawing; using BluntDirectX.Direct3D; namespace OpenRa.Game { static class UnitSheetBuilder { static readonly Package unitsPackage = new Package( "../../../conquer.mix" ); static readonly Package otherUnitsPackage = new Package("../../../hires.mix"); public static readonly List sprites = new List(); static Dictionary> sequences = new Dictionary>(); static ShpReader Load(string filename) { foreach( Package p in new Package[] { unitsPackage, otherUnitsPackage } ) try { return new ShpReader(p.GetContent(filename)); } catch { } throw new NotImplementedException(); } public static Range GetUnit(string name) { Range result; if (sequences.TryGetValue(name, out result)) return result; return AddUnit(name); } static Range AddUnit( string name ) { int low = sprites.Count; ShpReader reader = Load(name + ".shp"); foreach (ImageHeader h in reader) sprites.Add(SheetBuilder.Add(h.Image, reader.Size)); Range sequence = new Range(low, sprites.Count - 1); sequences.Add(name, sequence); return sequence; } } }