Skip to content

Commit

Permalink
Close #1366.
Browse files Browse the repository at this point in the history
  • Loading branch information
VladiStep committed May 5, 2023
1 parent 9acea03 commit 0bc9dbd
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions UndertaleModTool/Scripts/Resource Repackers/ImportGraphics.csx
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,19 @@ foreach (Atlas atlas in packer.Atlasses)
{
// Get sprite to add this texture to
string spriteName;
int lastUnderscore, frame;
int lastUnderscore;
int frame = 0;
try
{
lastUnderscore = stripped.LastIndexOf('_');
spriteName = stripped.Substring(0, lastUnderscore);
frame = Int32.Parse(stripped.Substring(lastUnderscore + 1));
if (lastUnderscore != -1)
{
spriteName = stripped[..lastUnderscore];
Int32.TryParse(stripped.Substring(lastUnderscore + 1), out frame);
}
else
spriteName = stripped;

}
catch (Exception e)
{
Expand Down Expand Up @@ -574,32 +581,23 @@ Pressing ""No"" will cause the program to ignore these images.");
// Sprites can have multiple frames! Do some sprite-specific checking.
if (spriteType == SpriteType.Sprite)
{
// Allow sprites without an underscore
if (lastUnderscore == -1)
continue;

try
{
spriteName = stripped.Substring(0, lastUnderscore);
spriteName = stripped[..lastUnderscore];
}
catch
{
throw new ScriptException("Getting the sprite name of " + FileNameWithExtension + " failed.");
}
Int32 validFrameNumber = 0;
try
{
validFrameNumber = Int32.Parse(stripped.Substring(lastUnderscore + 1));
}
catch
{
throw new ScriptException("The index of " + FileNameWithExtension + " could not be determined.");
}
int frame = 0;
try
{
frame = Int32.Parse(stripped.Substring(lastUnderscore + 1));
}
catch
{
throw new ScriptException(FileNameWithExtension + " is using letters instead of numbers. The script has stopped for your own protection.");
}

// If sprite has no index, then assume it's a single frame sprite
if (!Int32.TryParse(stripped.Substring(lastUnderscore + 1), out int frame))
continue;

int prevframe = 0;
if (frame != 0)
{
Expand Down

0 comments on commit 0bc9dbd

Please sign in to comment.