Beispiel #1
0
        static uint WriteImpl(MemoryPool memory, Button button)
        {
            var buttonMemory = memory.AllocatePadded(Constants.IntPtrSize * 16, Constants.IntPtrSize);

            using (var buttonWriter = GetWriter(buttonMemory))
            {
                buttonWriter.Write((UInt32)CharacterType.Button);
                buttonWriter.Write((UInt32)Character.SIGNATURE);
                buttonWriter.WriteBooleanUInt32(button.IsMenu);
                buttonWriter.Write((Vector4)button.Bounds);

                buttonWriter.Write((UInt32)button.Triangles.Length);
                buttonWriter.Write((UInt32)button.Vertices.Length);
                var verticesAddress  = ArrayWriter.WritePlainArray(memory, button.Vertices);
                var trianglesAddress = ArrayWriter.WritePlainArray(memory, button.Triangles);
                buttonWriter.Write((UInt32)verticesAddress);
                buttonWriter.Write((UInt32)trianglesAddress);

                buttonWriter.Write((UInt32)button.Records.Count);
                var recordsAddress = ArrayWriter.WritePlainArray(memory, button.Records);
                buttonWriter.Write((UInt32)recordsAddress);

                buttonWriter.Write((UInt32)button.Actions.Count);
                var actionsAddress = ArrayWriter.WritePlainArray(memory, button.Actions);
                buttonWriter.Write((UInt32)actionsAddress);

                buttonWriter.Write((UInt32)0);
            }

            return(buttonMemory.StartAddress);
        }
Beispiel #2
0
        static uint WriteImpl(MemoryPool memory, Text text)
        {
            var textMemory = memory.AllocatePadded(Constants.IntPtrSize * 15, Constants.IntPtrSize);

            using (var textWriter = GetWriter(textMemory))
            {
                textWriter.Write((UInt32)CharacterType.Text);
                textWriter.Write((UInt32)Character.SIGNATURE);
                textWriter.Write((RectangleF)text.Bounds);
                textWriter.Write((UInt32)text.Font);
                textWriter.Write((UInt32)text.Alignment);
                textWriter.Write((ColorRgba)text.Color);
                textWriter.Write((Single)text.FontHeight);
                textWriter.WriteBooleanUInt32(text.ReadOnly);
                textWriter.WriteBooleanUInt32(text.Multiline);
                textWriter.WriteBooleanUInt32(text.WordWrap);

                var contentAddress = Write(memory, text.Content);
                textWriter.Write((UInt32)contentAddress);

                var textAddress = Write(memory, text.Value);
                textWriter.Write((UInt32)textAddress);
            }

            return(textMemory.StartAddress);
        }
Beispiel #3
0
        static uint WriteImpl(MemoryPool memory, PlaceObject placeObject)
        {
            var placeObjectMemory = memory.AllocatePadded(Constants.IntPtrSize * 16, Constants.IntPtrSize);

            using (var placeObjectWriter = GetWriter(placeObjectMemory))
            {
                placeObjectWriter.Write((UInt32)FrameItemType.PlaceObject);
                placeObjectWriter.Write((UInt32)placeObject.Flags);
                placeObjectWriter.Write((Int32)placeObject.Depth);
                placeObjectWriter.Write((Int32)placeObject.Character);
                placeObjectWriter.Write((Matrix2x2)placeObject.RotScale);
                placeObjectWriter.Write((Vector2)placeObject.Translation);
                placeObjectWriter.Write((ColorRgba)placeObject.Color);
                placeObjectWriter.Write((UInt32)0); // unknown
                placeObjectWriter.Write((Single)placeObject.Ratio);

                var nameAddress = placeObject.Flags.HasFlag(PlaceObjectFlags.HasName) ? Write(memory, placeObject.Name) : 0;
                placeObjectWriter.Write((UInt32)nameAddress);

                placeObjectWriter.Write((Int32)placeObject.ClipDepth);

                var clipEventArrayAddress = placeObject.Flags.HasFlag(PlaceObjectFlags.HasClipAction) ? WriteClipEventArray(memory, placeObject.ClipEvents) : 0;
                placeObjectWriter.Write((UInt32)clipEventArrayAddress);
            }
            return(placeObjectMemory.StartAddress);
        }
Beispiel #4
0
        static uint WriteImpl(MemoryPool memory, BackgroundColor backgroundColor)
        {
            var backgroundColorMemory = memory.AllocatePadded(Constants.IntPtrSize * 2, Constants.IntPtrSize);

            using (var backgroundColorWriter = GetWriter(backgroundColorMemory))
            {
                backgroundColorWriter.Write((UInt32)FrameItemType.BackgroundColor);
                backgroundColorWriter.Write((ColorRgba)backgroundColor.Color);
            }
            return(backgroundColorMemory.StartAddress);
        }
Beispiel #5
0
        static uint WriteImpl(MemoryPool memory, RemoveObject removeObject)
        {
            var removeObjectMemory = memory.AllocatePadded(Constants.IntPtrSize * 2, Constants.IntPtrSize);

            using (var removeObjectWriter = GetWriter(removeObjectMemory))
            {
                removeObjectWriter.Write((UInt32)FrameItemType.RemoveObject);
                removeObjectWriter.Write((Int32)removeObject.Depth);
            }
            return(removeObjectMemory.StartAddress);
        }
Beispiel #6
0
        static uint WriteImpl(MemoryPool memory, Shape shape)
        {
            var shapeMemory = memory.AllocatePadded(Constants.IntPtrSize * 7, Constants.IntPtrSize);

            using (var shapeWriter = GetWriter(shapeMemory)) {
                shapeWriter.Write((UInt32)CharacterType.Shape);
                shapeWriter.Write((UInt32)Character.SIGNATURE);
                shapeWriter.Write((Vector4)shape.Bounds);
                shapeWriter.Write((UInt32)shape.Geometry);
            }
            return(shapeMemory.StartAddress);
        }
Beispiel #7
0
        static uint WriteImpl(MemoryPool memory, Movie movie)
        {
            var importsAddress = ArrayWriter.WritePlainArray(memory, movie.Imports);
            var exportsAddress = ArrayWriter.WritePlainArray(memory, movie.Exports);

            if (movie.Characters.First() != movie)
            {
                throw new ArgumentException("Shouldn't the first element of character array be movie itself?");
            }
            var characterArrayBegin = memory.AllocatePadded(Constants.IntPtrSize, Constants.IntPtrSize);
            var otherCharacters     = movie.Characters.Skip(1).ToList();

            ArrayWriter.WriteArrayOfPointers(memory, otherCharacters);

            var movieMemory = memory.AllocatePadded(Constants.IntPtrSize * 15, Constants.IntPtrSize);

            using (var movieWriter = GetWriter(movieMemory))
            {
                movieWriter.Write((UInt32)CharacterType.Movie);
                movieWriter.Write((UInt32)Character.SIGNATURE);
                movieWriter.Write((UInt32)movie.Frames.Count);
                movieWriter.Write((UInt32)ArrayWriter.WritePlainArray(memory, movie.Frames));
                movieWriter.Write((UInt32)0); // pointer
                movieWriter.Write((UInt32)movie.Characters.Count);
                movieWriter.Write((UInt32)characterArrayBegin.StartAddress);
                movieWriter.Write((UInt32)movie.ScreenWidth);
                movieWriter.Write((UInt32)movie.ScreenHeight);
                movieWriter.Write((UInt32)movie.MillisecondsPerFrame);
                movieWriter.Write((UInt32)movie.Imports.Count);
                movieWriter.Write((UInt32)importsAddress);
                movieWriter.Write((UInt32)movie.Exports.Count);
                movieWriter.Write((UInt32)exportsAddress);
                movieWriter.Write((UInt32)0); // count
            }
            var entryOffset = movieMemory.StartAddress;

            BitConverter.GetBytes((UInt32)entryOffset).CopyTo(characterArrayBegin.Memory, 0);
            return(entryOffset);
        }
Beispiel #8
0
        static uint WriteImpl(MemoryPool memory, Image image)
        {
            var imageMemory = memory.AllocatePadded(Constants.IntPtrSize * 3, Constants.IntPtrSize);

            using (var imageWriter = GetWriter(imageMemory))
            {
                imageWriter.Write((UInt32)CharacterType.Image);
                imageWriter.Write((UInt32)Character.SIGNATURE);
                imageWriter.Write((UInt32)image.TextureID);
            }

            return(imageMemory.StartAddress);
        }
Beispiel #9
0
        static uint WriteClipEventArray(MemoryPool memory, ICollection <ClipEvent> clipEvents)
        {
            var clipEventArrayMemory = memory.AllocatePadded(Constants.IntPtrSize * 2, Constants.IntPtrSize);

            using (var clipEventArrayWriter = GetWriter(clipEventArrayMemory))
            {
                clipEventArrayWriter.Write((UInt32)clipEvents.Count);

                var arrayAddress = ArrayWriter.WritePlainArray(memory, clipEvents);
                clipEventArrayWriter.Write((UInt32)arrayAddress);
            }
            return(clipEventArrayMemory.StartAddress);
        }
Beispiel #10
0
        static uint WriteImpl(MemoryPool memory, Action action)
        {
            var actionMemory = memory.AllocatePadded(Constants.IntPtrSize * 2, Constants.IntPtrSize);

            using (var actionWriter = GetWriter(actionMemory))
            {
                actionWriter.Write((UInt32)FrameItemType.Action);

                var instructionStartAddress = Write(memory, action.Instructions);
                actionWriter.Write((UInt32)instructionStartAddress);
            }
            return(actionMemory.StartAddress);
        }
Beispiel #11
0
        static uint WriteImpl(MemoryPool memory, InitAction initAction)
        {
            var initActionMemory = memory.AllocatePadded(Constants.IntPtrSize * 3, Constants.IntPtrSize);

            using (var initActionWriter = GetWriter(initActionMemory))
            {
                initActionWriter.Write((UInt32)FrameItemType.InitAction);
                initActionWriter.Write((UInt32)initAction.Sprite);

                var instructionStartAddress = Write(memory, initAction.Instructions);
                initActionWriter.Write((UInt32)instructionStartAddress);
            }
            return(initActionMemory.StartAddress);
        }
Beispiel #12
0
        static uint WriteImpl(MemoryPool memory, FrameLabel label)
        {
            var labelMemory = memory.AllocatePadded(Constants.IntPtrSize * 4, Constants.IntPtrSize);

            using (var labelWriter = GetWriter(labelMemory))
            {
                labelWriter.Write((UInt32)FrameItemType.FrameLabel);

                var labelNameAddress = Write(memory, label.Name);
                labelWriter.Write((UInt32)labelNameAddress);
                labelWriter.Write((UInt32)label.Flags);
                labelWriter.Write((UInt32)label.FrameId);
            }
            return(labelMemory.StartAddress);
        }
Beispiel #13
0
        static uint WriteImpl(MemoryPool memory, Sprite sprite)
        {
            var spriteMemory = memory.AllocatePadded(Constants.IntPtrSize * 5, Constants.IntPtrSize);

            using (var spriteWriter = GetWriter(spriteMemory))
            {
                spriteWriter.Write((UInt32)CharacterType.Sprite);
                spriteWriter.Write((UInt32)Character.SIGNATURE);

                spriteWriter.Write((UInt32)sprite.Frames.Count);
                var framesAddress = ArrayWriter.WritePlainArray(memory, sprite.Frames);
                spriteWriter.Write((UInt32)framesAddress);

                spriteWriter.Write((UInt32)0); // pointer
            }
            return(spriteMemory.StartAddress);
        }
Beispiel #14
0
        static uint WriteImpl(MemoryPool memory, Font font)
        {
            var fontMemory = memory.AllocatePadded(Constants.IntPtrSize * 5, Constants.IntPtrSize);

            using (var fontWriter = GetWriter(fontMemory))
            {
                fontWriter.Write((UInt32)CharacterType.Font);
                fontWriter.Write((UInt32)Character.SIGNATURE);

                var nameAddress = Write(memory, font.Name);
                fontWriter.Write((UInt32)nameAddress);

                fontWriter.Write((UInt32)font.Glyphs.Count);
                var glyphsAddress = ArrayWriter.WritePlainArray(memory, font.Glyphs);
                fontWriter.Write((UInt32)glyphsAddress);
            }

            return(fontMemory.StartAddress);
        }