コード例 #1
0
        public void Write(SwfWriter writer)
        {
            writer.ABC = this;
            var ver = Version;

            writer.WriteUInt16((ushort)ver.Minor);
            writer.WriteUInt16((ushort)ver.Major);
            if (ver.Major == CurrentMajor && ver.Minor == CurrentMinor)
            {
                IntPool.Write(writer);
                UIntPool.Write(writer);
                DoublePool.Write(writer);
                StringPool.Write(writer);
                Namespaces.Write(writer);
                NamespaceSets.Write(writer);
                Multinames.Write(writer);

                Methods.Write(writer);
                Metadata.Write(writer);

                int n = Instances.Count;
                writer.WriteUIntEncoded((uint)n);
                Instances.Write(writer);
                Classes.Write(writer);

                Scripts.Write(writer);
                MethodBodies.Write(writer);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
コード例 #2
0
ファイル: StringArray.cs プロジェクト: EIREXE/DIVA_Tools
        public override void Write(Stream destination)
        {
            var stringPool = new StringPool();

            stringPool.StringAlignment = 0x2;

            foreach (string value in strings)
            {
                stringPool.Add(destination, value);
            }

            DataStream.Pad(destination, 0x10);
            stringPool.Write(destination);
        }
コード例 #3
0
ファイル: AetDatabase.cs プロジェクト: Waelwindows/DIVA_Tools
        public override void Write(Stream destination)
        {
            destination.Seek(16, SeekOrigin.Begin);

            var stringPool1 = new StringPool();

            stringPool1.GroupAlignment = 0x10;

            long aetFileEntriesPosition = destination.Position;

            foreach (var entry in fileEntries)
            {
                DataStream.WriteUInt32(destination, entry.Id);
                stringPool1.Add(destination, entry.Name);
                stringPool1.Add(destination, entry.FileName);
                DataStream.WriteUInt32(destination, entry.Index);
                DataStream.WriteUInt32(destination, entry.SpriteId);
            }

            DataStream.Pad(destination, 0x10);

            var stringPool2 = new StringPool();

            stringPool2.GroupAlignment = 0x4;

            long aetEntriesPosition = destination.Position;

            foreach (var entry in entries)
            {
                DataStream.WriteUInt32(destination, entry.Id);
                stringPool2.Add(destination, entry.Name, entry.GroupId);
                DataStream.WriteUInt16(destination, entry.Index);
                DataStream.WriteUInt16(destination, entry.GroupId);
            }

            stringPool1.Write(destination);
            stringPool2.Write(destination);

            destination.Seek(0, SeekOrigin.Begin);
            DataStream.WriteUInt32(destination, (uint)fileEntries.Count);
            DataStream.WriteUInt32(destination, (uint)aetFileEntriesPosition);
            DataStream.WriteUInt32(destination, (uint)entries.Count);
            DataStream.WriteUInt32(destination, (uint)aetEntriesPosition);
        }
コード例 #4
0
        public void WriteEndTable()
        {
            if (status == Status.FieldCollection)
            {
                WriteEndFieldCollection();
            }

            if (status == Status.Row)
            {
                WriteEndRow();
            }

            status = Status.End;

            destination.Seek(headerPosition + header.RowsPosition + (header.RowLength * header.RowCount), SeekOrigin.Begin);

            stringPool.Write(destination);
            header.StringPoolPosition = (uint)stringPool.Position - headerPosition;

            DataStream.Pad(destination, vldPool.Align);

            vldPool.Write(destination);
            header.DataPoolPosition = (uint)vldPool.Position - headerPosition;

            DataStream.Pad(destination, vldPool.Align);

            long previousPosition = destination.Position;

            header.Length = (uint)destination.Position - headerPosition;

            if (settings.EncodingType == Encoding.GetEncoding("shift-jis"))
            {
                header.EncodingType = CriTableHeader.EncodingTypeShiftJis;
            }

            else if (settings.EncodingType == Encoding.UTF8)
            {
                header.EncodingType = CriTableHeader.EncodingTypeUtf8;
            }

            destination.Seek(headerPosition, SeekOrigin.Begin);

            destination.Write(CriTableHeader.SignatureBytes, 0, 4);
            DataStream.WriteUInt32BE(destination, header.Length - 8);
            DataStream.WriteByte(destination, header.UnknownByte);
            DataStream.WriteByte(destination, header.EncodingType);
            DataStream.WriteUInt16BE(destination, (ushort)(header.RowsPosition - 8));
            DataStream.WriteUInt32BE(destination, header.StringPoolPosition - 8);
            DataStream.WriteUInt32BE(destination, header.DataPoolPosition - 8);
            DataStream.WriteUInt32BE(destination, header.TableNamePosition);
            DataStream.WriteUInt16BE(destination, header.FieldCount);
            DataStream.WriteUInt16BE(destination, header.RowLength);
            DataStream.WriteUInt32BE(destination, header.RowCount);

            if (settings.EnableMask)
            {
                destination.Seek(headerPosition, SeekOrigin.Begin);
                CriTableMasker.Mask(destination, header.Length, settings.MaskXor, settings.MaskXorMultiplier);
            }

            destination.Seek(previousPosition, SeekOrigin.Begin);
        }