Merge templates.ini and tileset.til into theatre-specific yaml files.

Game doesn't use them yet.
This commit is contained in:
Paul Chote
2010-06-26 00:19:34 +12:00
parent cf265c8b58
commit 9cf6d8970a
7 changed files with 11714 additions and 1 deletions

View File

@@ -49,7 +49,6 @@ namespace OpenRA.FileFormats
public TileSet( string tilesetFile, string templatesFile, string suffix )
{
Walkability = new Walkability(templatesFile);
char tileSetChar = char.ToUpperInvariant( suffix[ 0 ] );
StreamReader tileIdFile = new StreamReader( FileSystem.Open(tilesetFile) );
@@ -83,8 +82,52 @@ namespace OpenRA.FileFormats
}
tileIdFile.Close();
Convert("tileset-"+suffix+".yaml");
}
static List<string> SimpleFields = new List<string>() {
"Name", "Size", "PickAny", "Bridge", "HP"
};
public void Convert(string outFile)
{
Dictionary<string, MiniYaml> root = new Dictionary<string, MiniYaml>();
foreach(var w in walk)
{
Dictionary<string, MiniYaml> nodeYaml = new Dictionary<string, MiniYaml>();
nodeYaml.Add("Id", new MiniYaml(w.Key.ToString(), null));
foreach (var field in SimpleFields)
{
var save = field;
System.Reflection.FieldInfo f = w.Value.GetType().GetField(field);
if (f.GetValue(w.Value) == null) continue;
if (field == "Name")
save = "Image";
if (field == "HP" && w.Value.HP == 0)
continue;
if (field == "HP")
save = "Strength";
if (field == "PickAny" && !w.Value.PickAny)
continue;
nodeYaml.Add(save, new MiniYaml(FieldSaver.FormatValue(w.Value, f), null));
}
nodeYaml.Add("Tiles", MiniYaml.FromDictionary<int, TerrainType>(w.Value.TerrainType));
root.Add("TileTemplate@{0}".F(w.Key), new MiniYaml(null, nodeYaml));
}
root.WriteToFile(outFile);
}
public byte[] GetBytes(TileReference<ushort,byte> r)
{
Terrain tile;