开个头,准备从script里强行抓fg组合信息

这下还有人敢说我漏东西了嘛
This commit is contained in:
Chenx221 2024-10-31 23:42:33 +08:00
parent fd4fd95c79
commit 2559d4a438
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
2 changed files with 101 additions and 12 deletions

View File

@ -0,0 +1,77 @@
namespace ArtemisFgTools
{
public class FgHelper
{
public class FgObject(string path, string head, List<string> fuku, List<List<string>> pose, Dictionary<string, List<string>> face)
{
public string Path { get; set; } = path;
public string Head { get; set; } = head;
public List<string> Fuku { get; set; } = fuku;
public List<List<string>> Pose { get; set; } = pose;
public Dictionary<string, List<string>> Face { get; set; } = face;
}
public static List<FgObject> FetchFgObjectsFromScript(string path)
{
//检查path是否存在然后foreach获得文件夹下所有.ast文件循环
if (!Directory.Exists(path))
throw new DirectoryNotFoundException("The path does not exist.");
else
{
List<string> fgScriptLine = [];
foreach (string f in Directory.GetFiles(path, "*.ast"))
{
using StreamReader sr = new(f);
string? line;
while ((line = sr.ReadLine()) != null)
{
if (line.Contains("{\"fg\","))
fgScriptLine.Add(line);
}
}
if (fgScriptLine.Count == 0)
throw new Exception("No valid fg script line found.");
else
{
List<FgObject> fgObjects = [];
foreach (var line in fgScriptLine)
{
FgObject fgObject = ParseScriptFGLine(line);
// TODO:如果fgObject未被添加到fgObjects中添加
fgObjects.Add(fgObject);
}
if (fgObjects.Count == 0)
throw new Exception("No valid fg object found.");
else
return fgObjects;
}
}
}
public static FgObject ParseScriptFGLine(string input)
{
input = input.Trim('{', '}');
var pairs = input.Split(',');
var result = new Dictionary<string, string>();
foreach (var pair in pairs)
{
var keyValue = pair.Split(['=', '='], 2);
if (keyValue.Length == 2)
{
string key = keyValue[0].Trim();
string value = keyValue[1].Trim().Trim('"'); // 去掉引号
result[key] = value;
}
}
foreach (var kv in result)
{
Console.WriteLine($"{kv.Key}: {kv.Value}");
}
throw new NotImplementedException();
}
}
}

View File

@ -1,26 +1,32 @@
using ImageMagick; using ImageMagick;
using NLua; using NLua;
using System.Reflection.Metadata.Ecma335;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using static ArtemisFgTools.FgHelper;
namespace ArtemisFgTools namespace ArtemisFgTools
{ {
internal class Program internal class Program
{ {
public class FgObject(string path, string head, List<string> fuku, List<List<string>> pose, Dictionary<string, List<string>> face)
{
public string Path { get; set; } = path;
public string Head { get; set; } = head;
public List<string> Fuku { get; set; } = fuku;
public List<List<string>> Pose { get; set; } = pose;
public Dictionary<string, List<string>> Face { get; set; } = face;
}
static void Main() static void Main()
{ {
Console.WriteLine("请输入立绘fg文件夹的所在路径无需\"\""); Console.WriteLine("请输入立绘fg文件夹的所在路径无需\"\"");
string? fgImagePath = Console.ReadLine(); string? fgImagePath = Console.ReadLine();
Console.WriteLine("请输入exlist的文件路径"); Console.WriteLine("要合并的游戏有找到exlist吗(y/n) ");
string spModeStr = Console.ReadLine() ?? throw new Exception("Invalid input");
bool spMode = (spModeStr == "n") || (spModeStr == "y" ? false : throw new Exception("Invalid input"));
string? luaFilePath = Console.ReadLine(); string? luaFilePath = Console.ReadLine();
if (spMode)
{
dosth();
return;
}
Console.WriteLine("请输入保存位置:"); Console.WriteLine("请输入保存位置:");
string? savePath = Console.ReadLine(); string? savePath = Console.ReadLine();
@ -71,6 +77,7 @@ namespace ArtemisFgTools
fgObjects.Add(new FgObject(path, head, fuku, pose, face)); fgObjects.Add(new FgObject(path, head, fuku, pose, face));
} }
} }
//jmp
foreach (var fgObject in fgObjects) foreach (var fgObject in fgObjects)
{ {
foreach (var siz in size) foreach (var siz in size)
@ -157,6 +164,11 @@ namespace ArtemisFgTools
} }
} }
private static void dosth()
{
throw new NotImplementedException();
}
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)) if (File.Exists(target))