add tmp->png conversion to utility

This commit is contained in:
Chris Forbes
2011-10-10 18:26:25 +13:00
parent a34b2d8c53
commit 2c415a8fd6
3 changed files with 31 additions and 1 deletions

View File

@@ -171,7 +171,6 @@ namespace OpenRA.Editor
BorderStyle = BorderStyle.FixedSingle
};
ibox.Click += (_, e) => surface1.SetTool(new ActorTool(template));
actorPalette.Controls.Add(ibox);

View File

@@ -105,6 +105,35 @@ namespace OpenRA.Utility
}
}
public static void ConvertTmpToPng(string[] args)
{
var mods = args[1].Split(',');
var theater = args[2];
var templateNames = args.Skip(3);
var manifest = new Manifest(mods);
FileSystem.LoadFromManifest(manifest);
var tileset = manifest.TileSets.Select( a => new TileSet(a) )
.FirstOrDefault( ts => ts.Name == theater );
if (tileset == null)
throw new InvalidOperationException("No theater named '{0}'".F(theater));
tileset.LoadTiles();
var palette = new Palette(FileSystem.Open(tileset.Palette), true);
foreach( var templateName in templateNames )
{
var template = tileset.Templates.FirstOrDefault(tt => tt.Value.Image == templateName);
if (template.Value == null)
throw new InvalidOperationException("No such template '{0}'".F(templateName));
using( var image = tileset.RenderTemplate(template.Value.Id, palette) )
image.Save( Path.ChangeExtension( templateName, ".png" ) );
}
}
public static void ConvertFormat2ToFormat80(string[] args)
{
var src = args[1];

View File

@@ -25,6 +25,7 @@ namespace OpenRA.Utility
{ "--png", Command.ConvertShpToPng },
{ "--fromd2", Command.ConvertFormat2ToFormat80 },
{ "--extract", Command.ExtractFiles },
{ "--tmp-png", Command.ConvertTmpToPng },
};
if (args.Length == 0) { PrintUsage(); return; }
@@ -55,6 +56,7 @@ namespace OpenRA.Utility
Console.WriteLine(" --shp PNGFILE FRAMEWIDTH Convert a PNG containing one or more frames to a SHP");
Console.WriteLine(" --png SHPFILE PALETTE [--transparent] Convert a SHP to a PNG containing all of its frames, optionally setting up transparency");
Console.WriteLine(" --extract MOD[,MOD]* FILES Extract files from mod packages");
Console.WriteLine(" --tmp-png MOD[,MOD]* THEATER FILES Extract terrain tiles to PNG");
}
static string GetNamedArg(string[] args, string arg)