Пример #1
0
        private static Dialog ParseScript(DataStream strIn, int num)
        {
            DataReader reader = new DataReader(strIn);

            // Read the FAT entry
            strIn.Seek(4 + num * 0x8, SeekMode.Origin);
            ushort id = reader.ReadUInt16();

            reader.ReadUInt16();    // Length
            uint offset = reader.ReadUInt32();

            // Read num of subelements
            strIn.Seek(offset, SeekMode.Origin);
            uint elements = reader.ReadUInt32();

            // At the moment, read only text entries, skip the first 3 entries
            Dialog dialog = new Dialog(id);

            for (int i = 3; i < elements; i += 2)
            {
                // Firstly it's the dialog name ID
                strIn.Seek(offset + 4 + i * 4, SeekMode.Origin);          // Go to block
                strIn.Seek(offset + reader.ReadUInt32(), SeekMode.Origin);
                string dialogId = reader.ReadString();

                // Then, the text
                strIn.Seek(offset + 4 + (i + 1) * 4, SeekMode.Origin);    // Go to block
                strIn.Seek(offset + reader.ReadUInt32(), SeekMode.Origin);

                List <ushort> dialogData = new List <ushort>();
                ushort        value      = reader.ReadUInt16();
                while (value != 0x8000 && value != 0xFFFF && value != 0x0000)
                {
                    dialogData.Add(value);
                    value = reader.ReadUInt16();
                }

                dialog.AddUnparsedText(dialogId, dialogData.ToArray());
            }

            return(dialog);
        }