removed extension for region names + refactor
This commit is contained in:
parent
7116eb0437
commit
0b812f45fe
@ -86,7 +86,7 @@ namespace RecrownedAthenaeum.Tools.CommandProcessor
|
|||||||
/// <param name="argument">The argument to find the index of.</param>
|
/// <param name="argument">The argument to find the index of.</param>
|
||||||
/// <param name="arguments">The array containing all arguments.</param>
|
/// <param name="arguments">The array containing all arguments.</param>
|
||||||
/// <returns>The index or throws argument exception if it doesn't exist.</returns>
|
/// <returns>The index or throws argument exception if it doesn't exist.</returns>
|
||||||
public int IndexOfArgumentIn(string argument, string[] arguments)
|
public int IndexOfArgument(string argument, string[] arguments)
|
||||||
{
|
{
|
||||||
if (arguments != null)
|
if (arguments != null)
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ namespace RecrownedAthenaeum.Tools.CommandProcessor
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IndexOfArgumentIn(argument, arguments);
|
IndexOfArgument(argument, arguments);
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ namespace RecrownedAthenaeum.Tools.CommandProcessor
|
|||||||
/// <returns>The index or throws argument exception if it doesn't exist.</returns>
|
/// <returns>The index or throws argument exception if it doesn't exist.</returns>
|
||||||
public int IndexOfArgumentIn(EngineCommandArgument argument, string[] arguments)
|
public int IndexOfArgumentIn(EngineCommandArgument argument, string[] arguments)
|
||||||
{
|
{
|
||||||
return IndexOfArgumentIn(argument.invokeString, arguments);
|
return IndexOfArgument(argument.invokeString, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -32,22 +32,21 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
|||||||
if (arguments == null) throw new ArgumentException("Missing arguments. Type \"help 9p\" for more information.");
|
if (arguments == null) throw new ArgumentException("Missing arguments. Type \"help 9p\" for more information.");
|
||||||
int leftBound = 0, rightBound = 0, topBound = 0, bottomBound = 0;
|
int leftBound = 0, rightBound = 0, topBound = 0, bottomBound = 0;
|
||||||
string imagePath, outPath;
|
string imagePath, outPath;
|
||||||
if (IndexOfArgumentIn("-i", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -i path after argument.");
|
if (IndexOfArgument("-i", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -i path after argument.");
|
||||||
imagePath = arguments[IndexOfArgumentIn("-i", arguments) + 1];
|
imagePath = arguments[IndexOfArgument("-i", arguments) + 1];
|
||||||
|
|
||||||
if (HasArgument(commandArguments[1], arguments))
|
if (HasArgument(commandArguments[1], arguments))
|
||||||
{
|
{
|
||||||
if (IndexOfArgumentIn("-o", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -o path after argument.");
|
if (IndexOfArgument("-o", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -o path after argument.");
|
||||||
outPath = arguments[IndexOfArgumentIn("-o", arguments) + 1];
|
outPath = arguments[IndexOfArgument("-o", arguments) + 1];
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
outPath = imagePath.Substring(0, imagePath.Length - Path.GetExtension(imagePath).Length);
|
outPath = imagePath.Substring(0, imagePath.Length - Path.GetExtension(imagePath).Length);
|
||||||
}
|
}
|
||||||
|
if (IndexOfArgument("-l", arguments) + 1 >= arguments.Length || !int.TryParse(arguments[IndexOfArgument("-l", arguments) + 1], out leftBound)) throw new ArgumentException("Missing -l argument bound.");
|
||||||
if (IndexOfArgumentIn("-l", arguments) + 1 >= arguments.Length && !int.TryParse(arguments[IndexOfArgumentIn("-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 (IndexOfArgumentIn("-r", arguments) + 1 >= arguments.Length && !int.TryParse(arguments[IndexOfArgumentIn("-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 (IndexOfArgumentIn("-u", arguments) + 1 >= arguments.Length && !int.TryParse(arguments[IndexOfArgumentIn("-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.");
|
||||||
if (IndexOfArgumentIn("-d", arguments) + 1 >= arguments.Length && !int.TryParse(arguments[IndexOfArgumentIn("-d", arguments) + 1], out bottomBound)) throw new ArgumentException("Missing -d argument bound.");
|
|
||||||
|
|
||||||
NinePatchData npData = new NinePatchData(Path.GetFileName(imagePath), leftBound, rightBound, bottomBound, topBound);
|
NinePatchData npData = new NinePatchData(Path.GetFileName(imagePath), leftBound, rightBound, bottomBound, topBound);
|
||||||
string serialized = JsonConvert.SerializeObject(npData, Formatting.Indented);
|
string serialized = JsonConvert.SerializeObject(npData, Formatting.Indented);
|
||||||
@ -58,7 +57,7 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
|||||||
|
|
||||||
File.WriteAllText(outPath + ".9p", serialized);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ namespace RecrownedAthenaeum.Tools.TextureAtlas
|
|||||||
ImageHandler ih = imageHandlers[i];
|
ImageHandler ih = imageHandlers[i];
|
||||||
regions[i].SetBounds(ih.x, ih.y, ih.Width, ih.Height);
|
regions[i].SetBounds(ih.x, ih.y, ih.Width, ih.Height);
|
||||||
regions[i].ninePatchData = ih.ninePatchData;
|
regions[i].ninePatchData = ih.ninePatchData;
|
||||||
regions[i].name = ih.Name;
|
regions[i].name = Path.GetFileNameWithoutExtension(ih.Name);
|
||||||
using (Image<Rgba32> image = Image.Load<Rgba32>(ih.path))
|
using (Image<Rgba32> image = Image.Load<Rgba32>(ih.path))
|
||||||
{
|
{
|
||||||
atlasTexture.Mutate(img => img.DrawImage(gOptions, image, new Point(ih.x, ih.y)));
|
atlasTexture.Mutate(img => img.DrawImage(gOptions, image, new Point(ih.x, ih.y)));
|
||||||
|
@ -65,20 +65,20 @@ namespace RecrownedAthenaeum.Tools.TextureAtlasTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int indexOfInputArg = IndexOfArgumentIn("-i", arguments);
|
int indexOfInputArg = IndexOfArgument("-i", arguments);
|
||||||
if (indexOfInputArg + 1 >= arguments.Length) throw new ArgumentException("-i is not followed by input path.");
|
if (indexOfInputArg + 1 >= arguments.Length) throw new ArgumentException("-i is not followed by input path.");
|
||||||
path = arguments[1 + IndexOfArgumentIn("-i", arguments)];
|
path = arguments[1 + IndexOfArgument("-i", arguments)];
|
||||||
if (HasArgument("-mp", arguments))
|
if (HasArgument("-mp", arguments))
|
||||||
{
|
{
|
||||||
int.TryParse(arguments[IndexOfArgumentIn("-mp", arguments) + 1], out mp);
|
int.TryParse(arguments[IndexOfArgument("-mp", arguments) + 1], out mp);
|
||||||
}
|
}
|
||||||
if (HasArgument("-sp", arguments))
|
if (HasArgument("-sp", arguments))
|
||||||
{
|
{
|
||||||
int.TryParse(arguments[IndexOfArgumentIn("-sp", arguments) + 1], out sp);
|
int.TryParse(arguments[IndexOfArgument("-sp", arguments) + 1], out sp);
|
||||||
}
|
}
|
||||||
int indexOfOutputArg = IndexOfArgumentIn("-o", arguments);
|
int indexOfOutputArg = IndexOfArgument("-o", arguments);
|
||||||
if (indexOfOutputArg + 1 >= arguments.Length) throw new ArgumentException("-o is not followed by input path.");
|
if (indexOfOutputArg + 1 >= arguments.Length) throw new ArgumentException("-o is not followed by input path.");
|
||||||
output = arguments[IndexOfArgumentIn("-o", arguments) + 1];
|
output = arguments[IndexOfArgument("-o", arguments) + 1];
|
||||||
if (HasArgument("-dau", arguments)) dau = true;
|
if (HasArgument("-dau", arguments)) dau = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user