Skip to content

Commit

Permalink
Added invalid file type check to batch convert and completion message.
Browse files Browse the repository at this point in the history
  • Loading branch information
sosuke3 committed Mar 10, 2018
1 parent 727a76f commit 8b6621d
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions ZSpriteTools/ZSpriteToolForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,18 +1120,27 @@ private void batchConvertToolStripMenuItem_Click(object sender, EventArgs e)

foreach(var file in files)
{
var destFilename = Path.Combine(destinationFolder, Path.GetFileNameWithoutExtension(file) + ".zspr");
try
{
var destFilename = Path.Combine(destinationFolder, Path.GetFileNameWithoutExtension(file) + ".zspr");

var spriteFile = File.ReadAllBytes(file);
var loadedSprite = new SpriteLibrary.PlayerSprite(spriteFile);
if (loadedSprite.Version == 0)
var spriteFile = File.ReadAllBytes(file);
var loadedSprite = new SpriteLibrary.PlayerSprite(spriteFile);
if (loadedSprite.Version == 0)
{
loadedSprite.DisplayText = Path.GetFileNameWithoutExtension(file);
}

var spriteData = loadedSprite.ToByteArray();
FileUtilities.WriteAllBytes(destFilename, spriteData);
}
catch(Exception ex)
{
loadedSprite.DisplayText = Path.GetFileNameWithoutExtension(file);
MessageBox.Show($"Failed to convert file {file}. {ex.ToString()}.");
}

var spriteData = loadedSprite.ToByteArray();
FileUtilities.WriteAllBytes(destFilename, spriteData);
}

MessageBox.Show("Done converting sprites");
}

private void animationComboBox_SelectedIndexChanged(object sender, EventArgs e)
Expand Down

0 comments on commit 8b6621d

Please sign in to comment.