private void Inject(ArchiveListing listing, ArchiveEntry entry, Dictionary <String, String> sourceEntries, Stream output) { ZtrFileType type = ZtrFileType.LittleEndianUncompressedDictionary; ZtrFileEntry[] targetEntries; using (Stream original = listing.Accessor.ExtractBinary(entry)) { ZtrFileUnpacker unpacker = new ZtrFileUnpacker(original, InteractionService.TextEncoding.Provide().Encoding); targetEntries = unpacker.Unpack(); if (InteractionService.GamePart == FFXIIIGamePart.Part2) { if (entry.Name.StartsWith("txtres/resident/system/txtres_", StringComparison.InvariantCultureIgnoreCase)) { type = ZtrFileType.BigEndianCompressedDictionary; } } } MergeEntries(sourceEntries, targetEntries); ZtrFilePacker packer = new ZtrFilePacker(output, InteractionService.TextEncoding.Provide().Encoding, type); packer.Pack(targetEntries); }
public static void writetoZTR() { String[] allfiles = System.IO.Directory.GetFiles(@"C:\LR\ysn\", "*.txt", System.IO.SearchOption.AllDirectories); foreach (var file in allfiles) { int counter = 0; string line; List <ZtrFileEntry> entries = new List <ZtrFileEntry>(); System.IO.StreamReader filestream = new System.IO.StreamReader(file); while ((line = filestream.ReadLine()) != null) { string[] splitstring = line.Split(new[] { " | " }, StringSplitOptions.None); ZtrFileEntry lineentry = new ZtrFileEntry(); lineentry.IsAnimatedText = false; lineentry.Key = splitstring[0]; if (splitstring[1].Contains("#")) { lineentry.Value = ""; } else { if (splitstring[1].Contains("%")) { string[] deconstructedstring = splitstring[1].Split(new[] { "%" }, StringSplitOptions.None); //byte[] charsepbytes = new byte[] { 0, 0, 1, 0 }; //string characterseparator = Convert(charsepbytes); char charzero = '*'; char charone = '&'; string characterseparator = ""; StringBuilder builder = new StringBuilder(characterseparator); builder.Append(charzero); builder.Append(charone); System.Diagnostics.Debug.WriteLine(builder.ToString()); lineentry.Value = deconstructedstring[0] + builder.ToString() + deconstructedstring[1]; } else { lineentry.Value = splitstring[1]; } } entries.Add(lineentry); System.Diagnostics.Debug.WriteLine(splitstring[1]); } ZtrFileEntry[] ztrarray = entries.ToArray(); FFXIIITextEncoding encoding = FFXIIITextEncodingFactory.CreateEuro(); String outputfile = @"C:\LR\ysn\" + Path.GetFileName(file) + ".ztr"; using (FileStream fs2 = File.OpenWrite(outputfile)) { ZtrFilePacker packer = new ZtrFilePacker(fs2, encoding, ZtrFileType.BigEndianCompressedDictionary); packer.Pack(ztrarray); StreamWriter sw = new StreamWriter(fs2); sw.Flush(); sw.Close(); } } }