public IObject(LWF lwf, Movie parent, Type type, int objId, int instId) : base(lwf, parent, type, objId) { m_prevInstance = null; m_nextInstance = null; m_linkInstance = null; m_instanceId = (instId >= lwf.data.instanceNames.Length) ? -1 : (int)instId; if (m_instanceId >= 0) { int stringId = lwf.GetInstanceNameStringId(m_instanceId); m_name = stringId == -1 ? null : lwf.data.strings[stringId]; IObject head = m_lwf.GetInstance(m_instanceId); if (head != null) head.m_prevInstance = this; m_nextInstance = head; m_lwf.SetInstance(m_instanceId, this); } }
public void SetInstance(int instId, IObject instance) { m_instances[instId] = instance; }
public void PostExec(bool progressing, bool force) { m_hasButton = false; if (!m_active) return; m_execedFrame = -1; bool postExeced = m_postExecCount == m_lwf.execCount; if (force || 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, p.blendMode); } 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, p.blendMode); } 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, p.blendMode); } 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, p.blendMode); } break; case Format.Control.Type.MOVEMCB: { Format.ControlMoveMCB ctrl = data.controlMoveMCBs[control.controlId]; Format.Place p = data.places[ctrl.placeId]; ExecObject(p.depth, p.objectId, ctrl.matrixId, ctrl.colorTransformId, p.instanceId, ctrl.blendMode, true); } 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(); } instance = m_instanceHead; while (instance != null) { if (instance.IsMovie()) { Movie movie = (Movie)instance; movie.PostExec(progressing && m_playing, force); if (!m_hasButton && movie.m_hasButton) m_hasButton = true; } instance = instance.linkInstance; } m_attachMoviePostExeced = true; 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 && m_playing, force); if (!m_hasButton && movie.m_hasButton) m_hasButton = true; } } } if (m_attachedLWFs != null) m_hasButton = true; if (!m_postLoaded) { m_postLoaded = true; #if LWF_USE_LUA if (m_isRoot && !String.IsNullOrEmpty(m_rootPostLoadFunc)) lwf.CallFunctionLua(m_rootPostLoadFunc, this); if (m_postLoadFunc != String.Empty) lwf.CallFunctionLua(m_postLoadFunc, this); #endif 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; } #if LWF_USE_LUA if (m_isRoot && !String.IsNullOrEmpty(m_rootEnterFrameFunc)) lwf.CallFunctionLua(m_rootEnterFrameFunc, this); if (m_enterFrameFunc != String.Empty) lwf.CallFunctionLua(m_enterFrameFunc, this); #endif PlayAnimation(ClipEvent.ENTERFRAME); if (!m_handler.Empty()) m_handler.Call(EventType.ENTERFRAME, this); m_postExecCount = m_lwf.execCount; }
public Movie(LWF lwf, Movie parent, int objId, int instId, int matrixId = 0, int colorTransformId = 0, bool attached = false, MovieEventHandlers handler = null, string n = null) : base(lwf, parent, attached ? Type.ATTACHEDMOVIE : Type.MOVIE, objId, instId) { m_data = lwf.data.movies[objId]; m_matrixId = matrixId; m_colorTransformId = colorTransformId; m_totalFrames = m_data.frames; if (!String.IsNullOrEmpty(n)) m_name = n; m_instanceHead = null; m_instanceTail = null; m_currentFrameInternal = -1; m_execedFrame = -1; m_animationPlayedFrame = -1; m_lastControlOffset = -1; m_lastControls = -1; m_lastHasButton = false; m_lastControlAnimationOffset = -1; m_skipped = false; m_postLoaded = false; m_active = true; m_visible = true; m_playing = true; m_jumped = false; m_overriding = false; m_attachMovieExeced = false; m_attachMoviePostExeced = false; m_movieExecCount = -1; m_postExecCount = -1; m_blendMode = (int)Constant.BLEND_MODE_NORMAL; m_requestedCalculateBounds = false; m_calculateBoundsCallback = null; m_property = new Property(lwf); m_matrix0 = new Matrix(); m_matrix1 = new Matrix(); m_matrixForAttachedLWFs = new Matrix(); m_colorTransform0 = new ColorTransform(); m_colorTransform1 = new ColorTransform(); m_colorTransformForAttachedLWFs = new ColorTransform(); m_displayList = new Object[m_data.depths]; m_eventHandlers = new EventHandlers(); m_handler = new MovieEventHandlers(); m_handler.Add(lwf.GetMovieEventHandlers(this)); m_handler.Add(handler); #if LWF_USE_LUA m_isRoot = objId == lwf.data.header.rootMovieId; if (m_isRoot) { if (parent == null) lwf.CallFunctionLua("Init", this); lwf.GetFunctionsLua(objId, out m_rootLoadFunc, out m_rootPostLoadFunc, out m_rootUnloadFunc, out m_rootEnterFrameFunc, true); } lwf.GetFunctionsLua(objId, out m_loadFunc, out m_postLoadFunc, out m_unloadFunc, out m_enterFrameFunc, false); if (m_isRoot && !String.IsNullOrEmpty(m_rootLoadFunc)) lwf.CallFunctionLua(m_rootLoadFunc, this); if (m_loadFunc != String.Empty) lwf.CallFunctionLua(m_loadFunc, this); #endif PlayAnimation(ClipEvent.LOAD); if (!m_handler.Empty()) m_handler.Call(EventType.LOAD, this); lwf.ExecMovieCommand(); }
private void ExecObject(int dlDepth, int objId, int matrixId, int colorTransformId, int instId, int dlBlendMode, bool updateBlendMode = false) { // Ignore error if (objId == -1) return; Data data = m_lwf.data; Format.Object dataObject = data.objects[objId]; int dataObjectId = dataObject.objectId; Object obj = m_displayList[dlDepth]; if (obj != null && (obj.type != (Type)dataObject.objectType || obj.objectId != dataObjectId || (obj.IsMovie() && ((IObject)obj).instanceId != instId))) { if (m_texts != null && obj.IsText()) EraseText(obj.objectId); obj.Destroy(); obj = null; } if (obj == null) { switch ((Type)dataObject.objectType) { case Type.BUTTON: obj = new Button(m_lwf, this, dataObjectId, instId, matrixId, colorTransformId); break; case Type.GRAPHIC: obj = new Graphic(m_lwf, this, dataObjectId); break; case Type.MOVIE: obj = new Movie(m_lwf, this, dataObjectId, instId, matrixId, colorTransformId); ((Movie)obj).blendMode = dlBlendMode; break; case Type.BITMAP: obj = new Bitmap(m_lwf, this, dataObjectId); break; case Type.BITMAPEX: obj = new BitmapEx(m_lwf, this, dataObjectId); break; case Type.TEXT: obj = new Text(m_lwf, this, dataObjectId, instId); break; case Type.PARTICLE: obj = new Particle(m_lwf, this, dataObjectId); break; case Type.PROGRAMOBJECT: obj = new ProgramObject(m_lwf, this, dataObjectId); break; } } if (obj.IsMovie() && updateBlendMode) ((Movie)obj).blendMode = dlBlendMode; if (obj.IsMovie() || obj.IsButton()) { IObject instance = (IObject)obj; instance.linkInstance = null; if (m_instanceHead == null) m_instanceHead = instance; else m_instanceTail.linkInstance = instance; m_instanceTail = instance; if (obj.IsButton()) m_hasButton = true; } if (m_texts != null && obj.IsText()) InsertText(obj.objectId); m_displayList[dlDepth] = obj; obj.execCount = m_movieExecCount; obj.Exec(matrixId, colorTransformId); }
public Movie(LWF lwf, Movie parent, int objId, int instId, int matrixId = 0, int colorTransformId = 0, bool attached = false, MovieEventHandlers handler = null) : base(lwf, parent, attached ? Type.ATTACHEDMOVIE : Type.MOVIE, objId, instId) { m_data = lwf.data.movies[objId]; m_matrixId = matrixId; m_colorTransformId = colorTransformId; m_totalFrames = m_data.frames; m_instanceHead = null; m_instanceTail = null; m_currentFrameInternal = -1; m_execedFrame = -1; m_animationPlayedFrame = -1; m_lastControlOffset = -1; m_lastControls = -1; m_lastHasButton = false; m_lastControlAnimationOffset = -1; m_skipped = false; m_postLoaded = false; m_active = true; m_visible = true; m_playing = true; m_jumped = false; m_overriding = false; m_attachMovieExeced = false; m_attachMoviePostExeced = false; m_movieExecCount = -1; m_postExecCount = -1; m_property = new Property(lwf); m_matrix0 = new Matrix(); m_matrix1 = new Matrix(); m_colorTransform0 = new ColorTransform(); m_colorTransform1 = new ColorTransform(); m_displayList = new Object[m_data.depths]; PlayAnimation(ClipEvent.LOAD); m_eventHandlers = new EventHandlerDictionary(); m_handler.Add(lwf.GetMovieEventHandlers(this)); m_handler.Add(handler); if (m_handler != null) m_handler.Call(EventType.LOAD, this); lwf.ExecMovieCommand(); }