Commit 4d533380 authored by Accensus's avatar Accensus
Browse files

- Removed anchors. Being able to set the base offsets renders anchors...

- Removed anchors. Being able to set the base offsets renders anchors redundant, plus they only interfere and make things unnecessarily complicated and/or confusing. May reimplement if deemed necessary.
- Base offsets are now required.
- Moved destination to the end of the argument list because it is still optional.
- Set UseShellExecute to "true". There's no reason to use "false" in this scenario.
parent 596f4a3c
......@@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Authors>Accensus</Authors>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<Copyright>(c) 2019-2020 Accensus</Copyright>
</PropertyGroup>
......
......@@ -17,25 +17,20 @@ namespace ImageCropper
{
Description = "Source directory of the images. Required."
},
new Argument<DirectoryInfo>("dest")
new Argument<int[]>("offset")
{
Description = "Output directory.",
Arity = new ArgumentArity(0, 1)
Description = "Base offsets. Required. Specified as a pair of integers, i.e. 50 100. Offset the uncropped sprite in SLADE until it looks good, then use that offset here.",
Arity = new ArgumentArity(2, 2)
},
new Argument<int[]>("offset", () => new[]{ 0, 0 })
{
Description = "Base offsets. Defaults are 0 0; recommended for monster sprites.",
Arity = new ArgumentArity(0, 2)
},
new Argument<float[]>("anchor", () => new[]{ 0.5f, 1.0f })
new Argument<DirectoryInfo>("dest")
{
Description = "Image-relative offset. Range is normally [0.0, 1.0]. Defaults are 0.5 1.0; recommended for monster sprites. Use 0 0 for weapon sprites.",
Arity = new ArgumentArity(0, 2)
Description = "Output directory. Optional. If not specifed, a folder called \"CroppedOutput\" will automatically be created.",
Arity = new ArgumentArity(0, 1)
},
};
RootCommand.Description = "Crop around the empty space around a sprite and automatically adjust the offsets using SetPNG.exe or GrabPNG.exe, which must be located in the same folder as this executable.";
RootCommand.Handler = CommandHandler.Create<DirectoryInfo, DirectoryInfo, int[], float[]>((src, dest, offset, anchor) =>
RootCommand.Handler = CommandHandler.Create<DirectoryInfo, int[], DirectoryInfo>((src, offset, dest) =>
{
if (!src.Exists)
{
......@@ -70,17 +65,9 @@ namespace ImageCropper
string NewFile = Path.Combine(dest.FullName, Sprite.SourceFile.Name);
Sprite.CropAndSave(NewFile, SolidArea);
Vector2 RelativeOffset = new Vector2(SolidArea.X, SolidArea.Y);
Vector2 AnchorOffset = new Vector2
{
X = (int)Math.Round(SolidArea.Width * anchor[0]),
Y = (int)Math.Round(SolidArea.Height * anchor[1])
};
Vector2 CalcOffset = new Vector2(offset[0], offset[1]) + AnchorOffset - RelativeOffset;
if (OffsetTool != null)
{
Vector2 CalcOffset = new Vector2(offset[0], offset[1]) - new Vector2(SolidArea.X, SolidArea.Y);
SetOffsets(OffsetTool, CalcOffset, NewFile, NewFile);
}
}
......@@ -97,7 +84,6 @@ namespace ImageCropper
{
Proc.StartInfo.FileName = tool.FullName;
Proc.StartInfo.Arguments = $"-grab {offset.X} {offset.Y} {src} {dest}";
Proc.StartInfo.UseShellExecute = false;
Proc.StartInfo.CreateNoWindow = true;
Proc.Start();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment