diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 8014cd9f58..628116ac3f 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -171,7 +171,6 @@ namespace OpenRA.Editor BorderStyle = BorderStyle.FixedSingle }; - ibox.Click += (_, e) => surface1.SetTool(new ActorTool(template)); actorPalette.Controls.Add(ibox); diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index 667feb7310..be3c26e3be 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -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]; diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index 328937c796..d245b4b886 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -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)