Exemple #1
0
        public System.IO.Stream WriteToScs(Endianness endian = Endianness.BigEndian, Bitness bits = Bitness.B32, GameTextEncoding encoding = GameTextEncoding.ShiftJIS)
        {
            System.IO.Stream stream     = new System.IO.MemoryStream();
            uint             entryCount = (uint)Entries.Count;

            stream.WriteUInt32(entryCount.ToEndian(endian));
            for (uint i = 0; i < entryCount; ++i)
            {
                stream.WriteUInt32(0);                 // reserve space
            }
            List <long> positions = new List <long>();

            for (uint i = 0; i < entryCount; ++i)
            {
                string s = Entries[(int)i];
                if (s != null)
                {
                    positions.Add(stream.Position);
                    stream.WriteNulltermString(s, encoding);
                }
                else
                {
                    positions.Add(0);
                }
            }
            stream.Position = 4;
            for (uint i = 0; i < entryCount; ++i)
            {
                stream.WriteUInt32(((uint)positions[(int)i]).ToEndian(endian));
            }
            stream.Position = 0;
            return(stream);
        }