Ejemplo 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());
}
Ejemplo n.º 2
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
Ejemplo n.º 3
0
	MainSkin::~MainSkin()
	{
		if (mOverlayContainer == null) return;
		// с защитой от удаления после шутдауна рендера
		Ogre::OverlayManager * manager = Ogre::OverlayManager::getSingletonPtr();
		if (manager != null) manager->destroyOverlayElement(mOverlayContainer);
	}
Ejemplo n.º 4
0
// 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;
    }
}
Ejemplo n.º 5
0
bool Menu::isQuestLogVisible() const
{
  Ogre::OverlayManager* om = Ogre::OverlayManager::getSingletonPtr();
  if (om==NULL) return false;
  const Ogre::Overlay* o_lay = om->getByName(cQuestLogOverlay);
  if (o_lay!=NULL) return o_lay->isVisible();
  return false;
}
Ejemplo n.º 6
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);
}
Ejemplo 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);
}
Ejemplo n.º 8
0
void Menu::hideDialogue()
{
  Ogre::OverlayManager* olMgr =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 (olMgr==NULL) return;
  Ogre::Overlay* ol = olMgr->getByName(cDialogueOverlay);
  if (ol!=NULL)
  {
    ol->hide();
  }
}
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);
}
Ejemplo n.º 10
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;
}
Ejemplo n.º 11
0
void Gui::createGui(Ogre::SceneManager* p_scene_manager, OgreBites::SdkTrayManager* p_tray_manager){
	m_tray_manager = p_tray_manager;
	m_button = m_tray_manager->createButton(OgreBites::TL_TOPLEFT, "MyButton", "Click me!");

	if(m_button->getName() == "MyButton"){
		int p = 0;
	}

	// Load layout
   Ogre::ResourceGroupManager::getSingletonPtr();
   Ogre::OverlayManager* mg = Ogre::OverlayManager::getSingletonPtr();
   Ogre::Overlay* ov = mg->getByName("testOverlay");
   ov->show();


}
 OverlayObject::OverlayObject(const std::string& name)
   : name_(name)
 {
   std::string material_name = name_ + "Material";
   Ogre::OverlayManager* mOverlayMgr = Ogre::OverlayManager::getSingletonPtr();
   overlay_ = mOverlayMgr->create(name_);
   panel_ = static_cast<Ogre::PanelOverlayElement*> (
     mOverlayMgr->createOverlayElement("Panel", name_ + "Panel"));
   panel_->setMetricsMode(Ogre::GMM_PIXELS);
   
   panel_material_
     = Ogre::MaterialManager::getSingleton().create(
       material_name,
       Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
   panel_->setMaterialName(panel_material_->getName());
   overlay_->add2D(panel_);
 }
Ejemplo n.º 13
0
	bool GBaseEngine::loadBootResources()
	{
		if( bBootResourcesWereLoaded )
		{
			GTRACE(1, "Warning: received command to load boot resources again! (Ignoring)");
			return false;
		}
		ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
		ResourceGroupManager::getSingleton().loadResourceGroup("Bootstrap");
		Ogre::OverlayManager * overlayManager = OverlayManager::getSingletonPtr();
		if( ! overlayManager )
		{
			GTRACE(3, "ERROR! OverlayManager is NULL!");
			return false;
		}
		
		loaderOverlay = overlayManager->getByName("GusApp/Loader4_3");

		bool result = (loaderOverlay != NULL);
		bBootResourcesWereLoaded = result;
		return result;
	}
Ejemplo n.º 14
0
bit GameVisualScene::init( Game* game )
{
	game->visualSystem.lockThread();

	game->visualSystem.loadResources("InGame");
	Ogre::Viewport* vp = game->visualSystem.getPrimaryRenderWindow()->getViewport(0);
	Ogre::CompositorManager* compositorMgr = Ogre::CompositorManager::getSingletonPtr();
	Ogre::CompositorInstance* compositor = compositorMgr->addCompositor(vp,"LuminanceBloom");
	compositorMgr->setCompositorEnabled(vp,"LuminanceBloom",true);

	VisualScene::init(game);

	Ogre::Light* light = game->visualSystem.getSceneMgr()->createLight("MainLight");
	light->setType(Ogre::Light::LT_DIRECTIONAL);
	light->setPosition(800,900,-550);
	Ogre::Vector3 dir = -light->getPosition();
	dir.normalise();
	light->setDirection(dir);
	light->setSpecularColour(1.0f,1.0f,1.0f);
	light->setDiffuseColour(0.8f,0.8f,0.8f);
	//light->setSpotlightRange(Ogre::Degree(50), Ogre::Degree(75));
	light->setPowerScale(1.0f);
	light->setCastShadows(true);	

	//Ogre::LiSPSMShadowCameraSetup* cameraSetup = new Ogre::LiSPSMShadowCameraSetup;
	//game->visualSystem.getSceneMgr()->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(cameraSetup));

	game->visualSystem.getSceneMgr()->getRootSceneNode()->attachObject(light);

	game->visualSystem.getSceneMgr()->setAmbientLight(Ogre::ColourValue(0.1,0.90,0.75));
	//game->visualSystem.getSceneMgr()->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE);
	game->visualSystem.getSceneMgr()->setShadowTextureSize(1024);
	//game->visualSystem.getSceneMgr()->setShadowTextureSettings(1024,2);
	game->visualSystem.getSceneMgr()->setShadowFarDistance(24);
	game->visualSystem.getSceneMgr()->setShadowDirLightTextureOffset(0.05);
	game->visualSystem.getSceneMgr()->setShadowTextureSelfShadow(false);
	game->visualSystem.getSceneMgr()->setShadowColour( Ogre::ColourValue(0.75f, 0.75f, 0.75f) );
	game->visualSystem.getSceneMgr()->setSkyBox(true,"skybox",1000);	
	game->visualSystem.getSceneMgr()->setShadowTextureCasterMaterial("depthShadowMapCasterMaterial");
	//game->visualSystem.getSceneMgr()->setShadowTextureCasterMaterial("VarianceShadowMapping/ShadowCaster");
	game->visualSystem.getSceneMgr()->setShadowTexturePixelFormat(PF_FLOAT32_R);
	game->visualSystem.getSceneMgr()->setShadowCasterRenderBackFaces(true);
	game->visualSystem.getSceneMgr()->setShadowTechnique(SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
	
	Bridge* bridge = new Bridge(game);
	bridge->init("bridge");

	RoadBarrier* barrier[20];

	for(u32 i=0 ; i<20 ; i++)
	{		
		barrier[i] = new RoadBarrier(game);
		barrier[i]->init("barrier"+IntToStr(i));		
	}
	hkQuaternion q;
	q.setAxisAngle(hkVector4(0,1,0),Deg2Rad(90));
	barrier[0]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,-50.0),q);
	barrier[1]->getPhysicsEntity()->setPositionAndRotation(hkVector4(4.5,0.51f,-40.0),q);
	barrier[2]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,-30.0),q);
	barrier[3]->getPhysicsEntity()->setPositionAndRotation(hkVector4(1.5,0.51f,-20.0),q);
	barrier[4]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,-10.0),q);
	barrier[5]->getPhysicsEntity()->setPositionAndRotation(hkVector4(2.5,0.51f,-70.0),q);
	barrier[6]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,-90.0),q);
	barrier[7]->getPhysicsEntity()->setPositionAndRotation(hkVector4(0.5,0.51f,100.0),q);
	barrier[8]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,110.0),q);
	barrier[9]->getPhysicsEntity()->setPositionAndRotation(hkVector4(5.5,0.51f,40.0),q);
	barrier[10]->getPhysicsEntity()->setPositionAndRotation(hkVector4(1.5,0.51f,50.0),q);
	barrier[11]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,60.0),q);
	barrier[12]->getPhysicsEntity()->setPositionAndRotation(hkVector4(5.5,0.51f,70.0),q);
	barrier[13]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,80.0),q);
	barrier[14]->getPhysicsEntity()->setPositionAndRotation(hkVector4(3.5,0.51f,90.0),q);
	barrier[15]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,100.0),q);
	barrier[16]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-2.5,0.51f,110.0),q);
	barrier[17]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-0.5,0.51f,120.0),q);
	barrier[18]->getPhysicsEntity()->setPositionAndRotation(hkVector4(2.5,0.51f,130.0),q);
	barrier[19]->getPhysicsEntity()->setPositionAndRotation(hkVector4(5.5,0.51f,140.0),q);

	Crate* crate[32];
	for(u32 i=0 ; i<32 ; i++)
	{
		crate[i] = new Crate(game);
		crate[i]->init("crate"+IntToStr(i));		
	}
	crate[0]->getPhysicsEntity()->setPosition(hkVector4(-1.25,0.0f,20.75));
	crate[1]->getPhysicsEntity()->setPosition(hkVector4(-2   ,0.0f,20.75));
	crate[2]->getPhysicsEntity()->setPosition(hkVector4(-2,0.0f,20.75));
	crate[3]->getPhysicsEntity()->setPosition(hkVector4(-1,25,0.0f,20.0));
	crate[4]->getPhysicsEntity()->setPosition(hkVector4(-2   ,0.0f,20.0));
	crate[5]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.0f,20.0));
	crate[6]->getPhysicsEntity()->setPosition(hkVector4(-1,25,0.0f,20.75));
	crate[7]->getPhysicsEntity()->setPosition(hkVector4(-2   ,0.0f,20.75));
	crate[8]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.0f,20.75));

	crate[9]->getPhysicsEntity()->setPosition(hkVector4(-1.25,0.5f,20.75));
	crate[10]->getPhysicsEntity()->setPosition(hkVector4(-2   ,0.5f,20.75));
	crate[11]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.5f,20.75));
	crate[12]->getPhysicsEntity()->setPosition(hkVector4(-1,25,0.5f,20.0));
	crate[13]->getPhysicsEntity()->setPosition(hkVector4(-2   ,0.5f,20.0));
	crate[14]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.5f,20.0));
	crate[15]->getPhysicsEntity()->setPosition(hkVector4(-1,25,0.5f,20.750));
	crate[16]->getPhysicsEntity()->setPosition(hkVector4(-2   ,0.5f,20.750));
	crate[17]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.5f,20.750));

	crate[18]->getPhysicsEntity()->setPosition(hkVector4(-1.25,1.0f,20.75));
	crate[19]->getPhysicsEntity()->setPosition(hkVector4(-2   ,1.0f,20.75));
	crate[20]->getPhysicsEntity()->setPosition(hkVector4(-2.75,1.0f,20.75));
	crate[21]->getPhysicsEntity()->setPosition(hkVector4(-1,25,1.0f,20.0));
	crate[22]->getPhysicsEntity()->setPosition(hkVector4(-2   ,1.0f,20.0));
	crate[23]->getPhysicsEntity()->setPosition(hkVector4(-2.75,1.0f,20.0));
	crate[24]->getPhysicsEntity()->setPosition(hkVector4(-1,25,1.0f,20.75));
	crate[25]->getPhysicsEntity()->setPosition(hkVector4(-2   ,1.0f,20.75));
	crate[26]->getPhysicsEntity()->setPosition(hkVector4(-2.75,1.0f,20.75));

	crate[27]->getPhysicsEntity()->setPosition(hkVector4(-1.25,1.5f,-20.75));
	crate[28]->getPhysicsEntity()->setPosition(hkVector4(-20   ,1.5f,-20.75));
	crate[29]->getPhysicsEntity()->setPosition(hkVector4(-2.75,1.5f,-20.75));
	crate[30]->getPhysicsEntity()->setPosition(hkVector4(-1,25,1.5f,-20.0));
	crate[31]->getPhysicsEntity()->setPosition(hkVector4(-2   ,1.5f,-20.0));


	//RoadBarrier* barrier = new RoadBarrier(game);
	//barrier->init("barrier");
	//barrier->getPhysicsEntity()->setPosition(hkVector4(-5.5,0.25f,0.0f));

	Ogre::OverlayManager* overlayManager = Ogre::OverlayManager::getSingletonPtr();
	Ogre::Overlay* overlay = overlayManager->getByName("debugText");
	overlay->show();
	debugTextOverlay  = (Ogre::TextAreaOverlayElement*)overlayManager->getOverlayElement("debugTextArea");
	debugTextOverlay->show();

	updateCamera();

	game->visualSystem.unlockThread();

	return true;
}
Ejemplo n.º 15
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
Ejemplo n.º 16
0
GameplayScreen::GameplayScreen()
{
	//Set up the 3D scene
	Ogre::SceneManager* mSceneManager = Ogre::Root::getSingletonPtr()->getSceneManager("ApplicationSceneManager");
	Ogre::Entity* stageEntity = mSceneManager->createEntity("Stage", "Stage.mesh");
	mStageNode = mSceneManager->getRootSceneNode()->createChildSceneNode("StageNode");
	mStageNode->attachObject(stageEntity);
	mStageNode->setPosition(0.0f, -6.0f, -6.5f);

	//Set up game objects
	mWhacker = new Whacker(mSceneManager, mSceneManager->getRootSceneNode());
	mWhacker->SetMovePlane(Ogre::Vector3(0.0f, 2.0f, 1.0f), Ogre::Vector3(0.0f, -0.5f, -6.5f), 3.8f, 3.0f);
	float dragonPositions[] = { -3.0f, -2.5f, -7.0f,
								-1.5f, -2.0f, -8.0f,
								-1.5f, -3.0f, -6.0f,
								0.0f, -2.5f, -7.0f,
								1.5f, -2.0f, -8.0f,
								1.5f, -3.0f, -6.0f,
								3.0f, -2.5f, -7.0f };
	mDragons = std::vector<Dragon*>();
	for (int i=0; i < 7; i++)
	{
		mDragons.push_back(new Dragon(mSceneManager, mSceneManager->getRootSceneNode()));
		mDragons[i]->SetPosition(Ogre::Vector3(dragonPositions[i*3], dragonPositions[(i*3)+1], dragonPositions[(i*3)+2]));
	}

	//Set up game variables
	timeBetweenPopups = 1.0f;
	timeSinceLastPopup = 0.0f;
	score = 0;
	numPeasants = 200;
	subtractPopTime = 0.05f;
	scorePerPopTimeSub = 15;
	minPopTime = 0.75f;
	mWhackerMoveScalar = 0.01f;

	//Lets set up our scoring overlay (Lots of uninteresting code :/ )
	//Fonts are loaded due to a resource loading bug in OGRE 1.8 http://www.ogre3d.org/forums/viewtopic.php?f=2&t=63652
	Ogre::FontManager::getSingleton().load( "YeOldShire", "General" );
	Ogre::FontManager::getSingleton().load( "DejaVuSans", "General" );
	//Title overlays
	Ogre::OverlayManager* overlayMgr = Ogre::OverlayManager::getSingletonPtr();
	mOverlay = overlayMgr->create("GameStats");
	Ogre::OverlayContainer* newContainer = static_cast<Ogre::OverlayContainer*>(overlayMgr->createOverlayElement("Panel", "StatsTitleContainer")); //Breaks Here
	newContainer->setMetricsMode(Ogre::GMM_RELATIVE);
    newContainer->setDimensions(0.4f, 0.15f);
    newContainer->setPosition(0.5f, 0.75f);
	newContainer->setHorizontalAlignment(Ogre::GHA_LEFT);
	Ogre::TextAreaOverlayElement* newElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr->createOverlayElement("TextArea", "ScoreTitleText"));
	newElement->setCaption("Score");
	newElement->setFontName("YeOldShire");
	newElement->setColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
	newElement->setAlignment(Ogre::TextAreaOverlayElement::Right);
	newElement->setVerticalAlignment(Ogre::GVA_TOP);
	newElement->setMetricsMode(Ogre::GMM_RELATIVE);
    newElement->setPosition(0, 0);
    newElement->setDimensions(0.4f, 0.4f);
    newElement->setCharHeight(0.028f);
	newContainer->addChild(newElement);
	newElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr->createOverlayElement("TextArea", "PeasantsTitleText"));
	newElement->setCaption("Peasants Left");
	newElement->setFontName("YeOldShire");
	newElement->setColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
	newElement->setAlignment(Ogre::TextAreaOverlayElement::Right);
	newElement->setVerticalAlignment(Ogre::GVA_BOTTOM);
	newElement->setMetricsMode(Ogre::GMM_RELATIVE);
    newElement->setPosition(0, 0);
    newElement->setDimensions(0.4f, 0.4f);
    newElement->setCharHeight(0.028f);
	newContainer->addChild(newElement);
	mOverlay->add2D(newContainer);
	//Value Overlays
	newContainer = static_cast<Ogre::OverlayContainer*>(overlayMgr->createOverlayElement("Panel", "StatsValueContainer"));
	newContainer->setMetricsMode(Ogre::GMM_RELATIVE);
    newContainer->setDimensions(0.4f, 0.15f);
    newContainer->setPosition(0.5f, 0.75f);
	newContainer->setHorizontalAlignment(Ogre::GHA_LEFT);
	newContainer->setColour(Ogre::ColourValue(1.0f, 1.0f, 1.0f, 0.3f));
	newElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr->createOverlayElement("TextArea", "ScoreValueText"));
	Ogre::String num_str = Ogre::StringConverter::toString(score);
	newElement->setCaption(":"+num_str);
	newElement->setFontName("DejaVuSans");
	newElement->setColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
	newElement->setAlignment(Ogre::TextAreaOverlayElement::Left);
	newElement->setVerticalAlignment(Ogre::GVA_TOP);
	newElement->setMetricsMode(Ogre::GMM_RELATIVE);
    newElement->setPosition(0, 0);
    newElement->setDimensions(0.4f, 0.4f);
    newElement->setCharHeight(0.045f);
	mScoreText = newElement;
	newContainer->addChild(newElement);
	newElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr->createOverlayElement("TextArea", "PeasantsValueText"));
	num_str = Ogre::StringConverter::toString(numPeasants);
	newElement->setCaption(":"+num_str);
	newElement->setFontName("DejaVuSans");
	newElement->setColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 1.0f));
	newElement->setAlignment(Ogre::TextAreaOverlayElement::Left);
	newElement->setVerticalAlignment(Ogre::GVA_BOTTOM);
	newElement->setMetricsMode(Ogre::GMM_RELATIVE);
    newElement->setPosition(0, 0);
    newElement->setDimensions(0.4f, 0.4f);
    newElement->setCharHeight(0.045f);
	mPeasantText = newElement;
	newContainer->addChild(newElement);
	mOverlay->add2D(newContainer);

	mOverlay->show();
}