54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Markup;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
|
|
namespace SpritePacker
|
|
{
|
|
class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
Utilities.GetProgramBuildDate();
|
|
List<string> values = new List<string>();
|
|
for(int i = 0; i < args.Length; i++)
|
|
{
|
|
switch(args[i])
|
|
{
|
|
case "--help":
|
|
string helpText = Utilities.GetEmbeddedResourceContent("SpritePacker.Help.txt");
|
|
string commitHash = Utilities.GetEmbeddedResourceContent("SpritePacker.latest-commit-hash.txt").Trim();
|
|
Dictionary<string, string> templateValues = new Dictionary<string, string>() {
|
|
{ "version", Utilities.GetProgramVersion().ToString() },
|
|
{ "build-time", Utilities.GetProgramBuildDate().ToString("dd/MM/yyyy h:mmtt") },
|
|
{ "commit-hash", commitHash.Substring(commitHash.Length - 7) }
|
|
};
|
|
foreach (KeyValuePair<string, string> replacePair in templateValues)
|
|
helpText = helpText.Replace(string.Format("{{{0}}}", replacePair.Key), replacePair.Value);
|
|
|
|
Console.WriteLine(helpText);
|
|
return;
|
|
case "--version":
|
|
Console.WriteLine("Version text coming soon!");
|
|
return;
|
|
default:
|
|
values.Add(args[i]);
|
|
break;
|
|
}
|
|
}
|
|
|
|
Packer spritePacker = new Packer();
|
|
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();
|
|
Console.WriteLine(spritePacker.ToString());
|
|
}
|
|
}
|
|
}
|