Support custom tile size ingame

This commit is contained in:
Paul Chote
2010-09-15 18:56:48 +12:00
parent ac8a3526a4
commit 051c451867
13 changed files with 149 additions and 130 deletions

View File

@@ -23,13 +23,15 @@ namespace OpenRA.FileFormats
Weapons, Voices, Music, Movies, TileSets;
public readonly string ShellmapUid, LoadScreen;
public readonly int TileSize = 24;
public Manifest(string[] mods)
{
var yaml = mods
.Select(m => MiniYaml.FromFile("mods/" + m + "/mod.yaml"))
.Aggregate(MiniYaml.Merge);
// Todo: Use fieldloader
Folders = YamlList(yaml, "Folders");
Packages = YamlList(yaml, "Packages");
Rules = YamlList(yaml, "Rules");
@@ -46,6 +48,9 @@ namespace OpenRA.FileFormats
ShellmapUid = yaml.First( x => x.Key == "ShellmapUid" ).Value.Value;
LoadScreen = yaml.First( x => x.Key == "LoadScreen" ).Value.Value;
if (yaml.FirstOrDefault( x => x.Key == "TileSize" ) != null)
TileSize = int.Parse(yaml.First( x => x.Key == "TileSize" ).Value.Value);
}
static string[] YamlList(List<MiniYamlNode> ys, string key)

View File

@@ -19,16 +19,13 @@ namespace OpenRA.FileFormats
public Terrain( Stream stream, int size )
{
System.Console.WriteLine("Loading tile with expected size {0}",size);
// Try loading as a cnc .tem
BinaryReader reader = new BinaryReader( stream );
int Width = reader.ReadUInt16();
int Height = reader.ReadUInt16();
System.Console.WriteLine("Actual size {0}x{1}",Width,Height);
if( Width != size || Height != size )
throw new InvalidDataException( "Expected tile of size {0}x{0}, got {1}x{2]".F(size, Width, Height ) );
throw new InvalidDataException( "{0}x{1} != {2}x{2}".F(Width, Height, size ) );
/*NumTiles = */reader.ReadUInt16();
/*Zero1 = */reader.ReadUInt16();

View File

@@ -74,7 +74,7 @@ namespace OpenRA.FileFormats
public string Name;
public string Id;
public string Palette;
public int TileSize;
public int TileSize = 24;
public string[] Extensions;
public Dictionary<string, TerrainTypeInfo> Terrain = new Dictionary<string, TerrainTypeInfo>();
public Dictionary<ushort, Terrain> Tiles = new Dictionary<ushort, Terrain>();