Performed basic tests and fixed 9patch and texturepacker.
This commit is contained in:
@@ -17,14 +17,14 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
||||
{
|
||||
help = "Generates a 9 patch file for a given image.";
|
||||
|
||||
arguments = new EngineCommandArgument[6];
|
||||
commandArguments = new EngineCommandArgument[6];
|
||||
|
||||
arguments[0] = new EngineCommandArgument("-i", "defines the path to the texture to be used for the nine patch.", true);
|
||||
arguments[1] = new EngineCommandArgument("-o", "defines path of output file.");
|
||||
arguments[2] = new EngineCommandArgument("-l", "left patch.", true);
|
||||
arguments[3] = new EngineCommandArgument("-r", "right patch.", true);
|
||||
arguments[4] = new EngineCommandArgument("-u", "up patch.", true);
|
||||
arguments[5] = new EngineCommandArgument("-d", "down patch.", true);
|
||||
commandArguments[0] = new EngineCommandArgument("-i", "defines the path to the texture to be used for the nine patch.", true);
|
||||
commandArguments[1] = new EngineCommandArgument("-o", "defines path of output file.");
|
||||
commandArguments[2] = new EngineCommandArgument("-l", "left patch.", true);
|
||||
commandArguments[3] = new EngineCommandArgument("-r", "right patch.", true);
|
||||
commandArguments[4] = new EngineCommandArgument("-u", "up patch.", true);
|
||||
commandArguments[5] = new EngineCommandArgument("-d", "down patch.", true);
|
||||
}
|
||||
|
||||
public override void Run(string[] arguments = null)
|
||||
@@ -35,13 +35,13 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
||||
if (IndexOfArgumentIn("-i", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -i path after argument.");
|
||||
imagePath = arguments[IndexOfArgumentIn("-i", arguments) + 1];
|
||||
|
||||
if (HasArgument(arguments[1], arguments))
|
||||
if (HasArgument(commandArguments[1], arguments))
|
||||
{
|
||||
if (IndexOfArgumentIn("-o", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -o path after argument.");
|
||||
outPath = arguments[IndexOfArgumentIn("-o", arguments) + 1];
|
||||
} else
|
||||
{
|
||||
outPath = Path.GetFileNameWithoutExtension(imagePath);
|
||||
outPath = imagePath.Substring(0, imagePath.Length - Path.GetExtension(imagePath).Length);
|
||||
}
|
||||
|
||||
if (IndexOfArgumentIn("-l", arguments) + 1 >= arguments.Length && !int.TryParse(arguments[IndexOfArgumentIn("-l", arguments) + 1], out leftBound)) throw new ArgumentException("Missing -l argument bound.");
|
||||
@@ -52,13 +52,13 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
||||
NinePatchData npData = new NinePatchData(Path.GetFileName(imagePath), leftBound, rightBound, bottomBound, topBound);
|
||||
string serialized = JsonConvert.SerializeObject(npData, Formatting.Indented);
|
||||
|
||||
if (!File.Exists(imagePath)) throw new ArgumentException("Input file does not exist.");
|
||||
if (!File.Exists(imagePath)) throw new ArgumentException("Input file does not exist at " + imagePath + ".");
|
||||
SupportedExtensions extension;
|
||||
if (!Enum.TryParse<SupportedExtensions>(Path.GetExtension(imagePath).ToLower().Substring(1), out extension)) throw new ArgumentException("Input file extension not supported.");
|
||||
using (StreamWriter stringWriter = new StreamWriter(outPath + ".9p"))
|
||||
{
|
||||
stringWriter.WriteLine(serialized);
|
||||
}
|
||||
if (!Enum.TryParse<SupportedExtensions>(Path.GetExtension(imagePath).ToLower().Substring(1), out extension)) throw new ArgumentException("Input file extension \"" + Path.GetExtension(imagePath).ToLower().Substring(1) + "\" not supported.");
|
||||
|
||||
File.WriteAllText(outPath + ".9p", serialized);
|
||||
|
||||
ConsoleUtilities.WriteWrappedLine("Done. Written to \"" + outPath + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user