Added processing of specified filenames.\r\nStill need to finish the Sprite class constructor.
This commit is contained in:
parent
b7c269acea
commit
b0548527bc
1 changed files with 40 additions and 8 deletions
|
@ -18,11 +18,16 @@ namespace SpritePacker
|
||||||
public static string Version = Utilities.GetEmbeddedResourceContent("SpritePacker.Version.txt").Trim();
|
public static string Version = Utilities.GetEmbeddedResourceContent("SpritePacker.Version.txt").Trim();
|
||||||
|
|
||||||
private static ProgramMode programMode = ProgramMode.Normal;
|
private static ProgramMode programMode = ProgramMode.Normal;
|
||||||
|
|
||||||
private static string helpTextFilename = "SpritePacker.Resources.HelpText.txt";
|
private static string helpTextFilename = "SpritePacker.Resources.HelpText.txt";
|
||||||
private static string versionTextFilename = "SpritePacker.Resources.VersionText.txt";
|
private static string versionTextFilename = "SpritePacker.Resources.VersionText.txt";
|
||||||
private static string commitHashFilename = "SpritePacker.latest-commit-hash.txt";
|
private static string commitHashFilename = "SpritePacker.latest-commit-hash.txt";
|
||||||
|
|
||||||
|
private static Packer spritePacker = new Packer();
|
||||||
private static List<string> values = new List<string>();
|
private static List<string> values = new List<string>();
|
||||||
|
|
||||||
|
public static bool Verbose = false;
|
||||||
|
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
string commitHash = Utilities.GetEmbeddedResourceContent(commitHashFilename).Trim();
|
string commitHash = Utilities.GetEmbeddedResourceContent(commitHashFilename).Trim();
|
||||||
|
@ -38,6 +43,9 @@ namespace SpritePacker
|
||||||
case "--version":
|
case "--version":
|
||||||
programMode = ProgramMode.DisplayVersionText;
|
programMode = ProgramMode.DisplayVersionText;
|
||||||
break;
|
break;
|
||||||
|
case "--verbose":
|
||||||
|
Verbose = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if(args[i].StartsWith("-"))
|
if(args[i].StartsWith("-"))
|
||||||
{
|
{
|
||||||
|
@ -81,16 +89,40 @@ namespace SpritePacker
|
||||||
|
|
||||||
public static void RunNormal()
|
public static void RunNormal()
|
||||||
{
|
{
|
||||||
Packer spritePacker = new Packer();
|
addSprites(values);
|
||||||
foreach(string filename in values)
|
|
||||||
{
|
|
||||||
if (File.Exists(filename))
|
|
||||||
spritePacker.Add(new Sprite(filename));
|
|
||||||
else
|
|
||||||
Console.Error.WriteLine("Warning: Ignoring non-existent file '{0}'.", filename);
|
|
||||||
}
|
|
||||||
spritePacker.Arrange();
|
spritePacker.Arrange();
|
||||||
Console.WriteLine(spritePacker.ToString());
|
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))
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue