예제 #1
0
        internal void ToSwf(SwfWriter w)
        {
            w.AppendBits(0, 2); // reserved
            w.AppendBit(IsSyncStop);
            w.AppendBit(IsSyncNoMultiple);
            w.AppendBit(HasEnvelope);
            w.AppendBit(HasLoops);
            w.AppendBit(HasOutPoint);
            w.Align();

            if (HasInPoint)
            {
                w.AppendUI32(InPoint);
            }
            if (HasOutPoint)
            {
                w.AppendUI32(OutPoint);
            }
            if (HasLoops)
            {
                w.AppendUI16(LoopCount);
            }
            if (HasEnvelope)
            {
                w.AppendByte((byte)LoopCount);
                uint count = (uint)EnvelopeRecords.Length;
                for (int i = 0; i < EnvelopeRecords.Length; i++)
                {
                    w.AppendUI32(EnvelopeRecords[i].Pos44);
                    w.AppendUI16(EnvelopeRecords[i].LeftLevel);
                    w.AppendUI16(EnvelopeRecords[i].RightLevel);
                }
            }
        }
예제 #2
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBits(0, 4);
            switch (PlaybackSoundRate)
            {
            case 55000:
                w.AppendBits(0, 2);
                break;

            case 11000:
                w.AppendBits(1, 2);
                break;

            case 22000:
                w.AppendBits(2, 2);
                break;

            case 44000:
                w.AppendBits(3, 2);
                break;
            }
            w.AppendBit(PlaybackSoundSize == 16u);
            w.AppendBit(IsStereo);
            w.AppendBits((uint)StreamSoundCompression, 4);

            switch (StreamSoundRate)
            {
            case 55000:
                w.AppendBits(0, 2);
                break;

            case 11000:
                w.AppendBits(1, 2);
                break;

            case 22000:
                w.AppendBits(2, 2);
                break;

            case 44000:
                w.AppendBits(3, 2);
                break;
            }
            w.AppendBit(StreamSoundSize == 16u);
            w.AppendBit(StreamIsStereo);
            w.Align();

            w.AppendUI16(StreamSoundSampleCount);

            if (StreamSoundCompression == SoundCompressionType.MP3)
            {
                w.AppendUI16(LatencySeek);
            }

            w.ResetLongTagLength(this.TagType, start);
        }
예제 #3
0
        internal void ToSwf(SwfWriter w)
        {
            w.AppendBits(0, 2);
            w.AppendBit(ButtonHasBlendMode);
            w.AppendBit(ButtonHasFilterList);
            w.AppendBit(ButtonStateHitTest);
            w.AppendBit(ButtonStateDown);
            w.AppendBit(ButtonStateOver);
            w.AppendBit(ButtonStateUp);

            w.AppendUI16(CharacterID);
            w.AppendUI16(PlaceDepth);
            PlaceMatrix.ToSwf(w);

            if (containerTag == TagType.DefineButton2)
            {
                ColorTransform.ToSwf(w, true);

                if (ButtonHasFilterList)
                {
                    w.AppendByte((byte)FilterList.Count);
                    for (int i = 0; i < FilterList.Count; i++)
                    {
                        FilterList[i].ToSwf(w);
                    }
                }
                if (ButtonHasBlendMode)
                {
                    w.AppendByte((byte)BlendMode);
                }
            }
        }
예제 #4
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.DefineFunction);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(FunctionName);
            w.AppendUI16((uint)Params.Length);
            for (int i = 0; i < Params.Length; i++)
            {
                w.AppendString(Params[i]);
            }

            w.AppendUI16(CodeSize); // temp
            long startPos = w.Position;

            for (int i = 0; i < Statements.Count; i++)
            {
                Statements[i].ToSwf(w);
            }

            // adjust code size
            long curPos = w.Position;

            if (codeSize != (curPos - startPos))
            {
                codeSize   = (uint)(curPos - startPos);
                w.Position = startPos - 2;
                w.AppendUI16(CodeSize); // acutal
                w.Position = curPos;
            }
        }
예제 #5
0
        internal override void ToSwf(SwfWriter w)
        {
            if (this.CompressionMode == CompressionType.ZLIB)
            {
                w.AppendByte((byte)'C');
            }
            else if (this.CompressionMode == CompressionType.LZMA)
            {
                w.AppendByte((byte)'Z');
            }
            else
            {
                w.AppendByte((byte)'F');
            }
            w.AppendByte((byte)'W');
            w.AppendByte((byte)'S');

            w.AppendByte(this.Version);

            w.AppendUI32(this.FileLength);
            this.FrameSize.ToSwf(w);

            ushort frateWhole = (ushort)this.FrameRate;
            uint   frateDec   = (((uint)this.FrameRate * 0x100) & 0xFF);

            w.AppendUI16((uint)((frateWhole << 8) + frateDec));

            w.AppendUI16(this.FrameCount);
        }
예제 #6
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(ButtonId);
            w.AppendBits(0, 7);
            w.AppendBit(TrackAsMenu);
            w.AppendUI16(ActionOffset); // todo: calc offset

            for (int i = 0; i < Characters.Count; i++)
            {
                Characters[i].ToSwf(w);
            }
            w.AppendByte(0);

            if (ActionOffset > 0)
            {
                ButtonCondActions[ButtonCondActions.Count - 1].CondActionSize = 0;
                for (int i = 0; i < ButtonCondActions.Count; i++)
                {
                    ButtonCondActions[i].ToSwf(w);
                }
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
예제 #7
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.WaitForFrame);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendUI16((uint)Frame);
            w.AppendByte((byte)SkipCount);
        }
예제 #8
0
        internal void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBit(HasClipActions);
            w.AppendBit(HasClipDepth);
            w.AppendBit(HasName);
            w.AppendBit(HasRatio);
            w.AppendBit(HasColorTransform);
            w.AppendBit(HasMatrix);
            w.AppendBit(HasCharacter);
            w.AppendBit(Move);

            w.AppendUI16(Depth);

            if (HasCharacter)
            {
                w.AppendUI16(Character);
            }
            if (HasMatrix)
            {
                Matrix.ToSwf(w);
            }
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, true);
            }
            if (HasRatio)
            {
                w.AppendUI16(Ratio);
            }
            if (HasName)
            {
                w.AppendString(Name);
            }
            if (HasClipDepth)
            {
                w.AppendUI16(ClipDepth);
            }

            if (HasClipActions)
            {
                ClipActions.ToSwf(w, isSwf6Plus);
            }

            //w.ResetLongTagLength(this.TagType, start, true);
            // this may be always long tag?
            if (HasClipActions || HasName)
            {
                w.ResetLongTagLength(this.TagType, start, true); // flash always makes long tags is clip actions are present
            }
            else
            {
                w.ResetLongTagLength(this.TagType, start);
            }
        }
예제 #9
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GotoFrame2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendBits(0, 6);
            w.AppendBit(SceneBiasFlag);
            w.AppendBit(PlayFlag);
            w.Align();
            if (SceneBiasFlag)
            {
                w.AppendUI16(SceneBias);
            }
        }
예제 #10
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterID);
            Bounds.ToSwf(w);

            w.AppendBit(HasText);
            w.AppendBit(WordWrap);
            w.AppendBit(Multiline);
            w.AppendBit(Password);
            w.AppendBit(ReadOnly);
            w.AppendBit(HasTextColor);
            w.AppendBit(HasMaxLength);
            w.AppendBit(HasFont);
            w.AppendBit(false);// resreved
            w.AppendBit(AutoSize);
            w.AppendBit(HasLayout);
            w.AppendBit(NoSelect);
            w.AppendBit(Border);
            w.AppendBit(false);// resreved
            w.AppendBit(HTML);
            w.AppendBit(UseOutlines);

            if (HasFont)
            {
                w.AppendUI16(FontID);
                w.AppendUI16(FontHeight);
            }
            if (HasTextColor)
            {
                w.AppendByte((byte)TextColor.R);
                w.AppendByte((byte)TextColor.G);
                w.AppendByte((byte)TextColor.B);
                w.AppendByte((byte)TextColor.A);
            }
            if (HasMaxLength)
            {
                w.AppendUI16(MaxLength);
            }
            if (HasLayout)
            {
                w.AppendByte((byte)Align);
                w.AppendUI16(LeftMargin);
                w.AppendUI16(RightMargin);
                w.AppendUI16(Indent);
                w.AppendUI16((uint)Leading);
            }

            w.AppendString(VariableName);

            if (HasText)
            {
                w.AppendString(InitialText);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
예제 #11
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16((uint)Exports.Count);
            foreach (uint index in Exports.Keys)
            {
                w.AppendUI16(index);
                w.AppendString(Exports[index]);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
예제 #12
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterId);

            if (!HasAlphaData)
            {
                if (!HasOwnTable)
                {
                    w.AppendByte(0xFF);
                    w.AppendByte(0xD8);

                    w.AppendBytes(JpegData);

                    w.AppendByte(0xFF);
                    w.AppendByte(0xD9);
                }
                else
                {
                    w.AppendBytes(JpegData);
                }
            }
            else
            {
                w.AppendUI32((uint)JpegData.Length);
                w.AppendBytes(JpegData);

                w.AppendBytes(CompressedAlphaData);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
예제 #13
0
        internal override void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendUI16(this.Width);
            w.AppendBits((uint)this.StartCapStyle, 2);
            w.AppendBits((uint)this.JoinStyle, 2);
            w.AppendBit(this.HasFillFlag);
            w.AppendBit(this.NoHScaleFlag);
            w.AppendBit(this.NoVScaleFlag);
            w.AppendBit(this.PixelHintingFlag);
            w.AppendBits(0, 5);
            w.AppendBit(this.NoClose);
            w.AppendBits((uint)this.EndCapStyle, 2);

            if (this.JoinStyle == JoinStyle.MiterJoin)
            {
                w.AppendFixed8_8(this.MiterLimitFactor);
            }

            if (this.HasFillFlag)
            {
                this.FillStyle.ToSwf(w);
            }
            else
            {
                w.AppendByte(Color.R);
                w.AppendByte(Color.G);
                w.AppendByte(Color.B);
                if (useAlpha)
                {
                    w.AppendByte(Color.A);
                }
            }
        }
예제 #14
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(this.Character);
            w.AppendUI16(this.Depth);
            Matrix.ToSwf(w);
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, false);
            }

            w.ResetLongTagLength(this.TagType, start);
        }
예제 #15
0
        internal void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            if ((uint)ClipEvents == 0)
            {
                if (isSwf6Plus)
                {
                    w.AppendUI32(0);
                }
                else
                {
                    w.AppendUI16(0);
                }
            }
            else
            {
                w.AppendBits((uint)ClipEvents, 32);

                uint start = (uint)w.Position;
                w.AppendUI32(0);                 // write len after tag written

                if ((ClipEvents & ClipEvents.KeyPress) > 0)
                {
                    w.AppendByte(KeyCode);
                }
                ActionRecords.ToSwf(w);

                uint end = (uint)w.Position;
                w.Position = start;
                w.AppendUI32(end - start - 4);
                w.Position = end;
            }
        }
예제 #16
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GoToLabel);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(Label);
        }
예제 #17
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.Jump);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendInt16(BranchOffset);
        }
예제 #18
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.StoreRegister);
            w.AppendUI16(Length - 3); // don't incude this part

            w.AppendByte((byte)Register);
        }
예제 #19
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.With);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            // todo: ctor missing
        }
예제 #20
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.SetTarget);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(TargetName);
        }
예제 #21
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GetURL);
            w.AppendUI16(Length - 3);// don't incude this part

            w.AppendString(UrlString);
            w.AppendString(TargetString);
        }
예제 #22
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterId);
            w.AppendUI16(FrameCount);

            for (int i = 0; i < ControlTags.Count; i++)
            {
                ControlTags[i].ToSwf(w);
            }

            // note: Flash always writes this as a long tag.
            w.ResetLongTagLength(this.TagType, start, true);
        }
예제 #23
0
        internal void ToSwf(SwfWriter w, uint glyphBits, uint advanceBits, bool hasAlpha)
        {
            w.AppendBit(_TextRecordType);
            w.AppendBits(_StyleFlagsReserved, 3);
            w.AppendBit(StyleFlagsHasFont);
            w.AppendBit(StyleFlagsHasColor);
            w.AppendBit(StyleFlagsHasYOffset);
            w.AppendBit(StyleFlagsHasXOffset);
            w.Align();

            if (StyleFlagsHasFont)
            {
                w.AppendUI16(FontID);
            }
            if (StyleFlagsHasColor)
            {
                w.AppendByte(TextColor.R);
                w.AppendByte(TextColor.G);
                w.AppendByte(TextColor.B);
                if (hasAlpha)
                {
                    w.AppendByte(TextColor.A);
                }
            }
            if (StyleFlagsHasXOffset)
            {
                w.AppendInt16(XOffset);
            }
            if (StyleFlagsHasYOffset)
            {
                w.AppendInt16(YOffset);
            }
            if (StyleFlagsHasFont)
            {
                w.AppendUI16(TextHeight);
            }

            w.AppendByte((byte)GlyphEntries.Length);

            for (int i = 0; i < GlyphEntries.Length; i++)
            {
                w.AppendBits(GlyphEntries[i].GlyphIndex, glyphBits);
                w.AppendSignedNBits(GlyphEntries[i].GlyphAdvance, advanceBits);
            }
            w.Align();
        }
예제 #24
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.DefineFunction2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(FunctionName);
            w.AppendUI16((uint)Parameters.Count);
            w.AppendByte((byte)RegisterCount);

            w.AppendBit((Preloads & PreloadFlags.Parent) > 0);
            w.AppendBit((Preloads & PreloadFlags.Root) > 0);
            w.AppendBit(SuppressSuperFlag);
            w.AppendBit((Preloads & PreloadFlags.Super) > 0);
            w.AppendBit(SuppressArgumentsFlag);
            w.AppendBit((Preloads & PreloadFlags.Arguments) > 0);
            w.AppendBit(SuppressThisFlag);
            w.AppendBit((Preloads & PreloadFlags.This) > 0);
            w.AppendBits(0, 7);
            w.AppendBit((Preloads & PreloadFlags.Global) > 0);

            foreach (KeyValuePair <uint, string> d in Parameters)
            {
                w.AppendByte((byte)d.Key);
                w.AppendString(d.Value);
            }

            w.AppendUI16(ActionContainer.CodeSize); // temp
            long startPos = w.Position;

            for (int i = 0; i < ActionContainer.Statements.Count; i++)
            {
                ActionContainer.Statements[i].ToSwf(w);
            }

            // adjust code size
            long curPos = w.Position;

            if (ActionContainer.codeSize != (curPos - startPos))
            {
                ActionContainer.codeSize = (uint)(curPos - startPos);
                w.Position = startPos - 2;
                w.AppendUI16(ActionContainer.CodeSize); // acutal
                w.Position = curPos;
            }
        }
예제 #25
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(ButtonId);

            w.AppendUI16(ButtonSoundChar0);
            ButtonSoundInfo0.ToSwf(w);
            w.AppendUI16(ButtonSoundChar1);
            ButtonSoundInfo1.ToSwf(w);
            w.AppendUI16(ButtonSoundChar2);
            ButtonSoundInfo2.ToSwf(w);
            w.AppendUI16(ButtonSoundChar3);
            ButtonSoundInfo3.ToSwf(w);

            w.ResetLongTagLength(this.TagType, start, true);
        }
예제 #26
0
파일: Push.cs 프로젝트: Screeder/GameFiles
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.Push);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            for (int i = 0; i < Values.Count; i++)
            {
                Values[i].ToSwf(w);
            }
        }
예제 #27
0
        internal void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            w.AppendUI16(0);             // reserved
            w.AppendBits((uint)ClipEvents, 32);

            for (int i = 0; i < ClipActionRecords.Count; i++)
            {
                ClipActionRecords[i].ToSwf(w, isSwf6Plus);
            }
        }
예제 #28
0
        internal override void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GetURL2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendBits((uint)SendVarsMethod, 2);
            w.AppendBits(0, 4);
            w.AppendBit(TargetIsSprite);
            w.AppendBit(LoadVariables);
            w.Align();
        }
예제 #29
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(SampleCount);
            w.AppendBytes(SoundData);

            w.ResetLongTagLength(this.TagType, start);
        }
예제 #30
0
        internal override void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(SoundId);
            SoundInfo.ToSwf(w);

            w.ResetLongTagLength(this.TagType, start, true);
        }