diff --git a/OpenRA.Game/Graphics/CursorSequence.cs b/OpenRA.Game/Graphics/CursorSequence.cs index 92871e52a5..f182dac2f4 100644 --- a/OpenRA.Game/Graphics/CursorSequence.cs +++ b/OpenRA.Game/Graphics/CursorSequence.cs @@ -27,7 +27,7 @@ namespace OpenRA.Graphics public CursorSequence(string cursorSrc, string palette, XmlElement e) { - sprites = CursorSheetBuilder.LoadAllSprites(cursorSrc); + sprites = Game.modData.CursorSheetBuilder.LoadAllSprites(cursorSrc); start = int.Parse(e.GetAttribute("start")); this.palette = palette; diff --git a/OpenRA.Game/Graphics/CursorSheetBuilder.cs b/OpenRA.Game/Graphics/CursorSheetBuilder.cs index 3ac3c32a0d..6e0e783143 100644 --- a/OpenRA.Game/Graphics/CursorSheetBuilder.cs +++ b/OpenRA.Game/Graphics/CursorSheetBuilder.cs @@ -14,25 +14,32 @@ using OpenRA.FileFormats; namespace OpenRA.Graphics { - static class CursorSheetBuilder + public class CursorSheetBuilder { - static Cache cursors = new Cache(LoadCursors); - static readonly string[] exts = { ".shp" }; + ModData modData; + Cache cursors; + readonly string[] exts = { ".shp" }; - static Sprite[] LoadCursors(string filename) + public CursorSheetBuilder( ModData modData ) + { + this.modData = modData; + this.cursors = new Cache( LoadCursors ); + } + + Sprite[] LoadCursors(string filename) { try { var shp = new Dune2ShpReader(FileSystem.OpenWithExts(filename, exts)); - return shp.Select(a => SheetBuilder.SharedInstance.Add(a.Image, a.Size)).ToArray(); + return shp.Select(a => modData.SheetBuilder.Add(a.Image, a.Size)).ToArray(); } catch (IndexOutOfRangeException) // This will occur when loading a custom (RA-format) .shp { var shp = new ShpReader(FileSystem.OpenWithExts(filename, exts)); - return shp.Select(a => SheetBuilder.SharedInstance.Add(a.Image, shp.Size)).ToArray(); + return shp.Select(a => modData.SheetBuilder.Add(a.Image, shp.Size)).ToArray(); } } - public static Sprite[] LoadAllSprites(string filename) { return cursors[filename]; } + public Sprite[] LoadAllSprites(string filename) { return cursors[filename]; } } } diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index 42570b13a9..55cde4a0a5 100755 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using OpenRA.FileFormats; +using OpenRA.Graphics; namespace OpenRA { @@ -10,12 +11,15 @@ namespace OpenRA { public readonly Manifest Manifest; public readonly ObjectCreator ObjectCreator; + public readonly CursorSheetBuilder CursorSheetBuilder; + public SheetBuilder SheetBuilder { get { return SheetBuilder.SharedInstance; } } public ModData( Manifest manifest ) { Manifest = manifest; ObjectCreator = new ObjectCreator( manifest ); FileSystem.LoadFromManifest( manifest ); + CursorSheetBuilder = new CursorSheetBuilder( this ); } } }