From 279869b4c52342b420cd2e9cf136af12e9ebb163 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 8 Mar 2023 23:08:03 +0000 Subject: [PATCH] Fix --dump-sequence-sheets utility command. Also formats output filenames to specify indexed sprite channels. --- .../DumpSequenceSheetsCommand.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs b/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs index 5283ca869f..b714fece02 100644 --- a/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs @@ -35,11 +35,14 @@ namespace OpenRA.Mods.Common.UtilityCommands var palette = new ImmutablePalette(args[1], new[] { 0 }, Array.Empty()); SequenceProvider sequences; - var mapPackage = new Folder(Platform.EngineDir).OpenPackage(args[2], modData.ModFiles); - if (mapPackage != null) + if (!modData.DefaultSequences.TryGetValue(args[2], out sequences)) + { + var mapPackage = new Folder(Platform.EngineDir).OpenPackage(args[2], modData.ModFiles); + if (mapPackage == null) + throw new InvalidOperationException($"{args[2]} is not a valid tileset or map path"); + sequences = new Map(modData, mapPackage).Sequences; - else if (!modData.DefaultSequences.TryGetValue(args[2], out sequences)) - throw new InvalidOperationException($"{args[2]} is not a valid tileset or map path"); + } sequences.Preload(); @@ -50,14 +53,14 @@ namespace OpenRA.Mods.Common.UtilityCommands { var max = s == sb.Current ? (int)sb.CurrentChannel + 1 : 4; for (var i = 0; i < max; i++) - s.AsPng((TextureChannel)ChannelMasks[i], palette).Save($"{count++}.png"); + s.AsPng((TextureChannel)ChannelMasks[i], palette).Save($"{count}.{i}.png"); + + count++; } sb = sequences.SpriteCache.SheetBuilders[SheetType.BGRA]; foreach (var s in sb.AllSheets) s.AsPng().Save($"{count++}.png"); - - Console.WriteLine("Saved [0..{0}].png", count - 1); } } }