Skip to content

Commit

Permalink
Downgrade duplicate sprite to a warning so we can parse some base gam…
Browse files Browse the repository at this point in the history
…e files with duplicated sprites
  • Loading branch information
daviscook477 committed Jan 13, 2020
1 parent aac24cb commit 8c61137
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion kanimal-cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ private static void Convert(string inputFormat, string outputFormat, List<string
case "scml":
var scmlWriter = new ScmlWriter(reader)
{
FillMissingSprites = !opt.Strict
FillMissingSprites = !opt.Strict,
AllowDuplicateSprites = !opt.Strict
};
scmlWriter.SaveToDir(Path.Join(opt.OutputPath));
break;
Expand Down
10 changes: 9 additions & 1 deletion kanimal/Writer/ScmlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ScmlWriter : Writer
protected XmlElement Entity;

public bool FillMissingSprites = true; // When true, if a file is referenced in frames but doesn't exist as a sprite, add it as a blank 1x1 sprite.
public bool AllowDuplicateSprites = true; // When true if a sprite is defined multiple times, only utilize the first definition.

public ScmlWriter(Reader reader)
{
Expand Down Expand Up @@ -97,7 +98,14 @@ protected virtual void AddFolderInfo()
var key = row.GetSpriteName().ToFilename();
if (filenameindex.ContainsKey(key))
{
throw new Exception($"filenameindex already contains a key for the sprite {key.Value}!");
if (AllowDuplicateSprites)
{
Logger.Warn($"Duplicate sprite for {key.Value}. This may be indicative of a problem with the source file.");
}
else
{
throw new Exception($"filenameindex already contains a key for the sprite {key.Value}! Try again without strict mode if you believe this is in error.");
}
}

filenameindex[key] = fileIndex;
Expand Down

0 comments on commit 8c61137

Please sign in to comment.