Merge pull request #4234 from Mailaender/minimap-utility
Added a minimap renderer to OpenRA.Utility.exe
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user