This commit is contained in:
Chenx221 2024-10-26 22:58:01 +08:00
parent 12a544b6df
commit 390a4614b3
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
2 changed files with 261 additions and 261 deletions

View File

@ -6,198 +6,198 @@ namespace EscudeTools
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
////批量处理EV/ST //批量处理EV/ST
//if (Directory.Exists(args[0]) && File.Exists(args[1])) if (Directory.Exists(args[0]) && File.Exists(args[1]))
////if (File.Exists(args[0])) //if (File.Exists(args[0]))
//{ {
// string graphicsDBPath = args[1]; string graphicsDBPath = args[1];
// using SqliteConnection connection = new($"Data Source={graphicsDBPath};"); using SqliteConnection connection = new($"Data Source={graphicsDBPath};");
// connection.Open(); connection.Open();
// List<string> tableNames = []; List<string> tableNames = [];
// string[] foundTN = new string[3]; string[] foundTN = new string[3];
// List<int> tableIds = []; List<int> tableIds = [];
// bool found1 = false, found2 = false, found3 = false; bool found1 = false, found2 = false, found3 = false;
// using (var command = new SqliteCommand("SELECT name FROM sqlite_master WHERE type='table';", connection)) using (var command = new SqliteCommand("SELECT name FROM sqlite_master WHERE type='table';", connection))
// using (var reader = command.ExecuteReader()) using (var reader = command.ExecuteReader())
// { {
// int id = 0; int id = 0;
// while (reader.Read()) while (reader.Read())
// { {
// string tableName = reader.GetString(0); string tableName = reader.GetString(0);
// if (tableName.StartsWith("イベント")) if (tableName.StartsWith("イベント"))
// { {
// foundTN[0] = tableName; foundTN[0] = tableName;
// found1 = true; found1 = true;
// } }
// else if (tableName.StartsWith("立ち")) else if (tableName.StartsWith("立ち"))
// { {
// foundTN[1] = tableName; foundTN[1] = tableName;
// found2 = true; found2 = true;
// } }
// else if (tableName.StartsWith("表情")) else if (tableName.StartsWith("表情"))
// { {
// foundTN[2] = tableName; foundTN[2] = tableName;
// found3 = true; found3 = true;
// } }
// tableNames.Add(tableName); tableNames.Add(tableName);
// tableIds.Add(id++); tableIds.Add(id++);
// } }
// } }
// if (!(found1 && found2 && found3)) //这里的代码未经测试 if (!(found1 && found2 && found3)) //这里的代码未经测试
// { {
// for (int i = 0; i < tableNames.Count; i++) for (int i = 0; i < tableNames.Count; i++)
// Console.WriteLine($"{tableIds[i]}: {tableNames[i]}"); Console.WriteLine($"{tableIds[i]}: {tableNames[i]}");
// if (!found1) if (!found1)
// { {
// Console.WriteLine("自动识别失败请选择存放CG信息的数据表ID: "); Console.WriteLine("自动识别失败请选择存放CG信息的数据表ID: ");
// string? input = Console.ReadLine(); string? input = Console.ReadLine();
// if (int.TryParse(input, out int userInputId)) if (int.TryParse(input, out int userInputId))
// { {
// if (userInputId >= 0 && userInputId < tableIds.Count) if (userInputId >= 0 && userInputId < tableIds.Count)
// { {
// foundTN[0] = tableNames[userInputId]; foundTN[0] = tableNames[userInputId];
// } }
// else else
// { {
// Console.WriteLine("Invalid ID."); Console.WriteLine("Invalid ID.");
// return; return;
// } }
// } }
// else else
// { {
// Console.WriteLine("Invalid input. Please enter a valid number."); Console.WriteLine("Invalid input. Please enter a valid number.");
// return; return;
// } }
// } }
// if (!found2) if (!found2)
// { {
// Console.WriteLine("自动识别失败请选择存放立绘信息的数据表ID: "); Console.WriteLine("自动识别失败请选择存放立绘信息的数据表ID: ");
// string? input = Console.ReadLine(); string? input = Console.ReadLine();
// if (int.TryParse(input, out int userInputId)) if (int.TryParse(input, out int userInputId))
// { {
// if (userInputId >= 0 && userInputId < tableIds.Count) if (userInputId >= 0 && userInputId < tableIds.Count)
// { {
// foundTN[1] = tableNames[userInputId]; foundTN[1] = tableNames[userInputId];
// } }
// else else
// { {
// Console.WriteLine("Invalid ID."); Console.WriteLine("Invalid ID.");
// return; return;
// } }
// } }
// else else
// { {
// Console.WriteLine("Invalid input. Please enter a valid number."); Console.WriteLine("Invalid input. Please enter a valid number.");
// return; return;
// } }
// } }
// if (!found3) if (!found3)
// { {
// Console.WriteLine("自动识别失败请选择存放表情信息的数据表ID: "); Console.WriteLine("自动识别失败请选择存放表情信息的数据表ID: ");
// string? input = Console.ReadLine(); string? input = Console.ReadLine();
// if (int.TryParse(input, out int userInputId)) if (int.TryParse(input, out int userInputId))
// { {
// if (userInputId >= 0 && userInputId < tableIds.Count) if (userInputId >= 0 && userInputId < tableIds.Count)
// { {
// foundTN[2] = tableNames[userInputId]; foundTN[2] = tableNames[userInputId];
// } }
// else else
// { {
// Console.WriteLine("Invalid ID."); Console.WriteLine("Invalid ID.");
// return; return;
// } }
// } }
// else else
// { {
// Console.WriteLine("Invalid input. Please enter a valid number."); Console.WriteLine("Invalid input. Please enter a valid number.");
// return; return;
// } }
// } }
// } }
// List<EvTable> evts = []; List<EvTable> evts = [];
// List<StTable> stts = []; List<StTable> stts = [];
// Face[] faces = new Face[32]; Face[] faces = new Face[32];
// using (var command = new SqliteCommand($"SELECT * FROM {foundTN[0]};", connection)) using (var command = new SqliteCommand($"SELECT * FROM {foundTN[0]};", connection))
// { {
// using var reader = command.ExecuteReader(); using var reader = command.ExecuteReader();
// while (reader.Read()) while (reader.Read())
// { {
// if (reader.IsDBNull(0) || string.IsNullOrEmpty(reader.GetString(0))) if (reader.IsDBNull(0) || string.IsNullOrEmpty(reader.GetString(0)))
// continue; continue;
// evts.Add(new EvTable evts.Add(new EvTable
// { {
// name = reader.GetString(0), name = reader.GetString(0),
// file = reader.GetString(1), file = reader.GetString(1),
// option = reader.GetString(2).Split(' '), option = reader.GetString(2).Split(' '),
// coverd = (uint)reader.GetInt32(3), coverd = (uint)reader.GetInt32(3),
// filter = (uint)reader.GetInt32(4), filter = (uint)reader.GetInt32(4),
// color = (uint)reader.GetInt32(5), color = (uint)reader.GetInt32(5),
// id = (uint)reader.GetInt32(6), id = (uint)reader.GetInt32(6),
// loc = (uint)reader.GetInt32(7), loc = (uint)reader.GetInt32(7),
// order = reader.GetInt32(8), order = reader.GetInt32(8),
// link = (uint)reader.GetInt32(9) link = (uint)reader.GetInt32(9)
// }); });
// } }
// } }
// using (var command = new SqliteCommand($"SELECT * FROM {foundTN[1]};", connection)) using (var command = new SqliteCommand($"SELECT * FROM {foundTN[1]};", connection))
// { {
// using var reader = command.ExecuteReader(); using var reader = command.ExecuteReader();
// while (reader.Read()) while (reader.Read())
// { {
// if (reader.IsDBNull(0) || string.IsNullOrEmpty(reader.GetString(0))) if (reader.IsDBNull(0) || string.IsNullOrEmpty(reader.GetString(0)))
// continue; continue;
// stts.Add(new StTable stts.Add(new StTable
// { {
// name = reader.GetString(0), name = reader.GetString(0),
// file = reader.GetString(1), file = reader.GetString(1),
// option = reader.GetString(2).Split(' '), option = reader.GetString(2).Split(' '),
// coverd = (uint)reader.GetInt32(3), coverd = (uint)reader.GetInt32(3),
// filter = (uint)reader.GetInt32(4), filter = (uint)reader.GetInt32(4),
// face = (uint)reader.GetInt32(5), face = (uint)reader.GetInt32(5),
// id = (uint)reader.GetInt32(6), id = (uint)reader.GetInt32(6),
// loc = (uint)reader.GetInt32(7), loc = (uint)reader.GetInt32(7),
// order = reader.GetInt32(8), order = reader.GetInt32(8),
// link = (uint)reader.GetInt32(9) link = (uint)reader.GetInt32(9)
// }); });
// } }
// } }
// using (var command = new SqliteCommand($"SELECT * FROM {foundTN[2]};", connection)) using (var command = new SqliteCommand($"SELECT * FROM {foundTN[2]};", connection))
// { {
// using var reader = command.ExecuteReader(); using var reader = command.ExecuteReader();
// while (reader.Read()) while (reader.Read())
// { {
// if (reader.IsDBNull(0) || string.IsNullOrEmpty(reader.GetString(0))) if (reader.IsDBNull(0) || string.IsNullOrEmpty(reader.GetString(0)))
// continue; continue;
// for (int i = 0; i < faces.Length; i++) for (int i = 0; i < faces.Length; i++)
// { {
// if (faces[i] == null) if (faces[i] == null)
// faces[i] = new Face(); faces[i] = new Face();
// if (reader.GetInt32(2 + i) == 1) if (reader.GetInt32(2 + i) == 1)
// faces[i].faceOptions.Add(reader.GetString(1)); faces[i].faceOptions.Add(reader.GetString(1));
// } }
// } }
// } }
// string[] files = Directory.GetFiles(args[0], "*.lsf", SearchOption.AllDirectories); string[] files = Directory.GetFiles(args[0], "*.lsf", SearchOption.AllDirectories);
// LsfManager lm = new(); LsfManager lm = new();
// foreach (string file in files) foreach (string file in files)
// { {
// if (lm.LoadLsf(file, true)) if (lm.LoadLsf(file, true))
// Console.WriteLine($"Load {file} Success"); Console.WriteLine($"Load {file} Success");
// else else
// { {
// Console.WriteLine($"Load {file} Failed"); Console.WriteLine($"Load {file} Failed");
// } }
// } }
// connection.Close(); connection.Close();
// string outputDir = Path.Combine(Path.GetDirectoryName(args[0]), "Output"); string outputDir = Path.Combine(Path.GetDirectoryName(args[0]), "Output");
// if (!Directory.Exists(outputDir)) if (!Directory.Exists(outputDir))
// Directory.CreateDirectory(outputDir); Directory.CreateDirectory(outputDir);
// var parallelOptions = new ParallelOptions var parallelOptions = new ParallelOptions
// { {
// MaxDegreeOfParallelism = 6 // 设置最大并行线程数 MaxDegreeOfParallelism = 6 // 设置最大并行线程数
// }; };
// //ST //表情还要另取? // //ST //表情还要另取?
// Parallel.ForEach(stts, parallelOptions, stt => // Parallel.ForEach(stts, parallelOptions, stt =>
@ -238,38 +238,38 @@ namespace EscudeTools
// }); // });
////} ////}
// //EV //EV
// Parallel.ForEach(evts, parallelOptions, evt => Parallel.ForEach(evts, parallelOptions, evt =>
// //foreach (EvTable evt in evts) //foreach (EvTable evt in evts)
// { {
// if (evt.order == 0) //仅提取鉴赏中有的CG if (evt.order == 0) //仅提取鉴赏中有的CG
// return; return;
// //continue;
// string targetFilename = Path.Combine(outputDir, evt.name + ".png"); //最后保存可用的文件名
// LsfData lsfData = lm.FindLsfDataByName(evt.file) ?? throw new Exception("Something Wrong");
// List<int> pendingList = [];
// List<string> pendingListFn = [];
// foreach (string o in evt.option)
// {
// List<int> t = TableManagercs.ParseOptions(lsfData, o);
// if (t.Count == 0)
//continue; //continue;
// pendingList.AddRange(t); string targetFilename = Path.Combine(outputDir, evt.name + ".png"); //最后保存可用的文件名
// foreach (int i in t) LsfData lsfData = lm.FindLsfDataByName(evt.file) ?? throw new Exception("Something Wrong");
// { List<int> pendingList = [];
// pendingListFn.Add(lsfData.lli[i].nameStr); List<string> pendingListFn = [];
// } foreach (string o in evt.option)
// } {
// pendingList = TableManagercs.OrderLayer(pendingList, pendingListFn); List<int> t = TableManagercs.ParseOptions(lsfData, o);
// if (pendingList[0] != 0) if (t.Count == 0)
// pendingList.Insert(0, 0); continue;
// if (!ImageManager.Process(lsfData, [.. pendingList], targetFilename)) pendingList.AddRange(t);
// throw new Exception("Process Fail"); foreach (int i in t)
// else {
// Console.WriteLine($"Export {evt.name} Success"); pendingListFn.Add(lsfData.lli[i].nameStr);
// }); }
// //} }
pendingList = TableManagercs.OrderLayer(pendingList, pendingListFn);
if (pendingList[0] != 0)
pendingList.Insert(0, 0);
if (!ImageManager.Process(lsfData, [.. pendingList], targetFilename))
throw new Exception("Process Fail");
else
Console.WriteLine($"Export {evt.name} Success");
});
//} //}
}

View File

@ -2,7 +2,7 @@
"profiles": { "profiles": {
"EscudeTools": { "EscudeTools": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "G:\\x221.local\\lab3\\Haison\\output\\data" "commandLineArgs": "G:\\x221.local\\lab3\\Haison\\output\\ev\\1\r\n\"G:\\x221.local\\lab3\\Haison\\output\\ev\\db_graphics.db\""
} }
} }
} }