Esempio n. 1
0
        public void PostExec(bool progressing)
        {
            m_hasButton = false;
            if (!m_active)
            {
                return;
            }

            m_execedFrame = -1;
            bool postExeced = m_postExecCount == m_lwf.execCount;

            if (progressing && m_playing && !m_jumped && !postExeced)
            {
                ++m_currentFrameInternal;
            }
            for (;;)
            {
                if (m_currentFrameInternal < 0 ||
                    m_currentFrameInternal >= m_totalFrames)
                {
                    m_currentFrameInternal = 0;
                }
                if (m_currentFrameInternal == m_execedFrame)
                {
                    break;
                }

                m_currentFrameCurrent = m_currentFrameInternal;
                m_execedFrame         = m_currentFrameCurrent;
                Data         data  = m_lwf.data;
                Format.Frame frame = data.frames[
                    m_data.frameOffset + m_currentFrameCurrent];

                int     controlAnimationOffset;
                IObject instance;

                if (m_lastControlOffset == frame.controlOffset &&
                    m_lastControls == frame.controls)
                {
                    controlAnimationOffset = m_lastControlAnimationOffset;

                    if (m_skipped)
                    {
                        instance = m_instanceHead;
                        while (instance != null)
                        {
                            if (instance.IsMovie())
                            {
                                Movie movie = (Movie)instance;
                                movie.m_attachMovieExeced     = false;
                                movie.m_attachMoviePostExeced = false;
                            }
                            else if (instance.IsButton())
                            {
                                ((Button)instance).EnterFrame();
                            }
                            instance = instance.linkInstance;
                        }
                        m_hasButton = m_lastHasButton;
                    }
                    else
                    {
                        for (int dlDepth = 0; dlDepth < m_data.depths; ++dlDepth)
                        {
                            Object obj = m_displayList[dlDepth];
                            if (obj != null)
                            {
                                if (!postExeced)
                                {
                                    obj.matrixIdChanged         = false;
                                    obj.colorTransformIdChanged = false;
                                }
                                if (obj.IsMovie())
                                {
                                    Movie movie = (Movie)obj;
                                    movie.m_attachMovieExeced     = false;
                                    movie.m_attachMoviePostExeced = false;
                                }
                                else if (obj.IsButton())
                                {
                                    ((Button)obj).EnterFrame();
                                    m_hasButton = true;
                                }
                            }
                        }
                        m_lastHasButton = m_hasButton;
                        m_skipped       = true;
                    }
                }
                else
                {
                    ++m_movieExecCount;
                    m_instanceHead         = null;
                    m_instanceTail         = null;
                    m_lastControlOffset    = frame.controlOffset;
                    m_lastControls         = frame.controls;
                    controlAnimationOffset = -1;
                    for (int i = 0; i < frame.controls; ++i)
                    {
                        Format.Control control =
                            data.controls[frame.controlOffset + i];

                        switch ((Format.Control.Type)control.controlType)
                        {
                        case Format.Control.Type.MOVE:
                        {
                            Format.Place p =
                                data.places[control.controlId];
                            ExecObject(p.depth, p.objectId,
                                       p.matrixId, 0, p.instanceId);
                        }
                        break;

                        case Format.Control.Type.MOVEM:
                        {
                            Format.ControlMoveM ctrl =
                                data.controlMoveMs[control.controlId];
                            Format.Place p = data.places[ctrl.placeId];
                            ExecObject(p.depth, p.objectId,
                                       ctrl.matrixId, 0, p.instanceId);
                        }
                        break;

                        case Format.Control.Type.MOVEC:
                        {
                            Format.ControlMoveC ctrl =
                                data.controlMoveCs[control.controlId];
                            Format.Place p = data.places[ctrl.placeId];
                            ExecObject(p.depth, p.objectId, p.matrixId,
                                       ctrl.colorTransformId, p.instanceId);
                        }
                        break;

                        case Format.Control.Type.MOVEMC:
                        {
                            Format.ControlMoveMC ctrl =
                                data.controlMoveMCs[control.controlId];
                            Format.Place p = data.places[ctrl.placeId];
                            ExecObject(p.depth, p.objectId, ctrl.matrixId,
                                       ctrl.colorTransformId, p.instanceId);
                        }
                        break;

                        case Format.Control.Type.ANIMATION:
                            if (controlAnimationOffset == -1)
                            {
                                controlAnimationOffset = i;
                            }
                            break;
                        }
                    }

                    m_lastControlAnimationOffset = controlAnimationOffset;
                    m_lastHasButton = m_hasButton;

                    for (int dlDepth = 0; dlDepth < m_data.depths; ++dlDepth)
                    {
                        Object obj = m_displayList[dlDepth];
                        if (obj != null && obj.execCount != m_movieExecCount)
                        {
                            if (m_texts != null && obj.IsText())
                            {
                                EraseText(obj.objectId);
                            }
                            obj.Destroy();
                            m_displayList[dlDepth] = null;
                        }
                    }
                }

                m_attachMovieExeced = true;
                if (m_attachedMovies != null)
                {
                    foreach (Movie movie in m_attachedMovieList.Values)
                    {
                        if (movie != null)
                        {
                            movie.Exec();
                        }
                    }
                }

                m_attachMoviePostExeced = true;
                instance = m_instanceHead;
                while (instance != null)
                {
                    if (instance.IsMovie())
                    {
                        Movie movie = (Movie)instance;
                        movie.PostExec(progressing);
                        if (!m_hasButton && movie.m_hasButton)
                        {
                            m_hasButton = true;
                        }
                    }
                    instance = instance.linkInstance;
                }

                if (m_attachedMovies != null)
                {
                    foreach (KeyValuePair <string, bool> kvp in m_detachedMovies)
                    {
                        string attachName = kvp.Key;
                        Movie  movie;
                        if (m_attachedMovies.TryGetValue(attachName, out movie))
                        {
                            DeleteAttachedMovie(this, movie, true, false);
                        }
                    }
                    m_detachedMovies.Clear();
                    foreach (Movie movie in m_attachedMovieList.Values)
                    {
                        if (movie != null)
                        {
                            movie.PostExec(progressing);
                            if (!m_hasButton && movie.m_hasButton)
                            {
                                m_hasButton = true;
                            }
                        }
                    }
                }

                if (m_attachedLWFs != null)
                {
                    m_hasButton = true;
                }

                if (!m_postLoaded)
                {
                    m_postLoaded = true;
                    if (!m_handler.Empty())
                    {
                        m_handler.Call(EventType.POSTLOAD, this);
                    }
                }

                if (controlAnimationOffset != -1 &&
                    m_execedFrame == m_currentFrameInternal)
                {
                    bool animationPlayed = m_animationPlayedFrame ==
                                           m_currentFrameCurrent && !m_jumped;
                    if (!animationPlayed)
                    {
                        for (int i = controlAnimationOffset;
                             i < frame.controls; ++i)
                        {
                            Format.Control control =
                                data.controls[frame.controlOffset + i];
                            m_lwf.PlayAnimation(control.controlId, this);
                        }
                    }
                }

                m_animationPlayedFrame = m_currentFrameCurrent;
                if (m_currentFrameCurrent == m_currentFrameInternal)
                {
                    m_jumped = false;
                }
            }

            PlayAnimation(ClipEvent.ENTERFRAME);
            if (!m_handler.Empty())
            {
                m_handler.Call(EventType.ENTERFRAME, this);
            }
            m_postExecCount = m_lwf.execCount;
        }
Esempio n. 2
0
        public override void Update(Matrix m, ColorTransform c)
        {
            if (!m_active)
            {
                return;
            }

            bool matrixChanged;
            bool colorTransformChanged;

            if (m_overriding)
            {
                matrixChanged         = true;
                colorTransformChanged = true;
            }
            else
            {
                matrixChanged         = m_matrix.SetWithComparing(m);
                colorTransformChanged = m_colorTransform.SetWithComparing(c);
            }

            if (!m_handler.Empty())
            {
                m_handler.Call(EventType.UPDATE, this);
            }

            if (m_property.hasMatrix)
            {
                matrixChanged = true;
                m             = Utility.CalcMatrix(m_matrix0, m_matrix, m_property.matrix);
            }
            else
            {
                m = m_matrix;
            }

            if (m_property.hasColorTransform)
            {
                colorTransformChanged = true;
                c = Utility.CalcColorTransform(
                    m_colorTransform0, m_colorTransform, m_property.colorTransform);
            }
            else
            {
                c = m_colorTransform;
            }

            for (int dlDepth = 0; dlDepth < m_data.depths; ++dlDepth)
            {
                Object obj = m_displayList[dlDepth];
                if (obj != null)
                {
                    UpdateObject(obj, m, c, matrixChanged, colorTransformChanged);
                }
            }

            if (m_attachedMovies != null || m_attachedLWFs != null)
            {
                if (m_attachedMovies != null)
                {
                    foreach (Movie movie in m_attachedMovieList.Values)
                    {
                        if (movie != null)
                        {
                            UpdateObject(movie,
                                         m, c, matrixChanged, colorTransformChanged);
                        }
                    }
                }

                if (m_attachedLWFs != null)
                {
                    foreach (KeyValuePair <string, bool> kvp in m_detachedLWFs)
                    {
                        string       attachName = kvp.Key;
                        LWFContainer lwfContainer;
                        if (m_attachedLWFs.TryGetValue(
                                attachName, out lwfContainer))
                        {
                            DeleteAttachedLWF(this, lwfContainer, true, false);
                        }
                    }
                    m_detachedLWFs.Clear();
                    foreach (LWFContainer lwfContainer
                             in m_attachedLWFList.Values)
                    {
                        m_lwf.RenderObject(
                            lwfContainer.child.Exec(m_lwf.thisTick, m, c));
                    }
                }
            }
        }
Esempio n. 3
0
        public override void Update(Matrix m, ColorTransform c)
        {
            if (!m_active)
            {
                return;
            }

            if (m_overriding)
            {
                Utility.CopyMatrix(m_matrix, m_lwf.rootMovie.matrix);
                Utility.CopyColorTransform(
                    m_colorTransform, m_lwf.rootMovie.colorTransform);
            }
            else
            {
                Utility.CopyMatrix(m_matrix, m);
                Utility.CopyColorTransform(m_colorTransform, c);
            }

            if (m_handler != null)
            {
                m_handler.Call(EventType.UPDATE, this);
            }

            for (int dlDepth = 0; dlDepth < m_data.depths; ++dlDepth)
            {
                Object obj = m_displayList[dlDepth];
                if (obj != null)
                {
                    Matrix objm            = m_matrix0;
                    bool   objHasOwnMatrix =
                        obj.type == Type.MOVIE && ((Movie)obj).m_property.hasMatrix;
                    if (m_property.hasMatrix)
                    {
                        if (objHasOwnMatrix)
                        {
                            Utility.CalcMatrix(objm, m_matrix, m_property.matrix);
                        }
                        else
                        {
                            Utility.CalcMatrix(
                                m_matrix1, m_matrix, m_property.matrix);
                            Utility.CalcMatrix(
                                m_lwf, objm, m_matrix1, obj.matrixId);
                        }
                    }
                    else
                    {
                        if (objHasOwnMatrix)
                        {
                            Utility.CopyMatrix(objm, m_matrix);
                        }
                        else
                        {
                            Utility.CalcMatrix(m_lwf, objm, m_matrix, obj.matrixId);
                        }
                    }

                    ColorTransform objc = m_colorTransform0;
                    bool           objHasOwnColorTransform = obj.type == Type.MOVIE &&
                                                             ((Movie)obj).m_property.hasColorTransform;
                    if (m_property.hasColorTransform)
                    {
                        if (objHasOwnColorTransform)
                        {
                            Utility.CalcColorTransform(objc,
                                                       m_colorTransform, m_property.colorTransform);
                        }
                        else
                        {
                            Utility.CalcColorTransform(m_colorTransform1,
                                                       m_colorTransform, m_property.colorTransform);
                            Utility.CalcColorTransform(m_lwf,
                                                       objc, m_colorTransform1, obj.colorTransformId);
                        }
                    }
                    else
                    {
                        if (objHasOwnColorTransform)
                        {
                            Utility.CopyColorTransform(objc, m_colorTransform);
                        }
                        else
                        {
                            Utility.CalcColorTransform(m_lwf,
                                                       objc, m_colorTransform, obj.colorTransformId);
                        }
                    }

                    obj.Update(objm, objc);
                }
            }

            if (m_attachedMovies != null || m_attachedLWFs != null)
            {
                m = m_matrix;
                if (m_property.hasMatrix)
                {
                    Matrix m1 = m_matrix1.Set(m);
                    Utility.CalcMatrix(m, m1, m_property.matrix);
                }

                c = m_colorTransform;
                if (m_property.hasColorTransform)
                {
                    ColorTransform c1 = m_colorTransform1.Set(c);
                    Utility.CalcColorTransform(c, c1, m_property.colorTransform);
                }

                if (m_attachedMovies != null)
                {
                    foreach (Movie movie in m_attachedMovieList)
                    {
                        if (movie != null)
                        {
                            movie.Update(m, c);
                        }
                    }
                }

                if (m_attachedLWFs != null)
                {
                    foreach (KeyValuePair <string, bool> kvp in m_detachedLWFs)
                    {
                        string       attachName = kvp.Key;
                        LWFContainer lwfContainer;
                        if (m_attachedLWFs.TryGetValue(
                                attachName, out lwfContainer))
                        {
                            DeleteAttachedLWF(this, lwfContainer, true, false);
                        }
                    }
                    m_detachedLWFs.Clear();
                    foreach (LWFContainer lwfContainer in m_attachedLWFList)
                    {
                        m_lwf.RenderObject(
                            lwfContainer.child.Exec(m_lwf.thisTick, m, c));
                    }
                }
            }
        }