public static Project GetProject(string projectPath) { if (projectPath.EndsWith("tf_yak0")) { return(Yakuza0Project.GetProject(projectPath)); } if (projectPath.EndsWith("tf_shm")) { return(ShenmueProject.GetProject(projectPath)); } if (projectPath.EndsWith("tf_sao_hf")) { return(SAOProject.GetProject(projectPath)); } if (projectPath.EndsWith("tf_srr")) { return(SRRProject.GetProject(projectPath)); } if (projectPath.EndsWith("tf_dsg")) { return(DisgaeaProject.GetProject(projectPath)); } if (projectPath.EndsWith("tf_btr")) { return(BattleRealmsProject.GetProject(projectPath)); } if (projectPath.EndsWith("tf_spf2")) { return(Spellforce2Project.GetProject(projectPath)); } if (projectPath.EndsWith("tf_jjm")) { return(JJMacfieldProject.GetProject(projectPath)); } if (projectPath.EndsWith("tf_nightcry")) { return(NightCryProject.GetProject(projectPath)); } throw new Exception(); }
private TFString ReadString(Stream s) { var stringOffset = (int)s.Position; var value = new TFString { FileId = Id, Offset = stringOffset, Visible = false }; var str = s.ReadStringZ(Encoding); if (!string.IsNullOrEmpty(str.TrimEnd('\0'))) { str = SRRProject.ReadingReplacements(str); } value.Original = str; value.Translation = str; value.Visible = !string.IsNullOrWhiteSpace(str); return(value); }
public override void Save(string fileName, byte[] originalContent, IList <TFString> strings, ExportOptions options) { using (var fs = new FileStream(fileName, FileMode.Create)) { fs.Seek(0x20, SeekOrigin.Begin); var content = _root.Content; fs.WriteValueS32(content.Unknown1, Endianness); fs.WriteValueS32(content.StringCount1, Endianness); fs.WriteValueS32(content.Array2ItemSize, Endianness); fs.WriteValueS32(content.StringCount2, Endianness); fs.WriteValueS32(content.Unknown3, Endianness); if (content.Array2ItemSize == 3) { fs.WriteValueS32(content.Unknown4, Endianness); } fs.WriteValueS32(content.Language, Endianness); var array1Base = fs.Position; var array2Base = array1Base + 4 * content.StringCount1; var stringsBase = array2Base + content.Array2ItemSize * 4 * content.StringCount1; var stringOffset = 0; for (var i = 0; i < content.StringCount1; i++) { var item = content.Strings[i]; fs.Seek(array1Base + 4 * i, SeekOrigin.Begin); fs.WriteValueS32(item.Index1, Endianness); fs.Seek(array2Base + 4 * item.Index1, SeekOrigin.Begin); fs.WriteValueS32(item.Index2.Unknown1, Endianness); if (content.Array2ItemSize == 3) { fs.WriteValueS32(item.Index2.Unknown2, Endianness); } fs.WriteValueS32(stringOffset, Endianness); fs.Seek(stringsBase + stringOffset, SeekOrigin.Begin); var tfString = strings[i]; var str = tfString.Original; if (tfString.Visible && !string.IsNullOrEmpty(str)) { str = tfString.Translation; } if (options.CharReplacement != 0) { str = Utils.ReplaceChars(str, options.CharReplacementList); } str = SRRProject.WritingReplacements(str); var length = str.GetLength(options.SelectedEncoding); fs.WriteValueS32(length, Endianness); fs.WriteStringZ(str, options.SelectedEncoding); stringOffset = (int)(fs.Position - stringsBase); while (fs.Position % 4 != 0) { fs.WriteValueU8(0); stringOffset++; } } while (fs.Position % 16 != 0) { fs.WriteValueU8(0); } var contentSize = (int)(fs.Position - 0x20); fs.WriteBytes(_root.Ending); WriteHeader(fs, contentSize); } }