Merge all 4 tileset files together
This commit is contained in:
@@ -82,50 +82,6 @@ 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)
|
||||
|
||||
@@ -660,6 +660,65 @@ namespace OpenRA
|
||||
file.Write(id);
|
||||
file.Flush();
|
||||
file.Close();
|
||||
}
|
||||
|
||||
public static void ConvertTileset(OpenRA.FileFormats.TileSet Tileset, OpenRA.Traits.TheaterInfo Info, string outFile)
|
||||
{
|
||||
List<string> SimpleFields = new List<string>() {
|
||||
"Name", "Size", "PickAny", "Bridge", "HP"
|
||||
};
|
||||
OpenRA.FileFormats.TerrainColorSet colors = new TerrainColorSet(Info.MapColors);
|
||||
|
||||
Dictionary<string, MiniYaml> root = new Dictionary<string, MiniYaml>();
|
||||
Dictionary<string, MiniYaml> terrainYaml = new Dictionary<string, MiniYaml>();
|
||||
|
||||
for (TerrainType t = TerrainType.Clear; t <= TerrainType.Special; t++)
|
||||
{
|
||||
Dictionary<string, MiniYaml> nodeYaml = new Dictionary<string, MiniYaml>();
|
||||
string type = Enum.GetName( typeof(TerrainType), t);
|
||||
nodeYaml.Add("Type", new MiniYaml(type, null));
|
||||
nodeYaml.Add("Buildable", new MiniYaml(Rules.TerrainTypes[t].Buildable.ToString(), null));
|
||||
nodeYaml.Add("AcceptSmudge", new MiniYaml(Rules.TerrainTypes[t].AcceptSmudge.ToString(), null));
|
||||
|
||||
var color = colors.ColorForTerrainType(t);
|
||||
nodeYaml.Add("Color", new MiniYaml("{0}, {1}, {2}".F(color.R, color.G, color.B), null));
|
||||
terrainYaml.Add("TerrainType@{0}".F(type), new MiniYaml(null, nodeYaml));
|
||||
}
|
||||
|
||||
root.Add("Terrain", new MiniYaml(null, terrainYaml));
|
||||
|
||||
Dictionary<string, MiniYaml> templateYaml = new Dictionary<string, MiniYaml>();
|
||||
foreach(var w in Tileset.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));
|
||||
templateYaml.Add("Template@{0}".F(w.Key), new MiniYaml(null, nodeYaml));
|
||||
}
|
||||
root.Add("Templates", new MiniYaml(null, templateYaml));
|
||||
root.WriteToFile(outFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace OpenRA
|
||||
.FirstOrDefault(t => t.Theater == Map.Theater);
|
||||
TileSet = new TileSet(theaterInfo.Tileset, theaterInfo.Templates, theaterInfo.Suffix);
|
||||
|
||||
Game.ConvertTileset(TileSet, theaterInfo, "tileset-"+theaterInfo.Suffix+".yaml");
|
||||
SpriteSheetBuilder.Initialize( Map );
|
||||
Timer.Time( "Tileset: {0}" );
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user