Skip to content

Commit

Permalink
Merge pull request #1611 from Miepee/seperate-folder-sprites
Browse files Browse the repository at this point in the history
Export sprites into subfolders for each sprite
  • Loading branch information
Miepee authored May 7, 2024
2 parents 8ee9052 + f693010 commit a24c316
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions UndertaleModTool/Scripts/Resource Unpackers/ExportAllSprites.csx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ EnsureDataLoaded();

bool padded = (!ScriptQuestion("Export all sprites unpadded?"));

bool useSubDirectories = ScriptQuestion("Export sprites into subdirectories?");

string texFolder = GetFolder(FilePath) + "Export_Sprites" + Path.DirectorySeparatorChar;
TextureWorker worker = new TextureWorker();
if (Directory.Exists(texFolder))
Expand Down Expand Up @@ -43,9 +45,17 @@ async Task DumpSprites()

void DumpSprite(UndertaleSprite sprite)
{
string outputFolder = texFolder;
if (useSubDirectories)
outputFolder = Path.Combine(outputFolder, sprite.Name.Content);
if (sprite.Textures.Count > 0)
Directory.CreateDirectory(outputFolder);

for (int i = 0; i < sprite.Textures.Count; i++)
{
if (sprite.Textures[i]?.Texture != null)
worker.ExportAsPNG(sprite.Textures[i].Texture, texFolder + sprite.Name.Content + "_" + i + ".png", null, padded); // Include padding to make sprites look neat!
worker.ExportAsPNG(sprite.Textures[i].Texture, Path.Combine(outputFolder, sprite.Name.Content + "_" + i + ".png"), null, padded); // Include padding to make sprites look neat!
}

IncrementProgressParallel();
}
}

0 comments on commit a24c316

Please sign in to comment.