Esempio n. 1
0
/**
 * Get all the childrens of an overlay
 * @param	ov		The overlay where we will retreive the childrens
 * @param	ch		Childrens
 */
void GUIHelper::getChildrens(Ogre::Overlay *ov,
		std::vector<Ogre::OverlayContainer *> &ch)
{
	ASSERT(ov);
	ch.clear();

	Ogre::Overlay::Overlay2DElementsIterator bit = ov->get2DElementsIterator();
	Ogre::OverlayContainer *parent = 0;
	while(bit.hasMoreElements()){
		parent = bit.peekNext();
		if(!parent){
			break;
		}
		ch.push_back(parent);
		bit.moveNext();
	}
}
Esempio n. 2
0
Ogre::OverlayContainer *GUIHelper::findContainer(Ogre::Overlay *overlay,
		const Ogre::String subStrName)
{
	ASSERT(overlay);

	Ogre::Overlay::Overlay2DElementsIterator bit = overlay->get2DElementsIterator();
	std::queue<Ogre::OverlayContainer *> q;
	Ogre::OverlayContainer *parent = 0;
	while(bit.hasMoreElements()){
		parent = bit.peekNext();
		if(!parent){
			break;
		}
		q.push(parent);
		bit.moveNext();
	}

	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;
}
Esempio n. 3
0
void GUIHelper::fullDestroyOverlay(Ogre::Overlay *overlay)
{
	ASSERT(overlay);

	Ogre::Overlay::Overlay2DElementsIterator it = overlay->get2DElementsIterator();
	Ogre::OverlayManager &om = Ogre::OverlayManager::getSingleton();
	std::vector<Ogre::OverlayElement *> elements;

	Ogre::OverlayContainer *parent = 0;
	while(it.hasMoreElements()){
		parent = it.peekNext();
		if(!parent){
			break;
		}

		Ogre::OverlayContainer::ChildIterator it2 = parent->getChildIterator();
		Ogre::OverlayContainer *child = 0;
		while(it2.hasMoreElements()){
			child = static_cast<Ogre::OverlayContainer *>(it2.peekNextValue());
			if(!child){
				break;
			}
			// else.. delete the container
			fullDestroyOverlayElement(child);

			it2.moveNext();
		}

		elements.push_back(parent);
		it.moveNext();
	}
	for(int i = 0; i < elements.size(); ++i){
		destroyMaterial(elements[i]->getMaterialName());
		om.destroyOverlayElement(elements[i]);
	}

	om.destroy(overlay);
}
Esempio n. 4
0
/**
 * Bugfix for the nested overlay containers position. This function will
 * get a overlay and will iterate over all the (child) containers and will
 * set the new "relative" position
 * @param	overlay		The overlay to fix the childs positions
 */
void GUIHelper::fixOverlayPosition(Ogre::Overlay *overlay)
{
	ASSERT(overlay);

	Ogre::Overlay::Overlay2DElementsIterator it = overlay->get2DElementsIterator();

	Ogre::OverlayContainer *parent = 0;
	while(it.hasMoreElements()){
		parent = it.peekNext();
		if(!parent){
			break;
		}

		// else we have the parent... get the top left and sizes
		Ogre::Real top = parent->getTop();
		Ogre::Real left = parent->getLeft();
		Ogre::Real height = parent->getHeight();
		Ogre::Real width = parent->getWidth();


		Ogre::OverlayContainer::ChildIterator it2 = parent->getChildIterator();
		Ogre::OverlayContainer *child = 0;
		while(it2.hasMoreElements()){
			child = static_cast<Ogre::OverlayContainer *>(it2.peekNextValue());
			if(!child){
				break;
			}
			// else.. we have to configure this child with the parent size and
			// position
			reposContainer(child, left, top, height, width);

			it2.moveNext();
		}


		it.moveNext();
	}
}