示例#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
void SplashScreenState::enter()
{
	OgreFramework::getSingletonPtr()->m_pLog->logMessage("Entering SplashScreenState...");

	m_pSceneMgr = OgreFramework::getSingletonPtr()->m_pRoot->createSceneManager(Ogre::ST_GENERIC, "SplashSceneMgr");
	m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));

	m_pSceneMgr->addRenderQueueListener(OgreFramework::getSingletonPtr()->m_pOverlaySystem);

	m_pCamera = m_pSceneMgr->createCamera("SplashCam");
	m_pCamera->setPosition(Ogre::Vector3(0, 25, -50));
	m_pCamera->lookAt(Ogre::Vector3(0, 0, 0));
	m_pCamera->setNearClipDistance(1);

	m_pCamera->setAspectRatio(Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualWidth()) /
		Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualHeight()));

	OgreFramework::getSingletonPtr()->m_pViewport->setCamera(m_pCamera);

	createScene();

	OgreFramework::getSingletonPtr()->m_pTrayMgr->destroyAllWidgets();

	new ObjectCache(m_pSceneMgr);

	Ogre::OverlayElement * btn = OgreFramework::getSingletonPtr()->m_pTrayMgr->createButton(OgreBites::TL_NONE, "SplashBtn", "Press Enter to continue...", 250)->getOverlayElement();
	btn->setPosition(Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualWidth()) * 50 / 100 - 125,
			Ogre::Real(OgreFramework::getSingletonPtr()->m_pViewport->getActualHeight()) * 75 / 100);
	OgreFramework::getSingletonPtr()->m_pTrayMgr->hideCursor();
}
示例#3
0
	Ogre::OverlayElement* COverlay::createChildElement(const std::string &type, const std::string& name, 
		float left, float top, float width, float height)
	{		
		assert( !_overlayManager->hasOverlayElement(name) && "Ya existe un elemento hijo con el mismo nombre" );
		
		Ogre::OverlayElement* newChild = _overlayManager->createOverlayElement(type, name);
			newChild->setMetricsMode(_metricsMode); 
			newChild->setPosition(left, top);		// segun metricsMode: relativas o en pixeles
			newChild->setDimensions(width, height); 
		
		_childElements[name] = newChild;

		return newChild;
	} // createChildTextArea
	void TextRenderer::AddTextBox(const std::string &id,
		const std::string &text,
		Ogre::Real x, Ogre::Real y,
		Ogre::Real width, Ogre::Real height,
		const Ogre::ColourValue &color)
	{
		Ogre::OverlayElement *textBox = m_overlayMgr->createOverlayElement("TextArea", id);
		textBox->setDimensions(width, height);
		textBox->setMetricsMode(Ogre::GMM_PIXELS);
		textBox->setPosition(x, y);
		textBox->setWidth(width);
		textBox->setHeight(height);
		textBox->setParameter("font_name", "DebugFont");
		textBox->setParameter("char_height", "16");
		textBox->setColour(color);

		textBox->setCaption(text);

		m_panel->addChild(textBox);
	}
示例#5
0
void
EndGameState::enter ()
{
	bool mapFit=false;
	if (!_root)
	{
	  _root = Ogre::Root::getSingletonPtr();
	  _gameMgr = GameManager::getSingletonPtr();

	  // Se recupera el gestor de escena y la cámara.
	  _sceneMgr = _root->getSceneManager("SceneManager");
	  
	  _camera = _sceneMgr->getCamera("IntroCamera");
	  _viewport = _root->getAutoCreatedWindow()->getViewport(0);
	  //_viewport = _root->getAutoCreatedWindow()->addViewport(_camera);
	  // Nuevo background colour.
	  _viewport->setBackgroundColour(Ogre::ColourValue(0.0, 0.0, 0.0));
	  _overlayMgr = Ogre::OverlayManager::getSingletonPtr();

	  mapFit=false;
	}

	_overlayMgr = Ogre::OverlayManager::getSingletonPtr();
	overlay = _overlayMgr->getByName("EndOverlay");
	Ogre::OverlayElement *endOverlay = _overlayMgr->getOverlayElement("endPanel");

	double width = _viewport->getActualWidth();
	double height = _viewport->getActualHeight();
	double aspectRatio = endOverlay->getWidth()/endOverlay->getHeight();
	endOverlay->setDimensions(width,width/aspectRatio);
	endOverlay->setPosition(0,(height/2)-(endOverlay->getHeight()/2));
	_gameMgr->playEndMusic();


	
  overlay->show();

  _exitGame = false;
}