Browse Source

Added processing of specified filenames.\r\nStill need to finish the Sprite class constructor.

tags/v0.1
Starbeamrainbowlabs 3 years ago
parent
commit
b0548527bc
1 changed files with 36 additions and 4 deletions
  1. 36
    4
      SpritePacker/Program.cs

+ 36
- 4
SpritePacker/Program.cs View File

@@ -18,11 +18,16 @@ namespace SpritePacker
public static string Version = Utilities.GetEmbeddedResourceContent("SpritePacker.Version.txt").Trim();

private static ProgramMode programMode = ProgramMode.Normal;

private static string helpTextFilename = "SpritePacker.Resources.HelpText.txt";
private static string versionTextFilename = "SpritePacker.Resources.VersionText.txt";
private static string commitHashFilename = "SpritePacker.latest-commit-hash.txt";

private static Packer spritePacker = new Packer();
private static List<string> values = new List<string>();

public static bool Verbose = false;

public static int Main(string[] args)
{
string commitHash = Utilities.GetEmbeddedResourceContent(commitHashFilename).Trim();
@@ -38,6 +43,9 @@ namespace SpritePacker
case "--version":
programMode = ProgramMode.DisplayVersionText;
break;
case "--verbose":
Verbose = true;
break;
default:
if(args[i].StartsWith("-"))
{
@@ -81,16 +89,40 @@ namespace SpritePacker

public static void RunNormal()
{
Packer spritePacker = new Packer();
addSprites(values);
spritePacker.Arrange();
Console.WriteLine(spritePacker.ToString());
}

private static void addSprites(List<string> filenames)
{
foreach(string filename in values)
{
// Make sure that the file actually exists (we don't want the packer to throw a tantrum)
if (File.Exists(filename))
spritePacker.Add(new Sprite(filename));
{
try
{
spritePacker.Add(new Sprite(filename));
}
catch(Exception error)
{
Console.Error.WriteLine("Error reading {0}: {1}", filename, error.Message);
}

if ((File.GetAttributes(filename) & FileAttributes.Directory) == FileAttributes.Directory)
{
// This filename is a directory - recurse over all the files in the directory
string[] dirFiles = Directory.GetFiles(filename);
addSprites(new List<string>(dirFiles));
}
}
else
{
Console.Error.WriteLine("Warning: Ignoring non-existent file '{0}'.", filename);
}
}
spritePacker.Arrange();
Console.WriteLine(spritePacker.ToString());

}
}
}

Loading…
Cancel
Save