Compare commits

..

2 Commits

Author SHA1 Message Date
e1c83d9d13 多线程处理 2024-07-28 17:15:47 +08:00
513d9d541b 修复坐标为负数时的意外情况 2024-07-28 16:49:07 +08:00
2 changed files with 14 additions and 8 deletions

View File

@ -11,6 +11,7 @@
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="13.10.0" /> <PackageReference Include="Magick.NET-Q16-AnyCPU" Version="13.10.0" />
<PackageReference Include="Magick.NET.Core" Version="13.10.0" /> <PackageReference Include="Magick.NET.Core" Version="13.10.0" />
<PackageReference Include="NLua" Version="1.7.3" /> <PackageReference Include="NLua" Version="1.7.3" />
<PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,7 +1,6 @@
using ImageMagick; using ImageMagick;
using NLua; using NLua;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml.Linq;
namespace ArtemisFgTools namespace ArtemisFgTools
{ {
internal class Program internal class Program
@ -81,12 +80,13 @@ namespace ArtemisFgTools
string pathWithSize = Path.Combine(fgImagePath, fgObject.Path, siz.ToString() ?? string.Empty); string pathWithSize = Path.Combine(fgImagePath, fgObject.Path, siz.ToString() ?? string.Empty);
foreach (var pose in fgObject.Pose) foreach (var pose in fgObject.Pose)
{ {
foreach (var fuku in fgObject.Fuku) Parallel.ForEach(fgObject.Fuku, fuku =>
//foreach (var in )
{ {
bool special = false; bool special = false;
string fuku_current = fuku; string fuku_current = fuku;
//if the tail of fuku is |0099, spec to true & remove |0099 //if the tail of fuku is |0099, spec to true & remove |0099
if (fuku.EndsWith("|0099")) if (fuku_current.EndsWith("|0099"))
{ {
special = true; special = true;
fuku_current = fuku[0..^5]; fuku_current = fuku[0..^5];
@ -102,7 +102,7 @@ namespace ArtemisFgTools
ProcessAndSave(baseImg, layerImg, layer2Img, savePathWithAll, special); ProcessAndSave(baseImg, layerImg, layer2Img, savePathWithAll, special);
} }
} });
} }
} }
} }
@ -113,11 +113,11 @@ namespace ArtemisFgTools
string pathWithSize = Path.Combine(fgImagePath, fgObject.Path, siz2.ToString() ?? string.Empty); string pathWithSize = Path.Combine(fgImagePath, fgObject.Path, siz2.ToString() ?? string.Empty);
foreach (var pose in fgObject.Pose) foreach (var pose in fgObject.Pose)
{ {
foreach (var fuku in fgObject.Fuku) Parallel.ForEach(fgObject.Fuku, fuku =>
{ {
bool special = false; bool special = false;
string fuku_current = fuku; string fuku_current = fuku;
if (fuku.EndsWith("|0099")) if (fuku_current.EndsWith("|0099"))
{ {
special = true; special = true;
fuku_current = fuku[0..^5]; fuku_current = fuku[0..^5];
@ -130,7 +130,7 @@ namespace ArtemisFgTools
string savePathWithAll = Path.Combine(savePathWithSizePart, $"{fgObject.Head}no{pose[0]}{fuku_current}{pose[1]}0_{face}" + (special ? ($"_{pose[0]}0099.png") : (".png"))); string savePathWithAll = Path.Combine(savePathWithSizePart, $"{fgObject.Head}no{pose[0]}{fuku_current}{pose[1]}0_{face}" + (special ? ($"_{pose[0]}0099.png") : (".png")));
ProcessAndSave(baseImg, layerImg, layer2Img, savePathWithAll, special); ProcessAndSave(baseImg, layerImg, layer2Img, savePathWithAll, special);
} }
} });
} }
} }
} }
@ -144,6 +144,11 @@ namespace ArtemisFgTools
private static void ProcessAndSave(string baseImg, string layerImg, string layer2Img, string target, bool special) private static void ProcessAndSave(string baseImg, string layerImg, string layer2Img, string target, bool special)
{ {
if (File.Exists(target))
{
Console.WriteLine($"{Path.GetFileName(target)}已存在,跳过!");
return;
}
string? directory = Path.GetDirectoryName(target); string? directory = Path.GetDirectoryName(target);
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
{ {
@ -284,7 +289,7 @@ namespace ArtemisFgTools
{ {
if (comment != null) if (comment != null)
{ {
string pattern = @"^pos,(\d+),(\d+),(\d+),(\d+)$"; string pattern = @"^pos,(-?\d+),(-?\d+),(-?\d+),(-?\d+)$";
Match match = Regex.Match(comment, pattern); Match match = Regex.Match(comment, pattern);
if (match.Success) if (match.Success)
{ {