开个头,准备从script里强行抓fg组合信息
这下还有人敢说我漏东西了嘛
This commit is contained in:
parent
fd4fd95c79
commit
2559d4a438
77
ArtemisFgTools/FgHelper.cs
Normal file
77
ArtemisFgTools/FgHelper.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +1,32 @@
|
||||
using ImageMagick;
|
||||
using NLua;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Text.RegularExpressions;
|
||||
using static ArtemisFgTools.FgHelper;
|
||||
namespace ArtemisFgTools
|
||||
{
|
||||
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()
|
||||
{
|
||||
Console.WriteLine("请输入立绘fg文件夹的所在路径(无需\"\"):");
|
||||
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();
|
||||
if (spMode)
|
||||
{
|
||||
dosth();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("请输入保存位置:");
|
||||
string? savePath = Console.ReadLine();
|
||||
@ -71,6 +77,7 @@ namespace ArtemisFgTools
|
||||
fgObjects.Add(new FgObject(path, head, fuku, pose, face));
|
||||
}
|
||||
}
|
||||
//jmp
|
||||
foreach (var fgObject in fgObjects)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (File.Exists(target))
|
||||
|
Loading…
Reference in New Issue
Block a user