diff --git a/OpenRA.Game/Graphics/Minimap.cs b/OpenRA.Game/Graphics/Minimap.cs index 9c8e89c625..0594b1854d 100644 --- a/OpenRA.Game/Graphics/Minimap.cs +++ b/OpenRA.Game/Graphics/Minimap.cs @@ -113,7 +113,7 @@ namespace OpenRA.Graphics { var mapX = x + map.Bounds.Left; var mapY = y + map.Bounds.Top; - var custom = map.CustomTerrain[mapX,mapY]; + var custom = map.CustomTerrain[mapX, mapY]; if (custom == null) continue; *(c + (y * bitmapData.Stride >> 2) + x) = world.TileSet.Terrain[custom].Color.ToArgb(); @@ -185,9 +185,9 @@ namespace OpenRA.Graphics return bitmap; } - public static Bitmap RenderMapPreview(Map map) + public static Bitmap RenderMapPreview(Map map, bool actualSize) { - Bitmap terrain = TerrainBitmap(map); + Bitmap terrain = TerrainBitmap(map, actualSize); return AddStaticResources(map, terrain); } } diff --git a/OpenRA.Game/Widgets/MapPreviewWidget.cs b/OpenRA.Game/Widgets/MapPreviewWidget.cs index d386f359fc..5ef3181b6a 100644 --- a/OpenRA.Game/Widgets/MapPreviewWidget.cs +++ b/OpenRA.Game/Widgets/MapPreviewWidget.cs @@ -170,7 +170,7 @@ namespace OpenRA.Widgets uid = cacheUids.Peek(); } - var bitmap = Minimap.RenderMapPreview(Game.modData.AvailableMaps[uid]); + var bitmap = Minimap.RenderMapPreview(Game.modData.AvailableMaps[uid], false); lock (syncRoot) { // TODO: We should add previews to a sheet here (with multiple previews per sheet) diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index cc9bcea144..50f91826fd 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007-2012 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made @@ -286,12 +286,31 @@ namespace OpenRA.Utility Console.WriteLine(); Console.WriteLine("```"); - } - - public static void GetMapHash(string[] args) - { - var result = new Map(args[1]).Uid; - Console.WriteLine(result); + } + + public static void GetMapHash(string[] args) + { + var result = new Map(args[1]).Uid; + Console.WriteLine(result); + } + + public static void GenerateMinimap(string[] args) + { + var map = new Map(args[1]); + var mod = args.Length > 1 ? args[2] : map.RequiresMod; + Game.modData = new ModData(mod); + + FileSystem.UnmountAll(); + foreach (var dir in Game.modData.Manifest.Folders) + FileSystem.Mount(dir); + + Rules.LoadRules(Game.modData.Manifest, map); + + var minimap = Minimap.RenderMapPreview(map, true); + + var dest = Path.GetFileNameWithoutExtension(args[1]) + ".png"; + minimap.Save(dest); + Console.WriteLine(dest + " saved."); } } } diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index 89c4f453de..6cac4f4067 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007-2012 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made @@ -28,6 +28,7 @@ namespace OpenRA.Utility { "--transpose", Command.TransposeShp }, { "--docs", Command.ExtractTraitDocs }, { "--map-hash", Command.GetMapHash }, + { "--minimap", Command.GenerateMinimap }, }; if (args.Length == 0) { PrintUsage(); return; } @@ -60,8 +61,9 @@ namespace OpenRA.Utility Console.WriteLine(" --extract MOD[,MOD]* FILES Extract files from mod packages to the current directory"); Console.WriteLine(" --remap SRCMOD:PAL DESTMOD:PAL SRCSHP DESTSHP Remap SHPs to another palette"); Console.WriteLine(" --transpose SRCSHP DESTSHP START N M [START N M ...] Transpose the N*M block of frames starting at START."); - Console.WriteLine(" --docs MOD Generate trait documentation in MarkDown format."); + Console.WriteLine(" --docs MOD Generate trait documentation in MarkDown format."); Console.WriteLine(" --map-hash MAPFILE Generate hash of specified oramap file."); + Console.WriteLine(" --minimap MAPFILE [MOD] Render PNG minimap of specified oramap file."); } static string GetNamedArg(string[] args, string arg)