コード例 #1
0
ファイル: Menu.cpp プロジェクト: Thoronador/Dusk
void Menu::showDialogue(const std::string& first, const std::vector<std::string>& options)
{
  Ogre::OverlayManager& om = Ogre::OverlayManager::getSingleton();
  std::cout << "getByName(overlay)\n";
  Ogre::Overlay* dialOverlay = om.getByName(cDialogueOverlay);
  if (dialOverlay == NULL)
  {
    std::cout << "create(overlay)\n";
    dialOverlay = om.create(cDialogueOverlay);
  }
  Ogre::OverlayContainer* dialCont = NULL;
  std::cout << "getOE(Box)\n";
  dialCont = static_cast<Ogre::OverlayContainer*> (om.getOverlayElement(cDialogueOverlay+"/Box"));
  if (dialCont == NULL)
  {
    std::cout << "createOE(Box)\n";
    dialCont = static_cast<Ogre::OverlayContainer*>
                    (om.createOverlayElement("Panel", cDialogueOverlay+"/Box"));
    dialCont->setPosition(0.0, 0.75);
    dialCont->setDimensions(1.0, 0.25);
    dialCont->setMaterialName("Dusk/Dialogue/Black");
  }
  std::cout << "getOE(Box/First)\n";
  Ogre::OverlayElement* dialElem;
  dialElem = om.getOverlayElement(cDialogueOverlay+"/Box/First");
  if (dialElem==NULL)
  {
    std::cout << "createOE(Box/First)\n";
    dialElem = om.createOverlayElement("TextArea", cDialogueOverlay+"/Box/First");
    dialElem->setDimensions(1.0, 0.0625);
    dialElem->setPosition(0.0, 0.0);
    dialElem->setMaterialName("Dusk/Dialogue/Element");
    dialCont->addChild(dialElem);
  }
  dialElem->setCaption(first);
  dialElem->show();
  unsigned int elemCount = options.size();
  if (elemCount > cMaxDialogueOptions)
  {
    elemCount = cMaxDialogueOptions;
  }

  killDialogueOverlayLines();
  unsigned int i;
  const float elemHeight = 0.8/(float)elemCount;
  for (i=0; i<elemCount; i=i+1)
  {
    //dialElem = om.createOverlayElement("TextArea", cDialogueOverlay+"/Box/Line"+IntToString(i));
    dialElem = om.createOverlayElementFromTemplate(cDialogueOverlay+"/LineTemplate", "TextArea", cDialogueOverlay+"/Box/Line"+IntToString(i));
    dialElem->setPosition(0.1, dialCont->getHeight()*(0.2+i*elemHeight));
    dialElem->setDimensions(0.8, elemHeight*dialCont->getHeight());
    dialElem->setCaption(IntToString(i+1)+": "+options[i]);
    dialElem->show();
    dialCont->addChild(dialElem);
    m_DialogueLineCount = i+1;
  }//for
  dialOverlay->show();
}
コード例 #2
0
ファイル: GUIHelper.cpp プロジェクト: agudpp/CordobaZombie
void GUIHelper::reposContainer(Ogre::OverlayContainer *o)
{
	ASSERT(o);
	if(!o->getParent()){
		debugWARNING("This overlay has no parent (%s)\n", o->getName().c_str());
		return;
	}
	// if we have parent then we call the other function
	Ogre::OverlayContainer *parent = o->getParent();
	reposContainer(o, parent->getLeft(), parent->getTop(),parent->getHeight(),
			parent->getWidth());
}
コード例 #3
0
ファイル: GUIHelper.cpp プロジェクト: agudpp/CordobaZombie
/**
 * 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();
	}
}