added check for valid input for texture nine patch command.
This commit is contained in:
parent
c62361da2f
commit
5e9d64e181
@ -8,6 +8,11 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
||||
{
|
||||
public class NinePatchCommand : EngineCommand
|
||||
{
|
||||
private enum SupportedExtensions
|
||||
{
|
||||
jpeg, jpg, png
|
||||
}
|
||||
|
||||
public NinePatchCommand() : base("9p", "ninepatch", "9patch")
|
||||
{
|
||||
help = "Generates a 9 patch file for a given image.";
|
||||
@ -41,6 +46,9 @@ 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.");
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user