Beispiel #1
0
        /// <summary>
        /// Read a TEXT file into memory.
        /// </summary>
        /// <param name="input">A readable stream of a TEXT file.</param>
        public TEXT(Stream input)
        {
            using (var br = new BinaryReaderX(input))
            {
                // TEXT Header
                _textHeader = br.ReadType <TEXTHeader>();

                // Text Group Metadata
                var groupMetadata = br.ReadMultiple <TextGroupMetadata>(_textHeader.EntryCount);

                // Read Strings
                foreach (var group in groupMetadata)
                {
                    br.BaseStream.Position = group.NameOffset;
                    var name = br.ReadCStringASCII();

                    br.BaseStream.Position = group.EntryOffset;
                    var offsets = br.ReadMultiple <int>(group.EntryCount);

                    var lines = new List <string>();
                    foreach (var offset in offsets)
                    {
                        br.BaseStream.Position = offset;
                        var length = br.ReadCStringASCII().Length;
                        br.BaseStream.Position = offset;
                        lines.Add(br.ReadString(length, Encoding.GetEncoding(1252)));
                    }

                    Entries.Add(new TextEntry
                    {
                        Name       = name,
                        EditedText = string.Join("\n", lines)
                    });
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Creates a new blank TEXT file.
 /// </summary>
 public TEXT()
 {
     _textHeader = new TEXTHeader();
 }