示例#1
0
文件: lwf_core.cpp 项目: ElAleyo/lwf
Button *LWF::SearchButtonInstanceByInstanceId(int instId) const
{
	if (instId < 0 || instId >= (int)m_instances.size())
		return 0;
	IObject *obj = m_instances[instId];
	while (obj) {
		if (obj->IsButton())
			return (Button *)obj;
		obj = obj->nextInstance;
	}
	return 0;
}
示例#2
0
文件: lwf_movie.cpp 项目: KitoHo/lwf
Button *Movie::SearchButtonInstanceByInstanceId(
	int instId, bool recursive) const
{
	for (IObject *instance = m_instanceHead; instance;
			instance = instance->linkInstance) {
		if (instance->IsButton() && instance->instanceId == instId) {
			return (Button *)instance;
		} else if (recursive && instance->IsMovie()) {
			Button *i = ((Movie *)instance)->SearchButtonInstanceByInstanceId(
				instId, recursive);
			if (i)
				return i;
		}
	}
	return 0;
}
示例#3
0
文件: lwf_movie.cpp 项目: KitoHo/lwf
Button *Movie::SearchButtonInstance(int stringId, bool recursive) const
{
	if (stringId == -1)
		return 0;

	for (IObject *instance = m_instanceHead; instance;
			instance = instance->linkInstance) {
		if (instance->IsButton() && lwf->GetInstanceNameStringId(
				instance->instanceId) == stringId) {
			return (Button *)instance;
		} else if (recursive && instance->IsMovie()) {
			Button *i = ((Movie *)instance)->SearchButtonInstance(
				stringId, recursive);
			if (i)
				return i;
		}
	}
	return 0;
}
示例#4
0
文件: lwf_movie.cpp 项目: KitoHo/lwf
void Movie::PostExec(bool progressing)
{
	hasButton = false;
	if (!active)
		return;

	m_execedFrame = -1;
	bool postExeced = m_postExecCount == lwf->execCount;
	if (progressing && playing && !m_jumped && !postExeced) {
		++m_currentFrameInternal;
		currentFrame = m_currentFrameInternal + 1;
	}
	for (;;) {
		if (m_currentFrameInternal < 0 ||
				m_currentFrameInternal >= totalFrames) {
			m_currentFrameInternal = 0;
			currentFrame = m_currentFrameInternal + 1;
		}
		if (m_currentFrameInternal == m_execedFrame)
			break;

		m_currentFrameCurrent = m_currentFrameInternal;
		m_execedFrame = m_currentFrameCurrent;
		const Data *d = lwf->data.get();
		const Format::Frame &frame = d->frames[
			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) {
					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;
				}
				hasButton = m_lastHasButton;
			} else {
				for (int dlDepth = 0; dlDepth < data->depths; ++dlDepth) {
					Object *obj = m_displayList[dlDepth].get();
					if (obj) {
						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();
							hasButton = true;
						}
					}
				}
				m_lastHasButton = hasButton;
				m_skipped = true;
			}

		} else {
			++m_movieExecCount;
			m_instanceHead = 0;
			m_instanceTail = 0;
			m_lastControlOffset = frame.controlOffset;
			m_lastControls = frame.controls;
			controlAnimationOffset = -1;
			for (int i = 0; i < frame.controls; ++i) {
				const Format::Control &control =
					d->controls[frame.controlOffset + i];

				switch (control.controlType) {
				case Format::Control::MOVE:
					{
						const Format::Place &p = d->places[control.controlId];
						ExecObject(p.depth, p.objectId,
							p.matrixId, 0, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::MOVEM:
					{
						const Format::ControlMoveM &ctrl =
							d->controlMoveMs[control.controlId];
						const Format::Place &p = d->places[ctrl.placeId];
						ExecObject(p.depth, p.objectId,
							ctrl.matrixId, 0, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::MOVEC:
					{
						const Format::ControlMoveC &ctrl =
							d->controlMoveCs[control.controlId];
						const Format::Place &p = d->places[ctrl.placeId];
						ExecObject(p.depth, p.objectId, p.matrixId,
							ctrl.colorTransformId, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::MOVEMC:
					{
						const Format::ControlMoveMC &ctrl =
							d->controlMoveMCs[control.controlId];
						const Format::Place &p = d->places[ctrl.placeId];
						ExecObject(p.depth, p.objectId, ctrl.matrixId,
							ctrl.colorTransformId, p.instanceId, p.blendMode);
					}
					break;

				case Format::Control::ANIMATION:
					if (controlAnimationOffset == -1)
						controlAnimationOffset = i;
					break;

				case Format::Control::CONTROL_MAX:
					// SUPPRESS WARNING
					break;
				}
			}

			m_lastControlAnimationOffset = controlAnimationOffset;
			m_lastHasButton = hasButton;

			for (int dlDepth = 0; dlDepth < data->depths; ++dlDepth) {
				Object *obj = m_displayList[dlDepth].get();
				if (obj && obj->execCount != m_movieExecCount) {
					if (m_texts && obj->IsText())
						EraseText(obj->objectId);
					obj->Destroy();
					m_displayList[dlDepth].reset();
				}
			}
		}

		m_attachMovieExeced = true;
		if (!m_attachedMovies.empty()) {
			AttachedMovieList::iterator it(m_attachedMovieList.begin()),
				itend(m_attachedMovieList.end());
			for (; it != itend; ++it)
				if (it->second)
					it->second->Exec();
		}

		m_attachMoviePostExeced = true;
		instance = m_instanceHead;
		while (instance) {
			if (instance->IsMovie()) {
				Movie *movie = (Movie *)instance;
				movie->PostExec(progressing);
				if (!hasButton && movie->hasButton)
					hasButton = true;
			}
			instance = instance->linkInstance;
		}

		if (!m_attachedMovies.empty()) {
			DetachDict::const_iterator
				dit(m_detachedMovies.begin()), ditend(m_detachedMovies.end());
			for (; dit != ditend; ++dit) {
				AttachedMovies::iterator it = m_attachedMovies.find(dit->first);
				if (it != m_attachedMovies.end())
					DeleteAttachedMovie(this, it->second, true, false);
			}
			m_detachedMovies.clear();

			AttachedMovieList::iterator it(m_attachedMovieList.begin()),
				itend(m_attachedMovieList.end());
			for (; it != itend; ++it) {
				if (it->second) {
					it->second->PostExec(progressing);
					if (!hasButton && it->second->hasButton)
						hasButton = true;
				}
			}
		}

		if (!m_attachedLWFs.empty())
			hasButton = true;

		if (!m_postLoaded) {
			m_postLoaded = true;
#if defined(LWF_USE_LUA)
			if (m_isRoot && !m_rootPostLoadFunc.empty())
				lwf->CallFunctionLua(m_rootPostLoadFunc, this);
			if (!m_postLoadFunc.empty())
				lwf->CallFunctionLua(m_postLoadFunc, this);
#endif
			if (!m_handler.Empty())
				m_handler.Call(METype::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) {
					const Format::Control &control =
						d->controls[frame.controlOffset + i];
					lwf->PlayAnimation(control.controlId, this);
				}
			}
		}

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

#if defined(LWF_USE_LUA)
	if (m_isRoot && !m_rootEnterFrameFunc.empty())
		lwf->CallFunctionLua(m_rootEnterFrameFunc, this);
	if (!m_enterFrameFunc.empty())
		lwf->CallFunctionLua(m_enterFrameFunc, this);
#endif
	PlayAnimation(ClipEvent::ENTERFRAME);
	if (!m_handler.Empty())
		m_handler.Call(METype::ENTERFRAME, this);
	m_postExecCount = lwf->execCount;
}