From 06b0ce621f4d4235398bdddbc39233aa374a7a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 5 Dec 2013 17:08:56 +0100 Subject: [PATCH 1/4] =?UTF-8?q?mixed=20line=20endings=20=E2=86=92=20Unix?= =?UTF-8?q?=20line=20endings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenRA.Utility/Command.cs | 14 +++++++------- OpenRA.Utility/Program.cs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index cc9bcea144..dc2c81eaac 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,12 @@ 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); } } } diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index 89c4f453de..d3a9b77f3f 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 @@ -60,7 +60,7 @@ 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."); } From 5a4fc712a9b6cb1ac8a6704796ed215968a27159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 5 Dec 2013 17:41:03 +0100 Subject: [PATCH 2/4] added --minimap to OpenRA Utility closes #4195 --- OpenRA.Game/Graphics/Minimap.cs | 4 ++-- OpenRA.Utility/Command.cs | 19 +++++++++++++++++++ OpenRA.Utility/Program.cs | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Graphics/Minimap.cs b/OpenRA.Game/Graphics/Minimap.cs index 9c8e89c625..42b5ca9413 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(); @@ -187,7 +187,7 @@ namespace OpenRA.Graphics public static Bitmap RenderMapPreview(Map map) { - Bitmap terrain = TerrainBitmap(map); + Bitmap terrain = TerrainBitmap(map, true); return AddStaticResources(map, terrain); } } diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index dc2c81eaac..5e2736e505 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -293,5 +293,24 @@ namespace OpenRA.Utility var result = new Map(args[1]).Uid; Console.WriteLine(result); } + + public static void GenerateMinimap(string[] args) + { + var map = new Map(args[1]); + + Game.modData = new ModData(map.RequiresMod); + + FileSystem.UnmountAll(); + foreach (var dir in Game.modData.Manifest.Folders) + FileSystem.Mount(dir); + + Rules.LoadRules(Game.modData.Manifest, map); + + var minimap = Minimap.RenderMapPreview(map); + + 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 d3a9b77f3f..e9dce0c937 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -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; } @@ -62,6 +63,7 @@ namespace OpenRA.Utility 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(" --map-hash MAPFILE Generate hash of specified oramap file."); + Console.WriteLine(" --minimap MAPFILE Render PNG minimap of specified oramap file."); } static string GetNamedArg(string[] args, string arg) From 52ecac7336698ccbf7657f515d33dcd2ffc28a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 5 Dec 2013 19:27:40 +0100 Subject: [PATCH 3/4] allow mod override e.g. useful for legacy maps where RequiresMod: is not set --- OpenRA.Utility/Command.cs | 4 ++-- OpenRA.Utility/Program.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenRA.Utility/Command.cs b/OpenRA.Utility/Command.cs index 5e2736e505..a68111e987 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -297,8 +297,8 @@ namespace OpenRA.Utility public static void GenerateMinimap(string[] args) { var map = new Map(args[1]); - - Game.modData = new ModData(map.RequiresMod); + var mod = args.Length > 1 ? args[2] : map.RequiresMod; + Game.modData = new ModData(mod); FileSystem.UnmountAll(); foreach (var dir in Game.modData.Manifest.Folders) diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index e9dce0c937..6cac4f4067 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -63,7 +63,7 @@ namespace OpenRA.Utility 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(" --map-hash MAPFILE Generate hash of specified oramap file."); - Console.WriteLine(" --minimap MAPFILE Render PNG minimap of specified oramap file."); + Console.WriteLine(" --minimap MAPFILE [MOD] Render PNG minimap of specified oramap file."); } static string GetNamedArg(string[] args, string arg) From 8d9282811bd5ae693f7923c01130dfa873760061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 5 Dec 2013 19:31:24 +0100 Subject: [PATCH 4/4] fixed System.IO.InvalidDataException`: Non-power-of-two array --- OpenRA.Game/Graphics/Minimap.cs | 4 ++-- OpenRA.Game/Widgets/MapPreviewWidget.cs | 2 +- OpenRA.Utility/Command.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Graphics/Minimap.cs b/OpenRA.Game/Graphics/Minimap.cs index 42b5ca9413..0594b1854d 100644 --- a/OpenRA.Game/Graphics/Minimap.cs +++ b/OpenRA.Game/Graphics/Minimap.cs @@ -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, true); + 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 a68111e987..50f91826fd 100644 --- a/OpenRA.Utility/Command.cs +++ b/OpenRA.Utility/Command.cs @@ -306,7 +306,7 @@ namespace OpenRA.Utility Rules.LoadRules(Game.modData.Manifest, map); - var minimap = Minimap.RenderMapPreview(map); + var minimap = Minimap.RenderMapPreview(map, true); var dest = Path.GetFileNameWithoutExtension(args[1]) + ".png"; minimap.Save(dest);