QoL for the MapRenderer tool (#11921)

This commit is contained in:
Mervill
2022-10-14 15:10:53 -07:00
committed by GitHub
parent ebff854c55
commit 920fde469d

View File

@@ -27,6 +27,8 @@ namespace Content.MapRenderer
{
if (args.Length == 0)
{
Console.WriteLine("Didn't specify any maps to paint! Loading the map list...");
await using var server = await PoolManager.GetServerClient();
var mapIds = server.Pair.Server
.ResolveDependency<IPrototypeManager>()
@@ -36,8 +38,10 @@ namespace Content.MapRenderer
Array.Sort(mapIds);
Console.WriteLine("Didn't specify any maps to paint, select one, multiple separated by commas or \"all\":");
Console.WriteLine(string.Join('\n', mapIds.Select((id, i) => $"({i}): {id}")));
Console.WriteLine("Map List");
Console.WriteLine(string.Join('\n', mapIds.Select((id, i) => $"{i,3}: {id}")));
Console.WriteLine("Select one, multiple separated by commas or \"all\":");
Console.Write("> ");
var input = Console.ReadLine();
if (input == null)
{
@@ -119,9 +123,10 @@ namespace Content.MapRenderer
mapViewerData.ParallaxLayers.Add(LayerGroup.DefaultParallax());
var directory = Path.Combine(arguments.OutputPath, map);
Directory.CreateDirectory(directory);
var i = 0;
try
{
await foreach (var renderedGrid in MapPainter.Paint(map))
{
var grid = renderedGrid.Image;
@@ -158,6 +163,13 @@ namespace Content.MapRenderer
mapNames.Add(fileName);
i++;
}
}
catch (Exception ex)
{
Console.WriteLine($"Painting map {map} failed due to an internal exception:");
Console.WriteLine(ex);
continue;
}
if (arguments.ExportViewerJson)
{
@@ -168,7 +180,8 @@ namespace Content.MapRenderer
var mapNamesString = $"[{string.Join(',', mapNames.Select(s => $"\"{s}\""))}]";
Console.WriteLine($@"::set-output name=map_names::{mapNamesString}");
Console.WriteLine($"Created {arguments.Maps.Count} map images.");
Console.WriteLine($"Processed {arguments.Maps.Count} maps.");
Console.WriteLine($"It's now safe to manually exit the process (automatic exit in a few moments...)");
}
}
}