Ejemplo n.º 1
0
 public void Serialize(GMDataWriter writer)
 {
     writer.Write(1);
     Sequence.Serialize(writer);
 }
Ejemplo n.º 2
0
        public void Serialize(GMDataWriter writer)
        {
            writer.WritePointerString(Name);
            writer.Write(Width);
            writer.Write(Height);
            writer.Write(MarginLeft);
            writer.Write(MarginRight);
            writer.Write(MarginBottom);
            writer.Write(MarginTop);
            writer.WriteWideBoolean(Transparent);
            writer.WriteWideBoolean(Smooth);
            writer.WriteWideBoolean(Preload);
            writer.Write(BBoxMode);
            writer.Write((int)SepMasks);
            writer.Write(OriginX);
            writer.Write(OriginY);

            if (SpecialOrGMS2)
            {
                // Special/GMS2 sprite type
                writer.Write(-1);
                if (writer.VersionInfo.IsNumberAtLeast(2, 3, 2))
                {
                    writer.Write(3);
                }
                else if (writer.VersionInfo.IsNumberAtLeast(2, 3))
                {
                    writer.Write(2);
                }
                else
                {
                    writer.Write(1);
                }
                writer.Write((int)S_SpriteType);
                if (writer.VersionInfo.IsNumberAtLeast(2))
                {
                    writer.Write(GMS2_PlaybackSpeed);
                    writer.Write((int)GMS2_PlaybackSpeedType);
                    if (writer.VersionInfo.IsNumberAtLeast(2, 3))
                    {
                        writer.WritePointer(GMS2_3_Sequence);
                        if (writer.VersionInfo.IsNumberAtLeast(2, 3, 2))
                        {
                            writer.WritePointer(GMS2_3_2_NineSlice);
                        }
                    }
                }

                switch (S_SpriteType)
                {
                case SpriteType.Normal:
                    TextureItems.Serialize(writer);
                    WriteMaskData(writer);
                    break;

                case SpriteType.SWF:
                    writer.Write(8);
                    TextureItems.Serialize(writer);
                    writer.Pad(4);
                    writer.Write(S_Buffer);
                    break;

                case SpriteType.Spine:
                    writer.Pad(4);
                    writer.Write(S_Buffer);
                    break;
                }

                if (GMS2_3_Sequence != null)
                {
                    writer.Pad(4);
                    writer.WriteObjectPointer(GMS2_3_Sequence);
                    GMS2_3_Sequence.Serialize(writer);
                }

                if (GMS2_3_2_NineSlice != null)
                {
                    writer.Pad(4);
                    writer.WriteObjectPointer(GMS2_3_2_NineSlice);
                    GMS2_3_2_NineSlice.Serialize(writer);
                }
            }
            else
            {
                // Normal sprite type
                TextureItems.Serialize(writer);
                WriteMaskData(writer);
            }
        }
Ejemplo n.º 3
0
 public void Serialize(GMDataWriter writer)
 {
     writer.WriteInt24(0);
     writer.Write((byte)Type);
 }
Ejemplo n.º 4
0
                public void Serialize(GMDataWriter writer)
                {
                    if (Variable != null)
                    {
                        if (Variable.Target != null)
                        {
                            List <int> l;
                            if (writer.VariableReferences.TryGetValue(Variable.Target, out l))
                            {
                                l.Add(writer.Offset);
                            }
                            else
                            {
                                writer.VariableReferences.Add(Variable.Target, new List <int> {
                                    writer.Offset
                                });
                            }
                        }
                        else
                        {
                            writer.Warnings.Add(new GMWarning($"Missing variable target at {writer.Offset}"));
                        }
                    }
                    else if (Function != null)
                    {
                        if (Function.Target != null)
                        {
                            List <int> l;
                            if (writer.FunctionReferences.TryGetValue(Function.Target, out l))
                            {
                                l.Add(writer.Offset);
                            }
                            else
                            {
                                writer.FunctionReferences.Add(Function.Target, new List <int> {
                                    writer.Offset
                                });
                            }
                        }
                        else
                        {
                            writer.Warnings.Add(new GMWarning($"Missing function target at {writer.Offset}"));
                        }
                    }

                    switch (GetInstructionType(Kind))
                    {
                    case InstructionType.SingleType:
                    case InstructionType.DoubleType:
                    case InstructionType.Comparison:
                    {
                        writer.Write(Extra);
                        if (writer.VersionInfo.FormatID <= 14 && Kind == Opcode.Cmp)
                        {
                            writer.Write((byte)0);
                        }
                        else
                        {
                            writer.Write((byte)ComparisonKind);
                        }
                        writer.Write((byte)((byte)Type2 << 4 | (byte)Type1));
                        if (writer.VersionInfo.FormatID <= 14)
                        {
                            writer.Write(NewOpcodeToOld((byte)Kind, (byte)ComparisonKind));
                        }
                        else
                        {
                            writer.Write((byte)Kind);
                        }
                    }
                    break;

                    case InstructionType.Branch:
                    {
                        if (writer.VersionInfo.FormatID <= 14)
                        {
                            writer.WriteInt24(JumpOffset);
                        }
                        else if (PopenvExitMagic)
                        {
                            writer.WriteInt24(0xF00000);
                        }
                        else
                        {
                            writer.WriteInt24((int)((uint)JumpOffset & ~0xFF800000));
                        }

                        if (writer.VersionInfo.FormatID <= 14)
                        {
                            writer.Write(NewOpcodeToOld((byte)Kind, 0));
                        }
                        else
                        {
                            writer.Write((byte)Kind);
                        }
                    }
                    break;

                    case InstructionType.Pop:
                    {
                        if (Type1 == DataType.Int16)
                        {
                            writer.Write((short)TypeInst);
                            writer.Write((byte)((byte)Type2 << 4 | (byte)Type1));
                            if (writer.VersionInfo.FormatID <= 14)
                            {
                                writer.Write(NewOpcodeToOld((byte)Kind, 0));
                            }
                            else
                            {
                                writer.Write((byte)Kind);
                            }
                        }
                        else
                        {
                            writer.Write((short)TypeInst);
                            writer.Write((byte)((byte)Type2 << 4 | (byte)Type1));
                            if (writer.VersionInfo.FormatID <= 14)
                            {
                                writer.Write(NewOpcodeToOld((byte)Kind, 0));
                            }
                            else
                            {
                                writer.Write((byte)Kind);
                            }
                            Variable.Serialize(writer);
                        }
                    }
                    break;

                    case InstructionType.Push:
                    {
                        if (Type1 == DataType.Int16)
                        {
                            writer.Write((short)Value);
                        }
                        else if (Type1 == DataType.Variable)
                        {
                            writer.Write((short)TypeInst);
                        }
                        else
                        {
                            writer.Write((short)0);
                        }
                        writer.Write((byte)Type1);

                        if (writer.VersionInfo.FormatID <= 14)
                        {
                            writer.Write(NewOpcodeToOld((byte)Kind, 0));
                        }
                        else
                        {
                            writer.Write((byte)Kind);
                        }

                        switch (Type1)
                        {
                        case DataType.Double:
                            writer.Write((double)Value);
                            break;

                        case DataType.Float:
                            writer.Write((float)Value);
                            break;

                        case DataType.Int32:
                            if (Function != null)
                            {
                                Function.Serialize(writer);
                                break;
                            }
                            writer.Write((int)Value);
                            break;

                        case DataType.Int64:
                            writer.Write((long)Value);
                            break;

                        case DataType.Boolean:
                            writer.WriteWideBoolean((bool)Value);
                            break;

                        case DataType.Variable:
                            Variable.Serialize(writer);
                            break;

                        case DataType.String:
                            writer.Write((int)Value);             // string ID
                            break;
                            //case DataType.Int16:
                            //    break;
                        }
                    }
                    break;

                    case InstructionType.Call:
                    {
                        writer.Write((short)Value);
                        writer.Write((byte)Type1);
                        if (writer.VersionInfo.FormatID <= 14)
                        {
                            writer.Write(NewOpcodeToOld((byte)Kind, 0));
                        }
                        else
                        {
                            writer.Write((byte)Kind);
                        }
                        Function.Serialize(writer);
                    }
                    break;

                    case InstructionType.Break:
                    {
                        writer.Write((ushort)Value);
                        writer.Write((byte)Type1);
                        if (writer.VersionInfo.FormatID <= 14)
                        {
                            writer.Write(NewOpcodeToOld((byte)Kind, 0));
                        }
                        else
                        {
                            writer.Write((byte)Kind);
                        }
                    }
                    break;

                    default:
                        throw new Exception("Unknown opcode " + Kind.ToString());
                    }
                }
Ejemplo n.º 5
0
 public void Serialize(GMDataWriter writer)
 {
     writer.WritePointerString(Name);
     writer.WritePointer(Item);
 }
Ejemplo n.º 6
0
        public void Serialize(GMDataWriter writer)
        {
            writer.WritePointerString(Name);
            writer.WritePointerString(Caption);
            writer.Write(Width); writer.Write(Height);
            writer.Write(Speed);
            writer.WriteWideBoolean(Persistent);
            writer.Write(BackgroundColor);
            writer.WriteWideBoolean(DrawBackgroundColor);
            writer.Write(CreationCodeID);
            int flags = (int)Flags;

            if (writer.VersionInfo.IsNumberAtLeast(2, 3))
            {
                flags |= 0x30000;
            }
            else if (writer.VersionInfo.IsNumberAtLeast(2))
            {
                flags |= 0x20000;
            }
            writer.Write(flags);
            writer.WritePointer(Backgrounds);
            writer.WritePointer(Views);
            writer.WritePointer(GameObjects);
            writer.WritePointer(Tiles);
            writer.WriteWideBoolean(Physics);
            writer.Write(Top); writer.Write(Left);
            writer.Write(Right); writer.Write(Bottom);
            writer.Write(GravityX); writer.Write(GravityY);
            writer.Write(PixelsToMeters);
            int sequencePatch = -1;

            if (writer.VersionInfo.IsNumberAtLeast(2))
            {
                writer.WritePointer(Layers);
                if (writer.VersionInfo.IsNumberAtLeast(2, 3))
                {
                    sequencePatch = writer.Offset;
                    writer.Write(0);
                }
            }

            writer.WriteObjectPointer(Backgrounds);
            Backgrounds.Serialize(writer);
            writer.WriteObjectPointer(Views);
            Views.Serialize(writer);
            writer.WriteObjectPointer(GameObjects);
            GameObjects.Serialize(writer);
            writer.WriteObjectPointer(Tiles);
            Tiles.Serialize(writer);
            if (writer.VersionInfo.IsNumberAtLeast(2))
            {
                writer.WriteObjectPointer(Layers);
                Layers.Serialize(writer);
                if (writer.VersionInfo.IsNumberAtLeast(2, 3))
                {
                    // Patch and write sequence IDs
                    int returnTo = writer.Offset;
                    writer.Offset = sequencePatch;
                    writer.Write(returnTo);
                    writer.Offset = returnTo;

                    writer.Write(SequenceIDs.Count);
                    foreach (int i in SequenceIDs)
                    {
                        writer.Write(i);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public override void Serialize(GMDataWriter writer)
        {
            base.Serialize(writer);

            List.Serialize(writer);
        }
Ejemplo n.º 8
0
 public void Serialize(GMDataWriter writer)
 {
     writer.Write((int)Kind);
     writer.WritePointerString(Name);
     writer.WritePointerString(Value);
 }
Ejemplo n.º 9
0
 public void Serialize(GMDataWriter writer)
 {
     writer.WritePointerString(EffectType);
     Properties.Serialize(writer);
 }
Ejemplo n.º 10
0
 public void Serialize(GMDataWriter writer)
 {
     writer.Write(Subtype);
     Actions.Serialize(writer);
 }
Ejemplo n.º 11
0
 public void Serialize(GMDataWriter writer)
 {
     writer.Write(X);
     writer.Write(Y);
 }