added a few more arguments to the texture packer command.
This commit is contained in:
parent
f001272b2d
commit
87952248c5
@ -18,13 +18,19 @@ namespace RecrownedAthenaeum.Tools.TextureAtlasTools
|
|||||||
switch (argument)
|
switch (argument)
|
||||||
{
|
{
|
||||||
case null:
|
case null:
|
||||||
return "Packs a given directory composed of png and jpg files into an atlas. Can also add 9patch properties. Possible arguments are \"-i\", \"-o\", and \"-9p\". Refer to \"help\" for more info.";
|
return "Packs a given directory composed of png and jpg files into an atlas. Can also add 9patch properties. Possible arguments are \"-i\", \"-o\", \"-mp\", \"-dau\", and \"-9p\". Refer to \"help\" for more info.";
|
||||||
case "-i":
|
case "-i":
|
||||||
return "-i : path for input directory containing the textures. Required.";
|
return "-i : Path for input directory containing the textures. Required.";
|
||||||
case "-o":
|
case "-o":
|
||||||
return "-o : path for output files. Points to non-existent file. Will create texture and definitions file with name. Required.";
|
return "-o : Path for output files. Points to non-existent file. Will create texture and definitions file with name. Required.";
|
||||||
case "-9p":
|
case "-9p":
|
||||||
return "-9p can be used multiple times for defining a 9patch. This parameter requires a name, left patch, right patch, top patch, and bottom patch in the format name,a,b,c,d. Optional.";
|
return "-9p : Can be used multiple times for defining a 9patch. This parameter requires a name, left patch, right patch, top patch, and bottom patch in the format name,a,b,c,d. Optional.";
|
||||||
|
case "-sp":
|
||||||
|
return "-sp : starting power for one side of the texture. Default is 8.";
|
||||||
|
case "-mp":
|
||||||
|
return "-mp : Maximum power for one side of the texture. Default is 8.";
|
||||||
|
case "-dau":
|
||||||
|
return "-dau : disables automatically upscaling the texture.";
|
||||||
default:
|
default:
|
||||||
return argument + " is not a valid argument. Type \"help texturepacker to see general help and list of arguments.\"";
|
return argument + " is not a valid argument. Type \"help texturepacker to see general help and list of arguments.\"";
|
||||||
}
|
}
|
||||||
@ -32,18 +38,42 @@ namespace RecrownedAthenaeum.Tools.TextureAtlasTools
|
|||||||
|
|
||||||
public override void Run(string[] arguments)
|
public override void Run(string[] arguments)
|
||||||
{
|
{
|
||||||
|
string path = null;
|
||||||
|
int mp = 8;
|
||||||
|
int sp = 8;
|
||||||
if (arguments == null) throw new ArgumentException("Requires arguments. Type \"help texturepacker\" for more info.");
|
if (arguments == null) throw new ArgumentException("Requires arguments. Type \"help texturepacker\" for more info.");
|
||||||
|
|
||||||
for (int i = 0; i < arguments.Length; i++)
|
for (int i = 0; i < arguments.Length; i++)
|
||||||
{
|
{
|
||||||
if (arguments[i] == "-i")
|
if (arguments[i] == "-i")
|
||||||
{
|
{
|
||||||
if (i + 1 >= arguments.Length) throw new ArgumentException("-i is not followed by path for input directory.");
|
if (i + 1 == arguments.Length) throw new ArgumentException("-i is not followed by path for input directory.");
|
||||||
texturePacker = new TexturePacker((arguments[i + 1]));
|
path = arguments[i + 1];
|
||||||
|
}
|
||||||
|
if (arguments[i] == "-mp")
|
||||||
|
{
|
||||||
|
if (i + 1 >= arguments.Length || !int.TryParse(arguments[i + 1], out mp)) throw new ArgumentException("mp is not followed by maximum power.");
|
||||||
|
}
|
||||||
|
if (arguments[i] == "-sp")
|
||||||
|
{
|
||||||
|
if (i + 1 >= arguments.Length || !int.TryParse(arguments[i + 1], out sp)) throw new ArgumentException("sp is not followed by maximum power.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
texturePacker = new TexturePacker(path, mp, sp);
|
||||||
if (texturePacker != null)
|
if (texturePacker != null)
|
||||||
{
|
{
|
||||||
texturePacker.Build();
|
bool dau = false;
|
||||||
|
for (int i = 0; i < arguments.Length; i++)
|
||||||
|
{
|
||||||
|
if (arguments[i] == "-dau") dau = true;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
texturePacker.Build(!dau);
|
||||||
|
} catch (InvalidOperationException e)
|
||||||
|
{
|
||||||
|
throw new ArgumentException(e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < arguments.Length; i++)
|
for (int i = 0; i < arguments.Length; i++)
|
||||||
{
|
{
|
||||||
@ -76,7 +106,8 @@ namespace RecrownedAthenaeum.Tools.TextureAtlasTools
|
|||||||
throw new ArgumentException("no -o argument found to specify output.");
|
throw new ArgumentException("no -o argument found to specify output.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentException("-i not specified.");
|
throw new ArgumentException("-i not specified.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user