Ejemplo n.º 1
0
Ogre::OverlayContainer *GUIHelper::findContainer(Ogre::OverlayContainer *overlay,
			const Ogre::String subStrName)
{
	ASSERT(overlay);

	std::queue<Ogre::OverlayContainer *> q;
	q.push(overlay);

	Ogre::OverlayContainer *parent = 0;
	while(!q.empty()){
		parent = q.back();
		q.pop();
		if(parent->getName().find(subStrName) != Ogre::String::npos){
			// we find it
			return parent;
		}
		// else we have to iterate over all the children an put it in the queue
		Ogre::OverlayContainer *child = 0;
		Ogre::OverlayContainer::ChildIterator it = parent->getChildIterator();
		while(it.hasMoreElements()){
			child = static_cast<Ogre::OverlayContainer *>(it.peekNextValue());
			if(!child){
				break;
			}
			// else we put it in the queue
			q.push(child);
			it.moveNext();
		}

	}

	return 0;
}
Ejemplo n.º 2
0
void GUIHelper::fullDestroyOverlayElement(Ogre::OverlayContainer *elem)
{
	ASSERT(elem);

	Ogre::OverlayManager &om = Ogre::OverlayManager::getSingleton();

	Ogre::OverlayContainer::ChildIterator it = elem->getChildIterator();
	Ogre::OverlayContainer *child = 0;

	// TODO: cuidado aca que podemos estar teniendo SIGSEV si tenemos
	// muchos overlays anidados, deberiamos guardarlos capaz en un container
	// y luego liberar todos de una como en la funcion de arriba
	while(it.hasMoreElements()){
		child = static_cast<Ogre::OverlayContainer *>(it.peekNextValue());
		if(!child){
			break;
		}
		// else.. we have to configure this child with the parent size and
		// position
		fullDestroyOverlayElement(child);
		it.moveNext();
	}

	destroyMaterial(elem->getMaterialName());
	om.destroyOverlayElement(elem);
}
Ejemplo n.º 3
0
/**
 * Ugly but fast recursively function used to reposition the overlaycontainer
 */
void GUIHelper::reposContainer(Ogre::OverlayContainer *o,
		Ogre::Real parentX, Ogre::Real parentY, Ogre::Real parentHeight,
		Ogre::Real parentWidth)
{
	ASSERT(o);
	ASSERT(parentX >= 0.0f && parentX <= 1.0f);
	ASSERT(parentY >= 0.0f && parentY <= 1.0f);
	ASSERT(parentHeight >= 0.0f && parentHeight <= 1.0f);
	ASSERT(parentWidth >= 0.0f && parentWidth <= 1.0f);

//	debugBLUE("Configuring new container: \n"
//			"Top: %f, Left:%f, Width:%f, Height:%f\n"
//			"Parent: %f,%f,%f,%f\n",
//			o->getTop(), o->getLeft(), o->getWidth(), o->getHeight(),
//			parentY, parentX, parentWidth, parentHeight);

	// configure this container
	// size
	ASSERT( o->getHeight() >= 0.0f &&  o->getHeight() <= 1.0f);
	ASSERT(o->getWidth() >= 0.0f && o->getWidth() <= 1.0f);
	o->setHeight(parentHeight * o->getHeight());
	o->setWidth(parentWidth * o->getWidth());

	// position
	ASSERT(o->getTop() >= 0.0f && o->getTop() <= 1.0f);
	ASSERT(o->getLeft() >= 0.0f && o->getLeft() <= 1.0f);
	o->setTop((o->getTop() * parentHeight));
	o->setLeft((o->getLeft() * parentWidth));


	Ogre::OverlayContainer::ChildIterator it = o->getChildIterator();
	Ogre::OverlayContainer *child = 0;
	while(it.hasMoreElements()){
		child = static_cast<Ogre::OverlayContainer *>(it.peekNextValue());
		if(!child){
			return;
		}
		// else.. we have to configure this child with the parent size and
		// position
		reposContainer(child, o->getLeft(), o->getTop(), o->getHeight(),
				o->getWidth());

		it.moveNext();
	}
}
Ejemplo n.º 4
0
void GUIHelper::getChildrens(Ogre::OverlayContainer *elem,
		std::vector<Ogre::OverlayContainer *> &ch)
{
	ASSERT(elem);
	ch.clear();

	Ogre::OverlayContainer::ChildIterator it = elem->getChildIterator();
	Ogre::OverlayContainer *child = 0;
	while(it.hasMoreElements()){
		child = static_cast<Ogre::OverlayContainer *>(it.peekNextValue());
		if(!child){
			break;
		}
		ch.push_back(child);
		it.moveNext();
	}

}