removed extension for region names + refactor
This commit is contained in:
@@ -32,22 +32,21 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
||||
if (arguments == null) throw new ArgumentException("Missing arguments. Type \"help 9p\" for more information.");
|
||||
int leftBound = 0, rightBound = 0, topBound = 0, bottomBound = 0;
|
||||
string imagePath, outPath;
|
||||
if (IndexOfArgumentIn("-i", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -i path after argument.");
|
||||
imagePath = arguments[IndexOfArgumentIn("-i", arguments) + 1];
|
||||
if (IndexOfArgument("-i", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -i path after argument.");
|
||||
imagePath = arguments[IndexOfArgument("-i", arguments) + 1];
|
||||
|
||||
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];
|
||||
if (IndexOfArgument("-o", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -o path after argument.");
|
||||
outPath = arguments[IndexOfArgument("-o", arguments) + 1];
|
||||
} else
|
||||
{
|
||||
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.");
|
||||
if (IndexOfArgumentIn("-r", arguments) + 1 >= arguments.Length && !int.TryParse(arguments[IndexOfArgumentIn("-r", arguments) + 1], out rightBound)) throw new ArgumentException("Missing -r argument bound.");
|
||||
if (IndexOfArgumentIn("-u", arguments) + 1 >= arguments.Length && !int.TryParse(arguments[IndexOfArgumentIn("-u", arguments) + 1], out topBound)) throw new ArgumentException("Missing -u argument bound.");
|
||||
if (IndexOfArgumentIn("-d", arguments) + 1 >= arguments.Length && !int.TryParse(arguments[IndexOfArgumentIn("-d", arguments) + 1], out bottomBound)) throw new ArgumentException("Missing -d argument bound.");
|
||||
if (IndexOfArgument("-l", arguments) + 1 >= arguments.Length || !int.TryParse(arguments[IndexOfArgument("-l", arguments) + 1], out leftBound)) throw new ArgumentException("Missing -l argument bound.");
|
||||
if (IndexOfArgument("-r", arguments) + 1 >= arguments.Length || !Int32.TryParse(arguments[IndexOfArgument("-r", arguments) + 1], out rightBound)) throw new ArgumentException("Missing -r argument bound.");
|
||||
if (IndexOfArgument("-u", arguments) + 1 >= arguments.Length || !int.TryParse(arguments[IndexOfArgument("-u", arguments) + 1], out topBound)) throw new ArgumentException("Missing -u argument bound.");
|
||||
if (IndexOfArgument("-d", arguments) + 1 >= arguments.Length || !int.TryParse(arguments[IndexOfArgument("-d", arguments) + 1], out bottomBound)) throw new ArgumentException("Missing -d argument bound.");
|
||||
|
||||
NinePatchData npData = new NinePatchData(Path.GetFileName(imagePath), leftBound, rightBound, bottomBound, topBound);
|
||||
string serialized = JsonConvert.SerializeObject(npData, Formatting.Indented);
|
||||
@@ -58,7 +57,7 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
||||
|
||||
File.WriteAllText(outPath + ".9p", serialized);
|
||||
|
||||
ConsoleUtilities.WriteWrappedLine("Done. Written to \"" + outPath + "\"");
|
||||
ConsoleUtilities.WriteWrappedLine("Done. Written to \"" + outPath + "\" with values: left = " + leftBound + " right = " + rightBound + " top = " + topBound + " bottom = " + bottomBound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user