diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index d65d5fe27c..29bb07b52f 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -103,6 +103,7 @@ namespace OpenRA.Editor { Rules.LoadRules(manifest, map); tileset = Rules.TileSets[map.Theater]; + tileset.LoadTiles(); var palette = new Palette(FileSystem.Open(map.Theater.ToLowerInvariant() + ".pal"), true); surface1.Bind(map, tileset, palette); @@ -178,7 +179,7 @@ namespace OpenRA.Editor { try { - var template = RenderResourceType(a, tileset.TileSuffix, palette); + var template = RenderResourceType(a, tileset.Extensions, palette); var ibox = new PictureBox { Image = template.Bitmap, @@ -251,7 +252,7 @@ namespace OpenRA.Editor image = ri.OverrideImage[i]; image = image ?? ri.Image ?? info.Name; - using (var s = FileSystem.OpenWithExts(image, "." + tileset.TileSuffix, ".shp")) + using (var s = FileSystem.OpenWithExts(image, tileset.Extensions)) { var shp = new ShpReader(s); var frame = shp[0]; @@ -275,10 +276,10 @@ namespace OpenRA.Editor } } - static ResourceTemplate RenderResourceType(ResourceTypeInfo info, string ext, Palette p) + static ResourceTemplate RenderResourceType(ResourceTypeInfo info, string[] exts, Palette p) { var image = info.SpriteNames[0]; - using (var s = FileSystem.OpenWithExts(image, "." + ext, ".shp")) + using (var s = FileSystem.OpenWithExts(image, exts)) { var shp = new ShpReader(s); var frame = shp[shp.ImageCount - 1]; diff --git a/OpenRA.FileFormats/Map/TileSet.cs b/OpenRA.FileFormats/Map/TileSet.cs index 64aa24397d..c2a45c93bc 100644 --- a/OpenRA.FileFormats/Map/TileSet.cs +++ b/OpenRA.FileFormats/Map/TileSet.cs @@ -61,7 +61,7 @@ namespace OpenRA.FileFormats { public readonly string Name; public readonly string Id; - public readonly string TileSuffix; + public readonly string[] Extensions; public readonly Dictionary Terrain = new Dictionary(); public readonly Dictionary Tiles = new Dictionary(); public readonly Dictionary Templates = new Dictionary(); @@ -83,31 +83,19 @@ namespace OpenRA.FileFormats // Templates foreach (var tt in yaml["Templates"].Nodes) { - // Info var t = new TileTemplate(tt.Value.Nodes); Templates.Add(t.Id, t); - - // Artwork - using( Stream s = FileSystem.Open( t.Image + "." + TileSuffix ) ) - { - if( !Tiles.ContainsKey( t.Id ) ) - Tiles.Add( t.Id, new Terrain( s ) ); - } } } public void LoadTiles() { - // Templates foreach (var t in Templates) - { - // Artwork - using( Stream s = FileSystem.Open( t.Value.Image + "." + TileSuffix ) ) + using( Stream s = FileSystem.OpenWithExts(t.Value.Image, Extensions) ) { if( !Tiles.ContainsKey( t.Key ) ) Tiles.Add( t.Key, new Terrain( s ) ); } - } } public byte[] GetBytes(TileReference r) diff --git a/OpenRA.Game/Graphics/SpriteSheetBuilder.cs b/OpenRA.Game/Graphics/SpriteSheetBuilder.cs index 8746e01348..4ec76480da 100644 --- a/OpenRA.Game/Graphics/SpriteSheetBuilder.cs +++ b/OpenRA.Game/Graphics/SpriteSheetBuilder.cs @@ -29,7 +29,7 @@ namespace OpenRA.Graphics public static void Initialize( TileSet tileset ) { /* .tem: hack to allow incomplete theaters (interior) to work, falling back to temperate for the missing art */ - exts = new[] { "." + tileset.TileSuffix, ".shp", ".tem" }; + exts = tileset.Extensions; sprites = new Cache( LoadSprites ); } diff --git a/mods/cnc/tileset-des.yaml b/mods/cnc/tileset-des.yaml index a44f0ef8de..6f9aab9877 100644 --- a/mods/cnc/tileset-des.yaml +++ b/mods/cnc/tileset-des.yaml @@ -1,7 +1,7 @@ General: Name: Desert Id: DESERT - TileSuffix: des + Extensions: .des, .shp, .tem Terrain: TerrainType@Clear: diff --git a/mods/cnc/tileset-tem.yaml b/mods/cnc/tileset-tem.yaml index 910a8d87be..9c1a9fade4 100644 --- a/mods/cnc/tileset-tem.yaml +++ b/mods/cnc/tileset-tem.yaml @@ -1,7 +1,7 @@ General: Name: Temperate Id: TEMPERAT - TileSuffix: tem + Extensions: .tem, .shp Terrain: TerrainType@Clear: diff --git a/mods/cnc/tileset-win.yaml b/mods/cnc/tileset-win.yaml index 7ed8c06c6f..3381801e1c 100644 --- a/mods/cnc/tileset-win.yaml +++ b/mods/cnc/tileset-win.yaml @@ -1,7 +1,7 @@ General: Name: Winter Id: WINTER - TileSuffix: win + Extensions: .win, .shp, .tem Terrain: TerrainType@Clear: diff --git a/mods/ra/tileset-int.yaml b/mods/ra/tileset-int.yaml index a7171a7a30..9f21ebc791 100644 --- a/mods/ra/tileset-int.yaml +++ b/mods/ra/tileset-int.yaml @@ -1,7 +1,7 @@ General: Name: Interior Id: INTERIOR - TileSuffix: int + Extensions: .int, .shp, .tem Terrain: TerrainType@Clear: diff --git a/mods/ra/tileset-sno.yaml b/mods/ra/tileset-sno.yaml index 121ebba659..f62ed77b38 100644 --- a/mods/ra/tileset-sno.yaml +++ b/mods/ra/tileset-sno.yaml @@ -1,7 +1,7 @@ General: Name: Snow Id: SNOW - TileSuffix: sno + Extensions: .sno, .shp, .tem Terrain: TerrainType@Clear: diff --git a/mods/ra/tileset-tem.yaml b/mods/ra/tileset-tem.yaml index c83acf7d6d..1e5d8e35d8 100644 --- a/mods/ra/tileset-tem.yaml +++ b/mods/ra/tileset-tem.yaml @@ -1,7 +1,7 @@ General: Name: Temperate Id: TEMPERAT - TileSuffix: tem + Extensions: .tem, .shp Terrain: TerrainType@Clear: