Exemplo n.º 1
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());
}
// virtual
EC_OgreMovableTextOverlay::~EC_OgreMovableTextOverlay()
{
    if (renderer_.expired())
        return;

    if (overlay_)
    {
        overlay_->hide();
        container_->removeChild(overlayName_);
        overlay_->remove2D(container_);

        Ogre::OverlayManager *overlayManager = Ogre::OverlayManager::getSingletonPtr();
        overlayManager->destroyOverlayElement(text_element_);
        overlayManager->destroyOverlayElement(container_);
        overlayManager->destroy(overlay_);
    }

    if (node_)
    {
        DetachNode();
        Ogre::SceneManager *scene_mgr = renderer_.lock()->GetSceneManager();
        scene_mgr->destroySceneNode(node_);
        node_ = 0;
    }
}
Exemplo n.º 3
0
CObjectTitle::~CObjectTitle()
{
   Ogre::OverlayManager *pOverlayManager = Ogre::OverlayManager::getSingletonPtr();
   m_pContainer->removeChild(m_pTextArea->getName());
   m_pOverlay->remove2D(m_pContainer);
   pOverlayManager->destroyOverlayElement(m_pTextArea);
   pOverlayManager->destroyOverlayElement(m_pContainer);
   pOverlayManager->destroy(m_pOverlay);
}
MovableTextOverlay::~MovableTextOverlay()
{
	// overlay cleanup -- Ogre would clean this up at app exit but if your app 
	// tends to create and delete these objects often it's a good idea to do it here.

	mpOv->hide();
	Ogre::OverlayManager *overlayManager = Ogre::OverlayManager::getSingletonPtr();
	mpOvContainer->removeChild(mName+"_OvTxt");
	mpOv->remove2D(mpOvContainer);
	overlayManager->destroyOverlayElement(mpOvText);
	overlayManager->destroyOverlayElement(mpOvContainer);
	overlayManager->destroy(mpOv);
}
Exemplo n.º 5
0
void Menu::showQuestLogEntries()
{
  Ogre::OverlayManager* om = Ogre::OverlayManager::getSingletonPtr();
  if (om==NULL) return;
  Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(
                            om->getOverlayElement(cQuestLogOverlay+"/Panel"));
  if (panel==NULL)
  {
    std::cout << "Menu::showQuestLogEntries: ERROR: Panel not found!\n";
    return;
  }//if
  std::vector<QLogEntry> entries = QuestLog::getSingleton().listQuestEntries(m_QuestLogOffset, cQuestLogEntriesPerPage);
  if (m_QuestLogOffset>0 and entries.empty())
  { //reset offset, because we've gone too far, and fetch entries again
    m_QuestLogOffset = 0;
    entries = QuestLog::getSingleton().listQuestEntries(m_QuestLogOffset, cQuestLogEntriesPerPage);
  }
  Ogre::TextAreaOverlayElement* text_elem = NULL;

  const Ogre::FontPtr glyphs = Ogre::FontManager::getSingleton().getByName("Console");
  unsigned int i;
  //create text areas for entries
  for (i=0; i<entries.size(); ++i)
  {
    text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
        om->createOverlayElement("TextArea", cQuestLogOverlay+"/"+IntToString(i)));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.025, cQuestLogEntryHeight*i+0.5*cQuestLogEntryHeight);
    text_elem->setDimensions(0.725, cQuestLogEntryHeight);
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Left);
    text_elem->setCaption(chopString(Journal::getSingleton().getText(entries[i].questID, entries[i].index),
                cQuestLogCharHeight, glyphs));
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);
  }//for
  //delete unneccessary textareas, if present
  for (i=entries.size(); i<m_QuestLogEntryCount; ++i)
  {
    om->destroyOverlayElement(cQuestLogOverlay+"/"+IntToString(i));
  }//for
  m_QuestLogEntryCount = entries.size();
  //show notification, if no elements are present yet
  if (entries.empty())
  {
    text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
                    om->createOverlayElement("TextArea", cQuestLogOverlay+"/0"));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.025, 0.0+0.5*cQuestLogEntryHeight);
    text_elem->setDimensions(0.725, cQuestLogEntryHeight);
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
    text_elem->setCaption("You don't have any journal entries yet!");
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);
    m_QuestLogEntryCount = 1;
  }//if
}//func
Exemplo n.º 6
0
	MainSkin::~MainSkin()
	{
		if (mOverlayContainer == null) return;
		// с защитой от удаления после шутдауна рендера
		Ogre::OverlayManager * manager = Ogre::OverlayManager::getSingletonPtr();
		if (manager != null) manager->destroyOverlayElement(mOverlayContainer);
	}
Exemplo n.º 7
0
void TextComponent::OnDestroy() {
    Ogre::OverlayManager* mgr = Ogre::OverlayManager::getSingletonPtr();

    mPanel->removeChild(mLabel->getName());
    mOverlay->remove2D(mPanel);

    mgr->destroyOverlayElement(mLabel);
    mgr->destroyOverlayElement(mPanel);
    mgr->destroy(mOverlay);
}
Exemplo n.º 8
0
void Menu::killDialogueOverlayLines()
{
  Ogre::OverlayManager* om = Ogre::OverlayManager::getSingletonPtr();
  /*If overlay manager is NULL, then it is not present any more and all overlays
    should already be destroyed at that point. So we can return anyway. */
  if (om==NULL) return;
  Ogre::OverlayContainer* oc = static_cast<Ogre::OverlayContainer*> (om->getOverlayElement(cDialogueOverlay+"/Box"));
  unsigned int i;
  for (i=0; i<m_DialogueLineCount; i=i+1)
  {
    oc->removeChild(cDialogueOverlay+"/Box/Line"+IntToString(i));
    om->destroyOverlayElement(cDialogueOverlay+"/Box/Line"+IntToString(i));
  }//for
  m_DialogueLineCount = 0;
}
Exemplo n.º 9
0
void Menu::showQuestLog(const bool visible)
{
  Ogre::OverlayManager* om = Ogre::OverlayManager::getSingletonPtr();
  if (om==NULL) return;
  //Do we actually need to do something?
  if (visible==isQuestLogVisible()) return;

  if (visible)
  {
    //show it
    // -- create basic overlay
    Ogre::Overlay* ol = om->create(cQuestLogOverlay);
    // -- create container - panel
    Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(
                 om->createOverlayElement("Panel", cQuestLogOverlay+"/Panel"));
    panel->setMetricsMode(Ogre::GMM_RELATIVE);
    panel->setPosition(0.0, 0.0);
    panel->setDimensions(1.0, 1.0);
    /*set material via panel->setMaterialName(...)?*/
    panel->setMaterialName("QuestLog/Transparency");
    //add panel to overlay
    ol->add2D(panel);

    //create elements
    // -- "vorwärts blättern"
    Ogre::TextAreaOverlayElement* text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
                         om->createOverlayElement("TextArea", cQuestLogOverlay+"/Plus"));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.125, 0.9);
    text_elem->setDimensions(0.25, 0.1);
    text_elem->setCaption("+ (Next)");
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);
    //-- "rückwärts blättern"
    text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
              om->createOverlayElement("TextArea", cQuestLogOverlay+"/Minus"));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.425, 0.9);
    text_elem->setDimensions(0.25, 0.1);
    text_elem->setCaption("- (Previous)");
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);

    //lists all entries that fit onto the page
    showQuestLogEntries();

    // -- page number
    text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
              om->createOverlayElement("TextArea", cQuestLogOverlay+"/Page"));
    text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
    text_elem->setPosition(0.725, 0.9);
    text_elem->setDimensions(0.25, 0.1);
    text_elem->setCaption("Page "+IntToString(m_QuestLogOffset/cQuestLogEntriesPerPage+1));
    text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
    text_elem->setFontName("Console");
    text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
    text_elem->setCharHeight(cQuestLogCharHeight);
    panel->addChild(text_elem);

    //show the overlay
    ol->show();
  }//if visible
  else
  {
    //destroy all elements
    unsigned int i;
    // destroy entries
    for (i=0; i<m_QuestLogEntryCount; ++i)
    {
      om->destroyOverlayElement(cQuestLogOverlay+"/"+IntToString(i));
    }//for
    m_QuestLogEntryCount = 0;
    //destroy navigation elements
    om->destroyOverlayElement(cQuestLogOverlay+"/Plus");
    om->destroyOverlayElement(cQuestLogOverlay+"/Minus");
    om->destroyOverlayElement(cQuestLogOverlay+"/Page");
    //destroy panel
    om->destroyOverlayElement(cQuestLogOverlay+"/Panel");
    //destroy overlay
    om->destroy(cQuestLogOverlay);
  }//else
}//function