Esempio n. 1
0
        public Movie AttachMovie(string linkageName, string attachName,
                                 int attachDepth          = -1, bool reorder = false,
                                 MovieEventHandler load   = null, MovieEventHandler postLoad   = null,
                                 MovieEventHandler unload = null, MovieEventHandler enterFrame = null,
                                 MovieEventHandler update = null, MovieEventHandler render     = null)
        {
            int movieId = m_lwf.SearchMovieLinkage(m_lwf.GetStringId(linkageName));

            if (movieId == -1)
            {
                return(null);
            }

            MovieEventHandlers handlers = new MovieEventHandlers();

            handlers.Add(load, postLoad, unload, enterFrame, update, render);
            Movie movie = new Movie(m_lwf, this, movieId, -1, 0, 0, true, handlers);

            if (m_attachMovieExeced)
            {
                movie.Exec();
            }
            if (m_attachMoviePostExeced)
            {
                movie.PostExec(true);
            }

            return(AttachMovieInternal(movie, attachName, attachDepth, reorder));
        }
Esempio n. 2
0
        public int Exec(float tick    = 0,
                        Matrix matrix = null, ColorTransform colorTransform = null)
        {
            bool  execed          = false;
            float currentProgress = m_progress;

            if (m_execDisabled && tweens == null)
            {
                if (!m_executedForExecDisabled)
                {
                    ++m_execCount;
                    m_rootMovie.Exec();
                    m_rootMovie.PostExec(true);
                    m_executedForExecDisabled = true;
                    execed = true;
                }
            }
            else
            {
                bool progressing = true;
                m_thisTick = tick;
                if (tick == 0)
                {
                    m_progress = m_tick;
                }
                else if (tick < 0)
                {
                    m_progress  = m_tick;
                    progressing = false;
                }
                else
                {
                    if (m_time == 0)
                    {
                        m_time     += (double)m_tick;
                        m_progress += m_tick;
                    }
                    else
                    {
                        m_time     += (double)tick;
                        m_progress += tick;
                    }
                }

                if (m_execHandlers != null)
                {
                    m_execHandlers.ForEach(h => h(this));
                }

                int execLimit = m_execLimit;
                while (m_progress >= m_tick - m_roundOffTick)
                {
                    if (--execLimit < 0)
                    {
                        m_progress = 0;
                        break;
                    }
                    m_progress -= m_tick;
                    ++m_execCount;
                    m_rootMovie.Exec();
                    m_rootMovie.PostExec(progressing);
                    execed = true;
                }

                if (m_progress < m_roundOffTick)
                {
                    m_progress = 0;
                }

                m_buttonHead = null;
                if (interactive && m_rootMovie.hasButton)
                {
                    m_rootMovie.LinkButton();
                }
            }

            if (execed || isLWFAttached ||
                isPropertyDirty || matrix != null || colorTransform != null)
            {
                Update(matrix, colorTransform);
            }

            if (!m_execDisabled)
            {
                if (tick < 0)
                {
                    m_progress = currentProgress;
                }
            }

            return(m_renderingCount);
        }
Esempio n. 3
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. 4
0
        public Movie AttachMovie(string linkageName, string attachName,
		int attachDepth = -1, bool reorder = false,
		MovieEventHandler load = null, MovieEventHandler postLoad = null,
		MovieEventHandler unload = null, MovieEventHandler enterFrame = null,
		MovieEventHandler update = null, MovieEventHandler render = null)
        {
            int movieId = m_lwf.SearchMovieLinkage(m_lwf.GetStringId(linkageName));
            if (movieId == -1)
            return null;

            MovieEventHandlers handlers = new MovieEventHandlers();
            handlers.Add(load, postLoad, unload, enterFrame, update, render);
            Movie movie = new Movie(m_lwf, this, movieId, -1, 0, 0, true, handlers);
            if (m_attachMovieExeced)
            movie.Exec();
            if (m_attachMoviePostExeced)
            movie.PostExec(true);

            return AttachMovieInternal(movie, attachName, attachDepth, reorder);
        }
Esempio n. 5
0
        public int ExecInternal(float tick)
        {
            if (m_rootMovie == null)
            {
                return(0);
            }
            bool  execed          = false;
            float currentProgress = m_progress;

            if (m_execDisabled && tweens == null)
            {
                if (!m_executedForExecDisabled)
                {
                    ++m_execCount;
                    m_rootMovie.Exec();
                    m_rootMovie.PostExec(true);
                    m_executedForExecDisabled = true;
                    execed = true;
                }
            }
            else
            {
                bool progressing = true;
                if (tick == 0)
                {
                    m_progress = m_tick;
                }
                else if (tick < 0)
                {
                    m_progress  = m_tick;
                    progressing = false;
                }
                else
                {
                    if (m_time == 0)
                    {
                        m_time     += (double)m_tick;
                        m_progress += m_tick;
                    }
                    else
                    {
                        m_time     += (double)tick;
                        m_progress += tick;
                    }
                }

                if (m_execHandlers != null)
                {
                    foreach (var h in m_execHandlers)
                    {
                        h(this);
                    }
                }

                int execLimit = m_execLimit;
                while (m_progress >= m_tick - m_roundOffTick)
                {
                    if (--execLimit < 0)
                    {
                        m_progress = 0;
                        break;
                    }
                    m_progress -= m_tick;
                    ++m_execCount;
                    m_rootMovie.Exec();
                    m_rootMovie.PostExec(progressing);
                    execed = true;
                    if (!m_frameSkip)
                    {
                        break;
                    }
                }

                if (m_progress < m_roundOffTick)
                {
                    m_progress = 0;
                }

                LinkButton();
            }

            if (isLWFAttached)
            {
                bool hasButton = m_rootMovie.ExecAttachedLWF(tick, currentProgress);
                if (hasButton)
                {
                    LinkButton();
                }
            }

            m_needsUpdate = false;
            if (!m_fastForward)
            {
                if (execed || m_propertyDirty || m_needsUpdateForAttachLWF)
                {
                    m_needsUpdate = true;
                }
            }

            if (!m_execDisabled)
            {
                if (tick < 0)
                {
                    m_progress = currentProgress;
                }
            }

            return(m_renderingCount);
        }