Slight bugfix in new preset mode

This commit is contained in:
Starbeamrainbowlabs 2018-08-09 22:37:42 +01:00
parent 494e8c09fa
commit f92154b228
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 6 additions and 3 deletions

View file

@ -61,8 +61,10 @@ namespace SpritePacker
string presetFilename = args[++i]; string presetFilename = args[++i];
if (File.Exists(presetFilename)) if (File.Exists(presetFilename))
rawSourceLocations = File.ReadAllText(presetFilename); rawSourceLocations = File.ReadAllText(presetFilename);
else else {
Console.Error.WriteLine("Warning: Couldn't find the preset csv file at {0}", presetFilename); Console.Error.WriteLine("Warning: Couldn't find the preset csv file at {0}", presetFilename);
return 1;
}
break; break;
case "--csv": case "--csv":
outputFormat = OutputFormat.CSV; outputFormat = OutputFormat.CSV;
@ -120,7 +122,7 @@ namespace SpritePacker
// Preset some locations if they were specified // Preset some locations if they were specified
if (rawSourceLocations != null) { if (rawSourceLocations != null) {
foreach (string[] line in parseCSV(rawSourceLocations).Skip(1)) { // Skip the header foreach (string[] line in parseCSV(rawSourceLocations).Skip(1)) { // Skip the header
// index,filename,x,y,width,height // index,filename,x,y,width,height
Sprite currentSprite = sprites.Find((Sprite item) => item.Filename == line[1]); Sprite currentSprite = sprites.Find((Sprite item) => item.Filename == line[1]);
currentSprite.Area = new Rectangle( currentSprite.Area = new Rectangle(
int.Parse(line[2]), int.Parse(line[2]),
@ -129,6 +131,7 @@ namespace SpritePacker
int.Parse(line[5]) int.Parse(line[5])
); );
currentSprite.Placed = true; currentSprite.Placed = true;
if(Verbose) Console.WriteLine("Pre-placing {0}", currentSprite);
} }
} }
spritePacker.Add(sprites); spritePacker.Add(sprites);

View file

@ -155,7 +155,7 @@ namespace SpritePacker
if (probSpr.Bottom > downProblem.Bottom) if (probSpr.Bottom > downProblem.Bottom)
downProblem = probSpr; downProblem = probSpr;
// If the current problem's right edge is further in than the current next scan line, // If the current problem's right edge is further in than the current next scan line,
// move the enxt scan line up to meet it. // move the next scan line up to meet it.
// Also make sure that the next scan line and the current scan line don't touch or cross. // Also make sure that the next scan line and the current scan line don't touch or cross.
if (probSpr.Right < nextScanLines.X && probSpr.Right > scanLines.X) if (probSpr.Right < nextScanLines.X && probSpr.Right > scanLines.X)
nextScanLines.X = probSpr.Right; // NOTE: Add one here? nextScanLines.X = probSpr.Right; // NOTE: Add one here?