尝试兼容旧作Sennagi
This commit is contained in:
parent
17550bb6b1
commit
5ca0fe2e9a
@ -4,9 +4,116 @@ namespace EscudeTools
|
||||
{
|
||||
public class ImageManager
|
||||
{
|
||||
public static void ImgPreProcessNew(List<StTable> stts, Face[] faces, LsfManager lm, string outputDir)
|
||||
{
|
||||
var parallelOptions = new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 6 // 设置最大并行线程数
|
||||
};
|
||||
|
||||
Parallel.ForEach(stts, parallelOptions, stt =>
|
||||
//foreach (StTable stt in stts)
|
||||
{
|
||||
if (stt.order == 0) //仅提取鉴赏中有的ST
|
||||
return;
|
||||
//continue;
|
||||
string targetFilename = Path.Combine(outputDir, stt.name); //最后保存可用的文件名
|
||||
LsfData? lsfData = lm.FindLsfDataByName(stt.file) ?? throw new Exception($"错误,未找到与{stt.file}对应的lsf数据");
|
||||
List<int> pendingList = [];
|
||||
List<string> pendingListFn = [];
|
||||
foreach (string o in stt.option)
|
||||
{
|
||||
List<int> t = TableManagercs.ParseOptions(lsfData, o);
|
||||
if (t.Count == 0)
|
||||
continue;
|
||||
pendingList.AddRange(t);
|
||||
foreach (int i in t)
|
||||
{
|
||||
pendingListFn.Add(lsfData.lli[i].nameStr);
|
||||
}
|
||||
}
|
||||
//pendingList = TableManagercs.OrderLayer(pendingList, pendingListFn);
|
||||
int n = 0;
|
||||
foreach (string o in faces[(int)stt.face].faceOptions)
|
||||
{
|
||||
List<int> pendingListCopy = new(pendingList);
|
||||
List<string> pendingListFnCopy = new(pendingListFn);
|
||||
List<int> t = TableManagercs.ParseOptions(lsfData, o);
|
||||
if (t.Count == 0)
|
||||
continue;
|
||||
foreach (int i in t)
|
||||
{
|
||||
pendingListFnCopy.Add(lsfData.lli[i].nameStr);
|
||||
}
|
||||
pendingListCopy.AddRange(t);
|
||||
pendingListCopy = TableManagercs.OrderLayer(pendingListCopy, pendingListFnCopy);
|
||||
if (!ImageManager.Process(lsfData, [.. pendingListCopy], targetFilename + $"_{n}.png"))
|
||||
throw new Exception("Process Fail");
|
||||
else
|
||||
Console.WriteLine($"Export {stt.name}_{n} Success");
|
||||
n++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void ImgPreProcessOld(List<StTable> stts, LsfManager lm, string outputDir)
|
||||
{
|
||||
var parallelOptions = new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 6 // 设置最大并行线程数
|
||||
};
|
||||
|
||||
Parallel.ForEach(stts, parallelOptions, stt =>
|
||||
//foreach (var stt in stts)
|
||||
{
|
||||
if (stt.order == 0) //仅提取鉴赏中有的ST
|
||||
return;
|
||||
string targetFilename = Path.Combine(outputDir, stt.name);
|
||||
LsfData? lsfData = lm.FindLsfDataByName(stt.file) ?? throw new Exception($"错误,未找到与{stt.file}对应的lsf数据");
|
||||
List<int> faceAvailList = [];
|
||||
List<string> faceAvailNameList = [];
|
||||
for (int i = 0; i < lsfData.lli.Length; i++)
|
||||
{
|
||||
if (lsfData.lli[i].index == 1)
|
||||
{
|
||||
faceAvailList.Add(i);
|
||||
faceAvailNameList.Add(lsfData.lli[i].nameStr);
|
||||
}
|
||||
|
||||
}
|
||||
List<int> pendingList = [];
|
||||
List<string> pendingListFn = [];
|
||||
foreach (string o in stt.option)
|
||||
{
|
||||
List<int> t = TableManagercs.ParseOptions(lsfData, o);
|
||||
if (t.Count == 0)
|
||||
continue;
|
||||
pendingList.AddRange(t);
|
||||
foreach (int i in t)
|
||||
{
|
||||
pendingListFn.Add(lsfData.lli[i].nameStr);
|
||||
}
|
||||
}
|
||||
//pendingList = TableManagercs.OrderLayer(pendingList, pendingListFn);
|
||||
int n = 0;
|
||||
for (int k = 0; k < faceAvailList.Count; k++)
|
||||
{
|
||||
List<int> que = new(pendingList);
|
||||
List<string> queStr = new(pendingListFn);
|
||||
que.Add(faceAvailList[k]);
|
||||
queStr.Add(faceAvailNameList[k]);
|
||||
que = TableManagercs.OrderLayer(que, queStr);
|
||||
if (!ImageManager.Process(lsfData, [.. que], targetFilename + $"_{n}.png"))
|
||||
throw new Exception("Process Fail");
|
||||
else
|
||||
Console.WriteLine($"Export {stt.name}_{n} Success");
|
||||
n++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static bool Process(LsfData ld, int[] n, string target)
|
||||
{
|
||||
//get base size
|
||||
int height = ld.lfh.height, width = ld.lfh.width;
|
||||
using var baseImage = new MagickImage(MagickColors.Transparent, (uint)width, (uint)height);
|
||||
for (int i = 0; i < n.Length; i++)
|
||||
@ -19,9 +126,9 @@ namespace EscudeTools
|
||||
if (mode == 3)
|
||||
{
|
||||
overlayImage.Composite(baseImage, -1 * offsetX, -1 * offsetY, CompositeOperator.DstIn);
|
||||
baseImage.Composite(overlayImage, offsetX, offsetY, CompositeOperator.Multiply);//原先就一条这个,发现处理透明时会有问题
|
||||
baseImage.Composite(overlayImage, offsetX, offsetY, CompositeOperator.Multiply);//应该能解决透明度问题了
|
||||
}
|
||||
else if (mode == 10)
|
||||
else if (mode == 10) //目前还没遇到过?
|
||||
{
|
||||
baseImage.Composite(overlayImage, offsetX, offsetY, CompositeOperator.Plus);
|
||||
}
|
||||
@ -34,10 +141,6 @@ namespace EscudeTools
|
||||
return true;
|
||||
}
|
||||
|
||||
//上面足够给Ev、St用了
|
||||
//public static bool StProcess()
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace EscudeTools
|
||||
|
||||
public string pathStr;
|
||||
public string lsfName;
|
||||
}
|
||||
}
|
||||
public class LsfFileHeader
|
||||
{
|
||||
//public uint signature; // Header signature (LSF) 0x46534C
|
||||
|
@ -212,6 +212,7 @@ namespace EscudeTools
|
||||
using (var command = new SqliteCommand($"SELECT * FROM {foundTN[0]};", connection))
|
||||
{
|
||||
using var reader = command.ExecuteReader();
|
||||
int fieldCount = reader.FieldCount;
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.IsDBNull(0) || string.IsNullOrEmpty(reader.GetString(0)))
|
||||
@ -223,7 +224,7 @@ namespace EscudeTools
|
||||
option = (reader["オプション_44"].ToString() ?? "").Split(' '),
|
||||
//coverd = (uint)reader.GetInt32(3),
|
||||
//filter = (uint)reader.GetInt32(4),
|
||||
face = (uint)reader.GetInt32("表情_14"),
|
||||
face = (uint)(fieldCount == 9 ? 0 : reader.GetInt32("表情_14")),
|
||||
//id = (uint)reader.GetInt32(6),
|
||||
//loc = (uint)reader.GetInt32(7),
|
||||
order = reader.GetInt32("CG鑑賞_14"),
|
||||
@ -232,10 +233,14 @@ namespace EscudeTools
|
||||
}
|
||||
}
|
||||
List<string> fa = [];
|
||||
bool legacyMode = false;
|
||||
using (var command = new SqliteCommand($"SELECT * FROM {foundTN[1]};", connection))
|
||||
{
|
||||
using var reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
int fieldCount = reader.FieldCount;
|
||||
if (fieldCount <= 2)
|
||||
legacyMode = true;
|
||||
while (reader.Read() && !legacyMode)
|
||||
{
|
||||
if (reader.IsDBNull(0) || string.IsNullOrEmpty(reader.GetString(0)))
|
||||
continue;
|
||||
@ -263,55 +268,10 @@ namespace EscudeTools
|
||||
string outputDir = Path.Combine(Path.GetDirectoryName(v1), "Output");
|
||||
if (!Directory.Exists(outputDir))
|
||||
Directory.CreateDirectory(outputDir);
|
||||
|
||||
var parallelOptions = new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = 6 // 设置最大并行线程数
|
||||
};
|
||||
|
||||
Parallel.ForEach(stts, parallelOptions, stt =>
|
||||
//foreach (StTable stt in stts)
|
||||
{
|
||||
if (stt.order == 0) //仅提取鉴赏中有的ST
|
||||
return;
|
||||
//continue;
|
||||
string targetFilename = Path.Combine(outputDir, stt.name); //最后保存可用的文件名
|
||||
LsfData? lsfData = lm.FindLsfDataByName(stt.file) ?? throw new Exception($"错误,未找到与{stt.file}对应的lsf数据");
|
||||
List<int> pendingList = [];
|
||||
List<string> pendingListFn = [];
|
||||
foreach (string o in stt.option)
|
||||
{
|
||||
List<int> t = TableManagercs.ParseOptions(lsfData, o);
|
||||
if (t.Count == 0)
|
||||
continue;
|
||||
pendingList.AddRange(t);
|
||||
foreach (int i in t)
|
||||
{
|
||||
pendingListFn.Add(lsfData.lli[i].nameStr);
|
||||
}
|
||||
}
|
||||
//pendingList = TableManagercs.OrderLayer(pendingList, pendingListFn);
|
||||
int n = 0;
|
||||
foreach (string o in faces[(int)stt.face].faceOptions)
|
||||
{
|
||||
List<int> pendingListCopy = new(pendingList);
|
||||
List<string> pendingListFnCopy = new(pendingListFn);
|
||||
List<int> t = TableManagercs.ParseOptions(lsfData, o);
|
||||
if (t.Count == 0)
|
||||
continue;
|
||||
foreach (int i in t)
|
||||
{
|
||||
pendingListFnCopy.Add(lsfData.lli[i].nameStr);
|
||||
}
|
||||
pendingListCopy.AddRange(t);
|
||||
pendingListCopy = TableManagercs.OrderLayer(pendingListCopy, pendingListFnCopy);
|
||||
if (!ImageManager.Process(lsfData, [.. pendingListCopy], targetFilename + $"_{n++}.png"))
|
||||
throw new Exception("Process Fail");
|
||||
else
|
||||
Console.WriteLine($"Export {stt.name}_{n - 1} Success");
|
||||
}
|
||||
});
|
||||
//}
|
||||
if (legacyMode)
|
||||
ImageManager.ImgPreProcessOld(stts, lm, outputDir);
|
||||
else
|
||||
ImageManager.ImgPreProcessNew(stts, faces, lm, outputDir);
|
||||
|
||||
}
|
||||
}
|
||||
@ -647,7 +607,7 @@ namespace EscudeTools
|
||||
Console.WriteLine("Ignore the 001 files; the program will read them if needed.");
|
||||
Console.WriteLine("Must specify the type of script bin file to unpack.");
|
||||
Console.WriteLine("Accepts the following types: 0, 1, 2.");
|
||||
Console.WriteLine("Type 0: Full; this creates script.db containing all .bin and .001 information.");
|
||||
Console.WriteLine("Type 0(unstable): Full; this creates script.db containing all .bin and .001 information.");
|
||||
Console.WriteLine("Type 2: Exports only the text from bin; this creates script_text.db and many .dat files (non-text data).");
|
||||
Console.WriteLine("Type 1: Exports only the text from 001; this creates script_sm.db containing all .001 information.");
|
||||
Console.WriteLine();
|
||||
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"profiles": {
|
||||
"EscudeTools": {
|
||||
"commandName": "Project"
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "-s\r\n\"G:\\x221.local\\[231027][1231724][エスクード] 戦巫<センナギ> ―穢れた契りと神ころも― DL版 (files)\\戦巫〈センナギ〉―穢れた契りと神ころも―\\output\\st\\0\"\r\n\"G:\\x221.local\\[231027][1231724][エスクード] 戦巫<センナギ> ―穢れた契りと神ころも― DL版 (files)\\戦巫〈センナギ〉―穢れた契りと神ころも―\\output\\st\\db_graphics.db\""
|
||||
}
|
||||
}
|
||||
}
|
@ -89,9 +89,9 @@ namespace EscudeTools
|
||||
foreach (string item in layer_fn)
|
||||
{
|
||||
string[] parts = item.Split("_");
|
||||
if (parts.Length == 3)
|
||||
if (parts.Length >= 3)
|
||||
{
|
||||
if (int.TryParse(parts[2], out int number))
|
||||
if (int.TryParse(parts[^1], out int number))
|
||||
{
|
||||
order.Add(number);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user