public static void readEnglishZTR() { String[] allfiles = System.IO.Directory.GetFiles(@"C:\LR\HRW", "*_us.ztr", System.IO.SearchOption.AllDirectories); foreach (var file in allfiles) { Stream fs = File.OpenRead(file); FFXIIITextEncoding encoding = FFXIIITextEncodingFactory.CreateEuro(); ZtrFileUnpacker unpacker = new ZtrFileUnpacker(fs, encoding); ZtrFileEntry[] entries = unpacker.Unpack(); String outputfile = file.Substring(0, file.Length - 4) + ".txt"; using (FileStream fs2 = File.OpenWrite(outputfile)) { StreamWriter sw = new StreamWriter(fs2); foreach (ZtrFileEntry entry in entries) { sw.WriteLine(""); if (entry.IsAnimatedText) { sw.WriteLine(entry.Key + " | " + entry.Value + " | Is Animated? " + entry.IsAnimatedText); } else { sw.WriteLine(entry.Key + " | " + entry.Value); } } sw.Flush(); sw.Close(); } } }
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 void Extract(ArchiveEntry entry, StreamSequence output, Stream input, Byte[] buff) { int size = (int)entry.UncompressedSize; if (size == 0) { return; } ZtrFileUnpacker unpacker = new ZtrFileUnpacker(input, InteractionService.TextEncoding.Provide().Encoding); ZtrFileEntry[] entries = unpacker.Unpack(); ZtrTextWriter writer = new ZtrTextWriter(output, StringsZtrFormatter.Instance); writer.Write(entry.Name, entries); }
public void Show(ArchiveListing listing, ArchiveEntry entry) { _listing = listing; _entry = entry; if (listing == null || entry == null) { _textBox.Text = null; return; } FFXIIITextEncoding encoding = InteractionService.TextEncoding.Provide().Encoding; ZtrFileEntry[] entries; using (Stream data = listing.Accessor.ExtractBinary(entry)) { ZtrFileUnpacker unpacker = new ZtrFileUnpacker(data, encoding); entries = unpacker.Unpack(); } if (entries.IsNullOrEmpty()) { return; } using (MemoryStream ms = new MemoryStream(4096)) { ZtrTextWriter writer = new ZtrTextWriter(ms, StringsZtrFormatter.Instance); writer.Write(entry.Name, entries); ms.Position = 0; using (StreamReader sr = new StreamReader(ms, System.Text.Encoding.UTF8, false)) _textBox.Text = sr.ReadToEnd(); } Visibility = Visibility.Visible; }