Exemplo 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;
}
void ResourceGroupReloader::visitRecursivelyRenderablesFrom(Ogre::OverlayContainer* pOverlayContainer, Ogre::Renderable::Visitor& pVisitor, bool debugRenderable)
{
	// call on 'this'
	pOverlayContainer->visitRenderables(&pVisitor,false);

	// call on 'leaf' (cf composite pattern)
	{
		Ogre::OverlayContainer::ChildIterator childIter = pOverlayContainer->getChildIterator();
		for(;childIter.hasMoreElements();)
		{
			Ogre::OverlayElement* lOverElem = childIter.getNext();
			lOverElem->visitRenderables(&pVisitor,false);
		}
	}

	// call on 'not-leaf' (cf composite pattern)
	{
		Ogre::OverlayContainer::ChildContainerIterator childContainerIter = pOverlayContainer->getChildContainerIterator();
		for(;childContainerIter.hasMoreElements();)
		{
			Ogre::OverlayContainer * childContainer = childContainerIter.getNext();
			visitRecursivelyRenderablesFrom(childContainer, pVisitor,debugRenderable);
		}
	}
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
GameplayScreen::~GameplayScreen()
{
	//Destroy our game objects
	delete mWhacker;
	for(unsigned int i=0; i<mDragons.size(); i++)
	{
		delete mDragons[i];
	}
	//Destroy all entities created
	Ogre::SceneManager* mSceneManager = Ogre::Root::getSingletonPtr()->getSceneManager("ApplicationSceneManager");
	mSceneManager->destroyEntity("Stage");
	//Remove the stage mesh
	mStageNode->removeAndDestroyAllChildren();
	mStageNode->getParentSceneNode()->removeAndDestroyChild(mStageNode->getName());
	//Destroy our score overlay
	//To do this, we must traverse all elements contained within
	//the overlay and remove them one at a time.
	Ogre::OverlayManager* overlayMgr = Ogre::OverlayManager::getSingletonPtr();
	Ogre::Overlay::Overlay2DElementsIterator iter = mOverlay->get2DElementsIterator();
	for(;iter.hasMoreElements();)
	{
		Ogre::OverlayContainer * childContainer = iter.getNext();
		Ogre::OverlayContainer::ChildIterator contIter = childContainer->getChildIterator();
		for(;contIter.hasMoreElements();)
		{
			Ogre::OverlayElement* curElement = contIter.getNext();
			overlayMgr->destroyOverlayElement(curElement->getName());
		}
		overlayMgr->destroyOverlayElement(childContainer->getName());
	}
	overlayMgr->destroy(mOverlay->getName());
}
Exemplo n.º 5
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();
	}
}
Exemplo n.º 6
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();
	}

}
Exemplo n.º 7
0
void gkHUD::newImpl(void)
{

	try
	{

		m_overlay = Ogre::OverlayManager::getSingleton().getByName(m_name.getName());

		// Auto create if it's here
		if (m_overlay)
		{
			Ogre::Overlay::Overlay2DElementsIterator elements = m_overlay->get2DElementsIterator();

			while (elements.hasMoreElements())
			{
				Ogre::OverlayContainer* cont = elements.getNext();
				addChild(new gkHUDElement(cont->getName()));

				Ogre::OverlayContainer::ChildIterator childs = cont->getChildIterator();

				while (childs.hasMoreElements())
				{
					Ogre::OverlayElement* elm = childs.getNext();
					gkHUDElement* hele = new gkHUDElement(elm->getName());
					addChild(hele);
				}
			}

		}
	}
	catch (Ogre::Exception& e)
	{
		gkLogMessage("HUD: " << e.getDescription());
		m_overlay = 0;
	}
}