public void ExtractTexts(string filePath) { using (BinaryReader binred = new BinaryReader(File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.Unicode)) { bnd = binred.ReadUInt32(); idka = binred.ReadUInt32(); idka = binred.ReadUInt32(); fileCount = binred.ReadUInt32(); idk2 = binred.ReadUInt64(); version = binred.ReadUInt64(); directoryEntrySize = binred.ReadUInt32(); idk3 = binred.ReadUInt32(); dataOffset = binred.ReadUInt32(); idk4 = binred.ReadUInt32(); binred.ReadInt64(); binred.ReadInt64(); fmgArray = new FmgFile[fileCount]; for (int i = 0; i < fileCount; i++) { uint fileEntryOffset; uint fileNameOffset; uint fileId = 1; ulong idk6 = binred.ReadUInt64(); ulong fileEntrySize = binred.ReadUInt64(); if (directoryEntrySize == 36) { binred.ReadUInt64();//fileEntrySize again fileEntryOffset = binred.ReadUInt32(); fileId = binred.ReadUInt32(); fileNameOffset = binred.ReadUInt32(); } else { fileEntryOffset = binred.ReadUInt32(); fileNameOffset = binred.ReadUInt32(); } long hold = binred.BaseStream.Position; FmgFile entry = new FmgFile(); entry.FillData(binred, fileEntryOffset, (int)fileEntrySize, fileNameOffset, fileId); binred.BaseStream.Position = hold; fmgArray[i] = entry; } } ExcelFile excelFile = new ExcelFile(); string exportPath = filePath + ".xlsx"; excelFile.Create(fmgArray, exportPath); }
public void TestImporter(string bndFilePath) { string[] fmgPaths = //Directory.GetFiles(Path.GetDirectoryName(filePath), "*.fmg"); new string[] { "会話.fmg", "血文字.fmg", "ムービー字幕.fmg", "イベントテキスト.fmg", "インゲームメニュー.fmg", "メニュー共通テキスト.fmg", "メニューその他.fmg", "ダイアログ.fmg", "キーガイド.fmg", "一行ヘルプ.fmg", "項目ヘルプ.fmg", "テキスト表示用タグ一覧.fmg", "FDP_メニューテキスト.fmg", "FDP_一行ヘルプ.fmg", "FDP_キーガイド.fmg", "FDP_システムメッセージ_win64.fmg", "FDP_ダイアログ.fmg", "FDP_システムメッセージ_ps4.fmg", "FDP_システムメッセージ_xboxone.fmg", "会話_dlc1.fmg", "イベントテキスト_dlc1.fmg", "FDP_メニューテキスト_dlc1.fmg", "FDP_一行ヘルプ_dlc1.fmg", "FDP_システムメッセージ_win64_dlc1.fmg", "FDP_ダイアログ_dlc1.fmg", "FDP_システムメッセージ_ps4_dlc1.fmg", "FDP_システムメッセージ_xboxone_dlc1.fmg", "血文字_dlc1.fmg", "会話_dlc2.fmg", "イベントテキスト_dlc2.fmg", "FDP_メニューテキスト_dlc2.fmg", "FDP_一行ヘルプ_dlc2.fmg", "FDP_システムメッセージ_win64_dlc2.fmg", "FDP_ダイアログ_dlc2.fmg", "FDP_システムメッセージ_ps4_dlc2.fmg", "FDP_システムメッセージ_xboxone_dlc2.fmg", "血文字_dlc2.fmg", }; fmgArray = new FmgFile[fmgPaths.Length]; string sota = @"C:\Users\Burk\Desktop\darksoulsShit\BinderTool v0.4.3\data1\msg\engUS\"; for (int i = 0; i < fmgPaths.Length; i++) { FmgFile fmg = new FmgFile(); fmg.GetFromRawData(sota + fmgPaths[i]); fmg.fileName = fmg.fileName + "\0"; fmgArray[i] = fmg; } byte[] bndFile = File.ReadAllBytes(bndFilePath); using (BinaryReader binred = new BinaryReader(new MemoryStream(bndFile))) { MemoryStream newDat = new MemoryStream(); using (BinaryWriter binwr = new BinaryWriter(newDat)) { binwr.Write(binred.ReadBytes(6304)); for (int i = 0; i < fmgArray.Length; i++) { uint hold = (uint)binwr.BaseStream.Position; binwr.BaseStream.Position = 64 + (36 * i + 24); binwr.Write(hold); binwr.BaseStream.Position = hold; binwr.Write(fmgArray[i].fmgByteData); } } File.WriteAllBytes(bndFilePath + ".TESTIMPORTER", newDat.ToArray()); } }
public void Read(string where) { excelPath = where; ExcelPackage pck = new ExcelPackage(File.Open(where, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); ExcelWorksheet ws = pck.Workbook.Worksheets["Satirlar"]; Dictionary <string, FmgFile> fmgDic = new Dictionary <string, FmgFile>(); for (int col = 2; col < ws.Dimension.Rows; col++) { string orgStr = Tools.HandleCellValue(ws.Cells["A" + col].Value); string trStr = Tools.HandleCellValue(ws.Cells["B" + col].Value); uint id = uint.Parse(ws.Cells["C" + col].Value.ToString()); int fol = int.Parse(ws.Cells["D" + col].Value.ToString()); string fileName = ws.Cells["E" + col].Value.ToString(); uint fileId = uint.Parse(ws.Cells["F" + col].Value.ToString()); if (!fmgDic.ContainsKey(fileName)) { FmgFile fmgFile = new FmgFile(); fmgFile.fileName = fileName + "\0"; fmgFile.fileId = fileId; fmgDic.Add(fileName, fmgFile); } FmgString fmgStr = new FmgString(); string selectedStr = trStr; if (trStr == null || trStr == "") { selectedStr = orgStr; } selectedStr = selectedStr.Replace("\\n", "\n").Replace("\\r", "\r").Replace("\\t", "\t") + "\0"; fmgStr.str = selectedStr; fmgStr.id = id; fmgStr.firstorLast = fol; fmgDic[fileName].linesList.Add(fmgStr); } fmgBlocks = fmgDic.Values.ToList(); foreach (var fmg in fmgBlocks) { FmgIdRange idrange; for (int i = 0; i < fmg.linesList.Count; i++) { FmgString fstr = fmg.linesList[i]; if (fstr.firstorLast == 1) { idrange = new FmgIdRange(); idrange.firstId = fstr.id; idrange.offsetIndex = (uint)i; idrange.lastId = fstr.id; fmg.idRangesList.Add(idrange); } else if (fstr.firstorLast == -1) { fmg.idRangesList.Last().lastId = fstr.id; } } } Console.Write("."); }