Exemplo n.º 1
0
	//---------------------------------------------------------------------
	OverlayElement* OverlayManager::createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isATemplate)
	{

		OverlayElement* newObj  = NULL;

		if (templateName.empty())
		{
			newObj = createOverlayElement(typeName, instanceName, isATemplate);
		}
		else
		{
			// no template 
			OverlayElement* templateGui = getOverlayElement(templateName, true);

			String typeNameToCreate;
			if (typeName.empty())
			{
				typeNameToCreate = templateGui->getTypeName();
			}
			else
			{
				typeNameToCreate = typeName;
			}

			newObj = createOverlayElement(typeNameToCreate, instanceName, isATemplate);

			((OverlayContainer*)newObj)->copyFromTemplate(templateGui);
		}

		return newObj;
	}
// -------------------------------------------------------------------------
void OgreBulletListener::updateStats(void)
{

    // update stats when necessary
    if (mFpsStaticText)
    {
        const RenderTarget::FrameStats& stats = mWindow->getStatistics();

        static String avgFps = "Average FPS: ";
        static String currFps = "Current FPS: ";
        static String tris = "Triangle Count: ";


        mFpsStaticText->setValue
            (
            avgFps + StringConverter::toString(stats.avgFPS) + " / " +
            currFps + StringConverter::toString(stats.lastFPS) + " / " +
            tris + StringConverter::toString(stats.triangleCount)
            );
    }

    try {
        OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
        guiDbg->setCaption(mDebugText);
    }
    catch(...) {}
}
Exemplo n.º 3
0
  /** Show the loading bar and start listening.
      @param window The window to update 
      @param numGroupsInit The number of groups you're going to be initialising
      @param numGroupsLoad The number of groups you're going to be loading
      @param initProportion The proportion of the progress which will be taken
      up by initialisation (ie script parsing etc). Defaults to 0.7 since
      script parsing can often take the majority of the time.
  */
void LoadingBar::
start(RenderWindow* window,  unsigned short numGroupsInit , 
      unsigned short numGroupsLoad, Real initProportion)
{
    mWindow = window;
    mNumGroupsInit = numGroupsInit;
    mNumGroupsLoad = numGroupsLoad;
    mInitProportion = initProportion;
    // We need to pre-initialise the 'Bootstrap' group so we can use
    // the basic contents in the loading screen
    ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
    
    OverlayManager& omgr = OverlayManager::getSingleton();
    mLoadOverlay = (Overlay*)omgr.getByName("Core/LoadOverlay");
    if (!mLoadOverlay)
      {
	OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, 
		    "Cannot find loading overlay", "ExampleLoadingBar::start");
      }
    mLoadOverlay->show();
    
    // Save links to the bar and to the loading text, for updates as we go
    mLoadingBarElement = omgr.getOverlayElement("Core/LoadPanel/Bar/Progress");
    mLoadingCommentElement = omgr.getOverlayElement("Core/LoadPanel/Comment");
    mLoadingDescriptionElement = omgr.getOverlayElement("Core/LoadPanel/Description");
    
    OverlayElement* barContainer = omgr.getOverlayElement("Core/LoadPanel/Bar");
    mProgressBarMaxSize = barContainer->getWidth();
    mLoadingBarElement->setWidth(0);
    
    // self is listener
    ResourceGroupManager::getSingleton().addResourceGroupListener(this);
  }
Exemplo n.º 4
0
/*
ResourceGroupListener Methods
*/
void LogoState::start(RenderWindow* window,unsigned short numGroupsInit = 1,unsigned short numGroupsLoad = 1, Real initProportion = 0.70f)
{
    mWindow = window;
    mNumGroupsInit = numGroupsInit;
    mNumGroupsLoad = numGroupsLoad;
    mInitProportion = initProportion;
    OverlayManager&	omgr = OverlayManager::getSingleton();

    mLoadOverlay = (Overlay*)omgr.getByName("Core/LoadOverlay");
    if (!mLoadOverlay) {
        OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
                    "Cannot find loading overlay", "LoadingBar::start");
    }
    mLoadOverlay->show();

    // Save links to the bar and to the loading text, for updates as we go
    mLoadingBarElement = omgr.getOverlayElement("Core/LoadPanel/Bar/Progress");
    mLoadingCommentElement = omgr.getOverlayElement("Core/LoadPanel/Comment");
    mLoadingDescriptionElement = omgr.getOverlayElement("Core/LoadPanel/Description");

    OverlayElement* barContainer = omgr.getOverlayElement("Core/LoadPanel/Bar");
    mProgressBarMaxSize = barContainer->getWidth();
    mLoadingBarElement->setWidth(0);

    // self is listener
    ResourceGroupManager::getSingleton().addResourceGroupListener(LogoState::getInstance());
}
Exemplo n.º 5
0
    OverlayElement* OverlayContainer::findElementAt(Real x, Real y)         // relative to parent
    {

        OverlayElement* ret = NULL;

        int currZ = -1;

        if (mVisible)
        {
            ret = OverlayElement::findElementAt(x,y);   //default to the current container if no others are found
            if (ret && mChildrenProcessEvents)
            {
                ChildIterator it = getChildIterator();
                while (it.hasMoreElements())
                {
                    OverlayElement* currentOverlayElement = it.getNext();
                    if (currentOverlayElement->isVisible() && currentOverlayElement->isEnabled())
                    {
                        int z = currentOverlayElement->getZOrder();
                        if (z > currZ)
                        {
                            OverlayElement* elementFound = currentOverlayElement->findElementAt(x ,y );
                            if (elementFound)
                            {
                                currZ = z;
                                ret = elementFound;
                            }
                        }
                    }
                }
            }
        }
        return ret;
    }
 void addTextureDebugOverlay( TrayLocation loc, const String& texname, size_t i )
 {// Create material
   String matName = "Ogre/DebugTexture" + StringConverter::toString( i );
   MaterialPtr debugMat = MaterialManager::getSingleton().getByName( matName );
   if( debugMat.isNull() )
   {
     debugMat = MaterialManager::getSingleton().create( matName,
       ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
   }
   Pass* p = debugMat->getTechnique( 0 )->getPass( 0 );
   p->removeAllTextureUnitStates();
   p->setLightingEnabled( false );
   TextureUnitState *t = p->createTextureUnitState( texname );
   t->setTextureAddressingMode( TextureUnitState::TAM_CLAMP );
   // create template
   if( !OverlayManager::getSingleton().hasOverlayElement( "Ogre/DebugTexOverlay", true ) )
   {
     OverlayElement* e = OverlayManager::getSingleton().createOverlayElement( "Panel", "Ogre/DebugTexOverlay", true );
     e->setMetricsMode( GMM_PIXELS );
     e->setWidth( 128 );
     e->setHeight( 128 );
   }
   // add widget
   String widgetName = "DebugTex" + StringConverter::toString( i );
   Widget* w = mTrayMgr->getWidget( widgetName );
   if( !w )
   {
     w = mTrayMgr->createDecorWidget( loc, widgetName, "Ogre/DebugTexOverlay" );
   }
   w->getOverlayElement()->setMaterialName( matName );
 }
Exemplo n.º 7
0
	//---------------------------------------------------------------------
	void OverlayManager::destroyAllOverlayElementsImpl(ElementMap& elementMap)
	{
		ElementMap::iterator i;

		while ((i = elementMap.begin()) != elementMap.end())
		{
			OverlayElement* element = i->second;

			// Get factory to delete
			FactoryMap::iterator fi = mFactories.find(element->getTypeName());
			if (fi == mFactories.end())
			{
				OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Cannot locate factory for element " 
					+ element->getName(),
					"OverlayManager::destroyAllOverlayElements");
			}

			// remove from parent, if any
			OverlayContainer* parent;
			if ((parent = element->getParent()) != 0)
			{
				parent->_removeChild(element->getName());
			}

			// children of containers will be auto-removed when container is destroyed.
			// destroy the element and remove it from the list
			fi->second->destroyOverlayElement(element);
			elementMap.erase(i);
		}
	}
Exemplo n.º 8
0
void TruckHUD::checkOverflow(Ogre::OverlayElement* e)
{
	int newval = e->getLeft() + e->getWidth() + border;
	if(newval > this->width)
	{
		this->width = newval;
		OverlayElement *panel = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/MainPanel");
		panel->setWidth(width);
	}
}
Exemplo n.º 9
0
  void _setOverlay(void)
  {
    mOverlayMgr = OverlayManager::getSingletonPtr();
    mTextOverlay = mOverlayMgr->create("TextOverlay");

    mPanel = static_cast<Ogre::OverlayContainer*>(mOverlayMgr->createOverlayElement("Panel", "container1"));
    mPanel->setDimensions(1, 1);
    mPanel->setPosition(-0.3f, 0.5f);

    OverlayElement* textBox = mOverlayMgr->createOverlayElement("TextArea", "TextID");
    textBox->setMetricsMode(Ogre::GMM_PIXELS);
    textBox->setPosition(10, 10);
    textBox->setWidth(100);
    textBox->setHeight(20);
    textBox->setParameter("font_name", "Font/NanumBold18");
    textBox->setParameter("char_height", "40");
    textBox->setColour(Ogre::ColourValue::White);
    textBox->setCaption(L"한국산업기술대학교 이대현 선수");
    mPanel->addChild(textBox);

    mTextOverlay->add2D(mPanel);
    mTextOverlay->show();

    mLogoOverlay = OverlayManager::getSingleton().getByName("Overlay/KPU_LOGO");
    mLogoOverlay->show();

mLogoOverlay = OverlayManager::getSingleton().getByName("Overlay/Information");
mLogoOverlay->show(); 
  }
Exemplo n.º 10
0
	bool frameEnded(const FrameEvent &evt)
	{
		// Fill Here -----------------------------------------------
		static Ogre::DisplayString currFps = L"현재 FPS: ";
		static Ogre::DisplayString avgFps = L"평균 FPS: ";
		static Ogre::DisplayString bestFps = L"최고 FPS: ";
		static Ogre::DisplayString worstFps = L"최저 FPS: ";
		OverlayElement* guiAvg =
			OverlayManager::getSingleton().getOverlayElement("AverageFps");
		OverlayElement* guiCurr =
			OverlayManager::getSingleton().getOverlayElement("CurrFps");
		OverlayElement* guiBest =
			OverlayManager::getSingleton().getOverlayElement("BestFps");
		OverlayElement* guiWorst =
			OverlayManager::getSingleton().getOverlayElement("WorstFps");
		const RenderTarget::FrameStats& stats =
			mRoot->getAutoCreatedWindow()->getStatistics();
		guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
		guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
		guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS));
		guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS));
		// ---------------------------------------------------------

		return mContinue;
	}
Exemplo n.º 11
0
    //---------------------------------------------------------------------
    OverlayContainer::~OverlayContainer()
    {
        // remove from parent overlay if root
        if (mOverlay && !mParent)
        {
            mOverlay->remove2D(this);
        }

        OverlayContainer::ChildIterator ci = getChildIterator();
        while (ci.hasMoreElements())
        {
            OverlayElement* child = ci.getNext();
            child->_notifyParent(0, 0);
        }
    }
OgreQtOverlay::OgreQtOverlay(Ogre::Root *root, Ogre::RenderWindow *window, Ogre::uint w, Ogre::uint h, QObject *parent)
 : QGraphicsScene(parent), _width(w), _height(h)
{
	_root = root;
	_window = window;
	_time.start(); //start a timer for key events
	
	//Connect redraw signal to this class
	QObject::connect(this,SIGNAL(changed(QList<QRectF>)),this,SLOT(sceneChanged(QList<QRectF>)));
	
	//qDebug() << "WIDTH:" << _width << "HEIGHT:" << _height;
	
	//create a texture the size of the screen to draw into
	_texture = TextureManager::getSingleton().createManual("OgreQtTexture",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
			,TEX_TYPE_2D,_width,_height,0,PF_A8R8G8B8,TU_DYNAMIC_WRITE_ONLY).getPointer();
	
	//save texture buffer for later
	_buffer = _texture->getBuffer().getPointer();
	
	//Create a material
	MaterialPtr material = MaterialManager::getSingleton().create("DynamicTextureMaterial",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	material->getTechnique(0)->getPass(0)->createTextureUnitState("OgreQtTexture");
	material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
	
	//Load overlay
	_overlay = OverlayManager::getSingleton().getByName("MyOverlays/OgreQt");
	OverlayElement *element = OverlayManager::getSingleton().getOverlayElement("MyOverlayElements/QtPanel");
	element->setMaterialName("DynamicTextureMaterial");
	
	//set the screen rect for the graphicsscene
	float ratio = (float)_width / (float)_height;
	setSceneRect(QRectF(0.0,0.0,_width,_height));
	
	//Create Cursor Pixmap
	_cursor = addPixmap(QPixmap(POINTER_FILE));
	_cursor->scale(POINTER_SCALE_X,POINTER_SCALE_Y);
	_cursor->setZValue(POINTER_Z);
	
	//set some default values
	_modifiers = Qt::NoModifier;
	_lastkeytime=0;
	_repeating=false;
	_lastclicktime = 0;
	_visible=false;
	_overlay->hide();
}
Exemplo n.º 13
0
    OverlayElement* OverlayContainer::clone(const String& instanceName)
    {
        OverlayContainer *newContainer;

        newContainer = static_cast<OverlayContainer*>(OverlayElement::clone(instanceName));

          ChildIterator it = getChildIterator();
          while (it.hasMoreElements())
              {
                    OverlayElement* oldChildElement = it.getNext();
                    if (oldChildElement->isCloneable())
                    {
                OverlayElement* newChildElement = oldChildElement->clone(instanceName);
                newContainer->_addChild(newChildElement);
            }
        }

        return newContainer;
    }
Exemplo n.º 14
0
    //---------------------------------------------------------------------
    void OverlayContainer::_removeChild(const String& name)
    {
        ChildMap::iterator i = mChildren.find(name);
        if (i == mChildren.end())
        {
            OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Child with name " + name + 
                " not found.", "OverlayContainer::removeChild");
        }

        OverlayElement* element = i->second;
        mChildren.erase(i);

        // Remove from container list (if found)
        ChildContainerMap::iterator j = mChildContainers.find(name);
        if (j != mChildContainers.end())
            mChildContainers.erase(j);

        element->_setParent(0);
    }
Exemplo n.º 15
0
    //---------------------------------------------------------------------
	OverlayElement* Overlay::findElementAt(Real x, Real y)
	{
		OverlayElement* ret = NULL;
		int currZ = -1;
        OverlayContainerList::iterator i, iend;
        iend = m2DElements.end();
        for (i = m2DElements.begin(); i != iend; ++i)
        {
			int z = (*i)->getZOrder();
			if (z > currZ)
			{
				OverlayElement* elementFound = (*i)->findElementAt(x,y);
				if(elementFound)
				{
					currZ = elementFound->getZOrder();
					ret = elementFound;
				}
			}
        }
		return ret;
	}
 //-----------------------------------------------------------------------
 void OverlayProfileSessionListener::finializeSession()
 {
     OverlayContainer* container = dynamic_cast<OverlayContainer*>(mProfileGui);
     if (container)
     {
         OverlayContainer::ChildIterator children = container->getChildIterator();
         while (children.hasMoreElements())
         {
             OverlayElement* element = children.getNext();
             OverlayContainer* parent = element->getParent();
             if (parent) parent->removeChild(element->getName());
             OverlayManager::getSingleton().destroyOverlayElement(element);
         }
     }
     if(mProfileGui)
         OverlayManager::getSingleton().destroyOverlayElement(mProfileGui);
     if(mOverlay)
         OverlayManager::getSingleton().destroy(mOverlay);           
         
     mProfileBars.clear();
 }
Exemplo n.º 17
0
	void DebugText::updateStats(Ogre::String text)
	{
		static String currFps = "Current FPS: ";
		//static String avgFps = "Average FPS: ";
		//static String bestFps = "Best FPS: ";
		//static String worstFps = "Worst FPS: ";
		//static String tris = "Triangle Count: ";

		// update stats when necessary
		OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
		OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
		OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
		OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");
		
		guiAvg->hide();
		//guiCurr->hide();
		guiBest->hide();
		guiWorst->hide();

		//OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");

		/*guiAvg->setCaption(avgFps + StringConverter::toString(mWindow->getAverageFPS()));*/
		guiCurr->setCaption(currFps + StringConverter::toString(mWindow->getLastFPS()));
		//guiBest->setCaption(bestFps + StringConverter::toString(mWindow->getBestFPS())
		//	+" "+StringConverter::toString(mWindow->getBestFrameTime())+" ms");
		//guiWorst->setCaption(worstFps + StringConverter::toString(mWindow->getWorstFPS())
		//	+" "+StringConverter::toString(mWindow->getWorstFrameTime())+" ms");

		//OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
		//guiTris->setCaption(tris + StringConverter::toString(mWindow->getTriangleCount()));

		OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
		guiDbg->setCaption(text);
		//guiDbg->setPosition(0,0);

		
		//mDebugOverlay->

	}
Exemplo n.º 18
0
    //-----------------------------------------------------------------------
    void Profiler::setEnabled(bool enabled) 
	{
        if (!mInitialized && enabled) 
		{
            // the user wants to enable the Profiler for the first time
            // so we initialize the GUI stuff
            initialize();
            mInitialized = true;
        }
        else
        {
            OverlayContainer* container = dynamic_cast<OverlayContainer*>(mProfileGui);
			if (container)
			{
				OverlayContainer::ChildIterator children = container->getChildIterator();
				while (children.hasMoreElements())
				{
                    OverlayElement* element = children.getNext();
                    OverlayContainer* parent = element->getParent();
                    if (parent) parent->removeChild(element->getName());
                    OverlayManager::getSingleton().destroyOverlayElement(element);
				}
			}
            if(mProfileGui)
                OverlayManager::getSingleton().destroyOverlayElement(mProfileGui);
            if(mOverlay)
                OverlayManager::getSingleton().destroy(mOverlay);			
			
			mProfileBars.clear();
            mInitialized = false;
			mEnabled = false;
        }
        // We store this enable/disable request until the frame ends
        // (don't want to screw up any open profiles!)
        mNewEnableState = enabled;
    }
    //-----------------------------------------------------------------------
    OverlayElement* OverlayProfileSessionListener::createPanel(const String& name, Real width, Real height, Real top, Real left, 
                                      const String& materialName, bool show)
    {
        OverlayElement* panel = 
            OverlayManager::getSingleton().createOverlayElement("Panel", name);
        panel->setMetricsMode(GMM_PIXELS);
        panel->setWidth(width);
        panel->setHeight(height);
        panel->setTop(top);
        panel->setLeft(left);
        panel->setMaterialName(materialName);

        if (show) {
            panel->show();
        }
        else {
            panel->hide();
        }

        return panel;
    }
Exemplo n.º 20
0
    void OverlayContainer::copyFromTemplate(OverlayElement* templateOverlay)
    {
        OverlayElement::copyFromTemplate(templateOverlay);

            if (templateOverlay->isContainer() && isContainer())
            {
             OverlayContainer::ChildIterator it = static_cast<OverlayContainer*>(templateOverlay)->getChildIterator();
             while (it.hasMoreElements())
             {
                 OverlayElement* oldChildElement = it.getNext();
                 if (oldChildElement->isCloneable())
                 {
                     OverlayElement* newChildElement = 
                         OverlayManager::getSingleton().createOverlayElement(
                            oldChildElement->getTypeName(), 
                            mName+"/"+oldChildElement->getName());
                     newChildElement->copyFromTemplate(oldChildElement);
                     addChild(static_cast<OverlayContainer*>(newChildElement));
                 }
             }
        }
    }
Exemplo n.º 21
0
void LogoState::createOverlays()
{
    OverlayManager&	omgr = OverlayManager::getSingleton();
    mCurrentOverlay = -1;

    mOverlayGuys = (Overlay*)omgr.getByName("Marbles/Guys");
    OverlayElement* Guys = omgr.getOverlayElement("Marbles/GuysPanel");
    Guys->setPosition(mViewport->getActualWidth()/2 - 430, mViewport->getActualHeight()/2 - 320);

    mOverlay4Guys = (Overlay*)omgr.getByName("Marbles/4Guys");
    OverlayElement* FourGuys = omgr.getOverlayElement("Marbles/4GuysPanel");
    FourGuys->setPosition(mViewport->getActualWidth()/2 - 430, mViewport->getActualHeight()/2 + 145);

    mOverlay4G = (Overlay*)omgr.getByName("Marbles/4G");
    OverlayElement* FourG = omgr.getOverlayElement("Marbles/4GPanel");
    FourG->setPosition(mViewport->getActualWidth()/2 - 430, mViewport->getActualHeight()/2 + 145);

    mOverlayGirl = (Overlay*)omgr.getByName("Marbles/Girl");
    OverlayElement* Girl = omgr.getOverlayElement("Marbles/GirlPanel");
    Girl->setPosition(mViewport->getActualWidth()/2 - 190, mViewport->getActualHeight()/2 - 320);

    mOverlay1Girl = (Overlay*)omgr.getByName("Marbles/1Girl");
    OverlayElement* OneGirl = omgr.getOverlayElement("Marbles/1GirlPanel");
    OneGirl->setPosition(mViewport->getActualWidth()/2 - 190, mViewport->getActualHeight()/2 + 145);

    mOverlay1G = (Overlay*)omgr.getByName("Marbles/1G");
    OverlayElement* OneG = omgr.getOverlayElement("Marbles/1GPanel");
    OneG->setPosition(mViewport->getActualWidth()/2 - 190, mViewport->getActualHeight()/2 + 145);

    mOverlayGame = (Overlay*)omgr.getByName("Marbles/Game");
    OverlayElement* Game = omgr.getOverlayElement("Marbles/GamePanel");
    Game->setPosition(mViewport->getActualWidth()/2 - 450, mViewport->getActualHeight()/2 - 320);

    mOverlay1Game = (Overlay*)omgr.getByName("Marbles/1Game");
    OverlayElement* OneGame = omgr.getOverlayElement("Marbles/1GamePanel");
    OneGame->setPosition(mViewport->getActualWidth()/2 + 20, mViewport->getActualHeight()/2 + 145);

    mOverlay1Gsq = (Overlay*)omgr.getByName("Marbles/1Gsq");
    OverlayElement* OneGsq = omgr.getOverlayElement("Marbles/1GsqPanel");
    OneGsq->setPosition(mViewport->getActualWidth()/2 - 236, mViewport->getActualHeight()/2 + 145);

    mOverlaypresents = (Overlay*)omgr.getByName("Marbles/presents");
    OverlayElement* presents = omgr.getOverlayElement("Marbles/presentsPanel");
    presents->setPosition(mViewport->getActualWidth()/2 + 120, mViewport->getActualHeight()/2 + 190);

    mOverlayplugins = (Overlay*)omgr.getByName("Marbles/plugins");
    OverlayElement* plugins = omgr.getOverlayElement("Marbles/pluginsPanel");
    plugins->setPosition(mViewport->getActualWidth()/2 - 512, mViewport->getActualHeight()/2 - 393);

    mOverlayskip = (Overlay*)omgr.getByName("Marbles/skip");
    OverlayElement* skip = omgr.getOverlayElement("Marbles/skipPanel");
    skip->setPosition(mViewport->getActualWidth()/2 - 186, mViewport->getActualHeight() -75);
}
Exemplo n.º 22
0
	Movable *Level::createMovable (XmlFile *file, int type, std::string name, Movable *parent, XMLElement *element, bool createNow)
	{
		Movable *objObject = 0;

		if (type == GOT_ENTITY)
		{
			Entity *eEntity = new Entity (name);

			if (element != 0)
				eEntity->parseXML (file, element, parent);

			if (createNow == true)
				eEntity->create (parent);

			objObject = eEntity;
		}

		if (type == GOT_CAMERA)
		{
			Camera *cCamera = new Camera (name);

			if (element != 0)
				cCamera->parseXML (file, element, parent);

			if (createNow == true)
				cCamera->create (0, parent);

			objObject = cCamera;
		}

		if (type == GOT_PARTICLE_SYSTEM)
		{
			ParticleSystem *psSystem = new ParticleSystem (name);

			if (element != 0)
				psSystem->parseXML (file, element, parent);

			if (createNow == true)
				psSystem->create (parent);

			objObject = psSystem;
		}

		if (type == GOT_LIGHT)
		{
			Light *lLight = new Light (name);

			if (element != 0)
				lLight->parseXML (file, element, parent);

			if (createNow == true)
				lLight->create (parent);

			objObject = lLight;
		}

		if (type == GOT_ANIMATION_TRACK)
		{
			AnimationTrackObject *atoObject = new AnimationTrackObject (name);

			if (element != 0)
				atoObject->parseXML (file, element, parent);

			if (createNow == true)
				atoObject->create (parent);

			objObject = atoObject;
			aryAnimations.push_back (atoObject);
		}

		if (type == GOT_AUDIO_LISTENER)
		{
			AudioListener *alListener = new AudioListener (name);

			if (element != 0)
				alListener->parseXML (file, element, parent);

			if (createNow == true)
				alListener->create (parent);

			objObject = alListener;
		}

		if (type == GOT_SOUND)
		{
			Sound *sSound = new Sound (name);

			if (element != 0)
				sSound->parseXML (file, element, parent);

			if (createNow == true)
				sSound->create (parent);

			objObject = sSound;
		}

		if (type == GOT_OVERLAY)
		{
			Overlay *oOverlay = new Overlay (name);

			if (element != 0)
				oOverlay->parseXML (file, element, parent);

			if (createNow == true)
				oOverlay->create (parent);

			aryOverlays.push_back (oOverlay);
			objObject = oOverlay;
		}

		if (type == GOT_OVERLAY_ELEMENT)
		{
			OverlayElement *oOverlayElement = new OverlayElement (name);

			if (element != 0)
				oOverlayElement->parseXML (file, element, parent);

			if (createNow == true)
				oOverlayElement->create (parent);

			aryOverlayElements.push_back (oOverlayElement);
			objObject = oOverlayElement;
		}

		addMovable (objObject);

		return (objObject);
	}
Exemplo n.º 23
0
    //-----------------------------------------------------------------------
    OverlayElement* Profiler::createTextArea(const String& name, Real width, Real height, Real top, Real left, 
                                         uint fontSize, const String& caption, bool show) {


        OverlayElement* textArea = 
			OverlayManager::getSingleton().createOverlayElement("TextArea", name);
        textArea->setMetricsMode(GMM_PIXELS);
        textArea->setWidth(width);
        textArea->setHeight(height);
        textArea->setTop(top);
        textArea->setLeft(left);
        textArea->setParameter("font_name", "BlueHighway");
        textArea->setParameter("char_height", StringConverter::toString(fontSize));
        textArea->setCaption(caption);
        textArea->setParameter("colour_top", "1 1 1");
        textArea->setParameter("colour_bottom", "1 1 1");

        if (show) {
            textArea->show();
        }
        else {
            textArea->hide();
        }

        return textArea;

    }
void OgreFramework::UpdateStats()
{
	static String currFps = "Current FPS: ";
    static String avgFps = "Average FPS: ";
    static String bestFps = "Best FPS: ";
    static String worstFps = "Worst FPS: ";
    static String tris = "Triangle Count: ";
    static String batches = "Batch Count: ";

    OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
    OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
    OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
    OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");

	const RenderTarget::FrameStats& stats = m_renderWnd->getStatistics();
    guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
    guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
    guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS)
            +" "+StringConverter::toString(stats.bestFrameTime)+" ms");
    guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)
            +" "+StringConverter::toString(stats.worstFrameTime)+" ms");

    OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
    guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount));

	OverlayElement* guiBatches = OverlayManager::getSingleton().getOverlayElement("Core/NumBatches");
    guiBatches->setCaption(batches + StringConverter::toString(stats.batchCount));

	OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
	guiDbg->setCaption("");
}
    //-----------------------------------------------------------------------
    void OverlayProfileSessionListener::displayResults(ProfileInstance* instance, ProfileBarList::const_iterator& bIter, Real& maxTimeMillisecs, Real& newGuiHeight, int& profileCount)
    {
        OverlayElement* g;

        // display the profile's name and the number of times it was called in a frame
        g = *bIter;
        ++bIter;
        g->show();
        g->setCaption(String(instance->name + " (" + StringConverter::toString(instance->history.numCallsThisFrame) + ")"));
        g->setLeft(10 + instance->hierarchicalLvl * 15.0f);


        // display the main bar that show the percentage of the frame time that this
        // profile has taken
        g = *bIter;
        ++bIter;
        g->show();
        // most of this junk has been set before, but we do this to get around a weird
        // Ogre gui issue (bug?)
        g->setMetricsMode(GMM_PIXELS);
        g->setHeight(mBarHeight);

        if (mDisplayMode == DISPLAY_PERCENTAGE)
            g->setWidth( (instance->history.currentTimePercent) * mGuiWidth);
        else
            g->setWidth( (instance->history.currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth);

        g->setLeft(mGuiWidth);
        g->setTop(mGuiBorderWidth + profileCount * (mBarHeight + mBarSpacing));



        // display line to indicate the minimum frame time for this profile
        g = *bIter;
        ++bIter;
        g->show();
        if(mDisplayMode == DISPLAY_PERCENTAGE)
            g->setLeft(mBarIndent + instance->history.minTimePercent * mGuiWidth);
        else
            g->setLeft(mBarIndent + (instance->history.minTimeMillisecs / maxTimeMillisecs) * mGuiWidth);

        // display line to indicate the maximum frame time for this profile
        g = *bIter;
        ++bIter;
        g->show();
        if(mDisplayMode == DISPLAY_PERCENTAGE)
            g->setLeft(mBarIndent + instance->history.maxTimePercent * mGuiWidth);
        else
            g->setLeft(mBarIndent + (instance->history.maxTimeMillisecs / maxTimeMillisecs) * mGuiWidth);

        // display line to indicate the average frame time for this profile
        g = *bIter;
        ++bIter;
        g->show();
        if(instance->history.totalCalls != 0)
        {
            if (mDisplayMode == DISPLAY_PERCENTAGE)
                g->setLeft(mBarIndent + (instance->history.totalTimePercent / instance->history.totalCalls) * mGuiWidth);
            else
                g->setLeft(mBarIndent + ((instance->history.totalTimeMillisecs / instance->history.totalCalls) / maxTimeMillisecs) * mGuiWidth);
        }
        else
            g->setLeft(mBarIndent);

        // display text
        g = *bIter;
        ++bIter;
        g->show();
        if (mDisplayMode == DISPLAY_PERCENTAGE)
        {
            g->setLeft(mBarIndent + instance->history.currentTimePercent * mGuiWidth + 2);
            g->setCaption(StringConverter::toString(instance->history.currentTimePercent * 100.0f, 3, 3) + "%");
        }
        else
        {
            g->setLeft(mBarIndent + (instance->history.currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth + 2);
            g->setCaption(StringConverter::toString(instance->history.currentTimeMillisecs, 3, 3) + "ms");
        }

        // we set the height of the display with respect to the number of profiles displayed
        newGuiHeight += mBarHeight + mBarSpacing;

        ++profileCount;

        // display children
        ProfileInstance::ProfileChildren::const_iterator it = instance->children.begin(), endit = instance->children.end();
        for(;it != endit; ++it)
        {
            ProfileInstance* child = it->second;
            displayResults(child, bIter, maxTimeMillisecs, newGuiHeight, profileCount);
        }
    }
Exemplo n.º 26
0
	//---------------------------------------------------------------------
	OverlayElement* OverlayManager::cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName)
	{
		OverlayElement* templateGui = getOverlayElement(templateName, true);
		return templateGui->clone(instanceName);
	}
Exemplo n.º 27
0
    //-----------------------------------------------------------------------
    void Profiler::displayResults() {

        if (!mEnabled) {

            return;

        }

        // if its time to update the display
        if (!(mCurrentFrame % mUpdateDisplayFrequency)) {


            ProfileHistoryList::iterator iter;
            ProfileBarList::iterator bIter;

            OverlayElement* g;

            Real newGuiHeight = mGuiHeight;

            int profileCount = 0; 

			Real maxTimeMillisecs = (Real)mMaxTotalFrameTime / 1000.0f;

            // go through each profile and display it
            for (iter = mProfileHistory.begin(), bIter = mProfileBars.begin(); 
				iter != mProfileHistory.end() && bIter != mProfileBars.end(); 
				++iter, ++bIter) 
			{

                // display the profile's name and the number of times it was called in a frame
                g = *bIter;
                g->show();
                g->setCaption(String((*iter).name + " (" + StringConverter::toString((*iter).numCallsThisFrame) + ")"));
                g->setLeft(10 + (*iter).hierarchicalLvl * 15.0f);

                // display the main bar that show the percentage of the frame time that this
                // profile has taken
                bIter++;
                g = *bIter;
                g->show();
                // most of this junk has been set before, but we do this to get around a weird
                // Ogre gui issue (bug?)
                g->setMetricsMode(GMM_PIXELS);
                g->setHeight(mBarHeight);
				if (mDisplayMode == DISPLAY_PERCENTAGE)
					g->setWidth(((*iter).currentTimePercent) * mGuiWidth);
				else
					g->setWidth(((*iter).currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth);
                g->setLeft(mGuiWidth);
                g->setTop(mGuiBorderWidth + profileCount * (mBarHeight + mBarSpacing));

                // display line to indicate the minimum frame time for this profile
                bIter++;
                g = *bIter;
                g->show();
				if (mDisplayMode == DISPLAY_PERCENTAGE)
		            g->setLeft(mBarIndent + (*iter).minTimePercent * mGuiWidth);
				else
					g->setLeft(mBarIndent + ((*iter).minTimeMillisecs / maxTimeMillisecs) * mGuiWidth);

                // display line to indicate the maximum frame time for this profile
                bIter++;
                g = *bIter;
                g->show();
				if (mDisplayMode == DISPLAY_PERCENTAGE)
	                g->setLeft(mBarIndent + (*iter).maxTimePercent * mGuiWidth);
				else
					g->setLeft(mBarIndent + ((*iter).maxTimeMillisecs / maxTimeMillisecs) * mGuiWidth);
                // display line to indicate the average frame time for this profile
                bIter++;
                g = *bIter;
                g->show();
                if ((*iter).totalCalls != 0)
					if (mDisplayMode == DISPLAY_PERCENTAGE)
	                    g->setLeft(mBarIndent + ((*iter).totalTimePercent / (*iter).totalCalls) * mGuiWidth);
					else
						g->setLeft(mBarIndent + (((*iter).totalTimeMillisecs / (*iter).totalCalls) / maxTimeMillisecs) * mGuiWidth);
                else
                    g->setLeft(mBarIndent);

				// display text
				bIter++;
				g = *bIter;
				g->show();
				if (mDisplayMode == DISPLAY_PERCENTAGE)
				{
					g->setLeft(mBarIndent + (*iter).currentTimePercent * mGuiWidth + 2);
					g->setCaption(StringConverter::toString((*iter).currentTimePercent * 100.0f, 3, 3) + "%");
				}
				else
				{
					g->setLeft(mBarIndent + ((*iter).currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth + 2);
					g->setCaption(StringConverter::toString((*iter).currentTimeMillisecs, 3, 3) + "ms");
				}

				// we set the height of the display with respect to the number of profiles displayed
                newGuiHeight += mBarHeight + mBarSpacing;

                profileCount++;

            }

            // set the main display dimensions
            mProfileGui->setMetricsMode(GMM_PIXELS);
            mProfileGui->setHeight(newGuiHeight);
            mProfileGui->setWidth(mGuiWidth * 2 + 15);
            mProfileGui->setTop(5);
            mProfileGui->setLeft(5);

            // we hide all the remaining pre-created bars
            for (; bIter != mProfileBars.end(); ++bIter) {

                (*bIter)->hide();

            }

        }

		mCurrentFrame++;

    }
Exemplo n.º 28
0
void CoreListener::updateStats(void)
{
	static String currFps = "Current FPS: ";
    static String avgFps = "Average FPS: ";
    static String bestFps = "Best FPS: ";
    static String worstFps = "Worst FPS: ";
    static String tris = "Triangle Count: ";
    static String missTime = "Mission Time: ";

    // update stats when necessary
    try {
        OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("USCA/AverageFps");
        OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("USCA/CurrFps");
        OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("USCA/BestFps");
        OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("USCA/WorstFps");
        OverlayElement* guiTime = OverlayManager::getSingleton().getOverlayElement("USCA/MissionTime");

		const RenderTarget::FrameStats& stats = Shmoulette::Core::getSingleton()->getWindow()->getStatistics();

		guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS)+"("+ts(Shmoulette::Level::getSingleton()->getCurrentSegment()->getTimeTrack())+")");
        guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
        guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS)
            +" "+StringConverter::toString(stats.bestFrameTime)+" ms");
        guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)
            +" "+StringConverter::toString(stats.worstFrameTime)+" ms");
		guiTime->setCaption(missTime + ts(Level::getSingleton()->getCurrentSegment()->getTimeTrack())
            +" "+StringConverter::toString(stats.worstFrameTime)+" secs");
        OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("USCA/NumTris");
        guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount));

        OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("USCA/DebugText");
        //guiDbg->setCaption(Shmoulette::Core::getSingleton()->getWindow()->getDe->getDebugText());
    }
    catch(...)
    {
        // ignore
    }
}
Exemplo n.º 29
0
void COgreFrameListener::updateStats(void)
{
	static String currFps = "Current FPS: ";
	static String avgFps = "Average FPS: ";
	static String bestFps = "Best FPS: ";
	static String worstFps = "Worst FPS: ";
	static String tris = "Triangle Count: ";
	static String batches = "Batch Count: ";

	// update stats when necessary
	try {
		OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
		OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
		OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
		OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");

		const RenderTarget::FrameStats& stats = m_pRenderWindow->getStatistics();
		guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
		guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
		guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS)
			+" "+StringConverter::toString(stats.bestFrameTime)+" ms");
		guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)
			+" "+StringConverter::toString(stats.worstFrameTime)+" ms");

		OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
		guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount));

		OverlayElement* guiBatches = OverlayManager::getSingleton().getOverlayElement("Core/NumBatches");
		guiBatches->setCaption(batches + StringConverter::toString(stats.batchCount));
	}
	catch(...) { /* ignore */ }
}
Exemplo n.º 30
0
bool TruckHUD::update(float dt, Beam *truck, bool visible)
{
	OverlayElement *overlayElement = 0;

	// only update every 300 ms
	if (visible)
	{
		updatetime -= dt;
		if (updatetime <= 0.0f)
		{
			// update now, reset timer
			updatetime = 0.3f;
		} else
		{
			// don't update visuals, only count stats
			visible = false;
		}
	}

	if (visible)
	{
		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/Truckname");
		overlayElement->setCaption(truck->getTruckName());
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/Truckauthor");
		overlayElement->setCaption(_L("(no author information available)"));
		std::vector<authorinfo_t> file_authors = truck->getAuthors();
		if (!file_authors.empty())
		{
			String authors = "";
			for (std::vector<authorinfo_t>::iterator it = file_authors.begin(); it != file_authors.end(); ++it)
			{
				authors += (*it).name + " ";
			}
			overlayElement->setCaption(_L("Authors: ") + authors);
		}
		checkOverflow(overlayElement);

		std::vector<std::string> description = truck->getDescription();
		for (unsigned int i=1; i < 3; i++)
		{
			overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/DescriptionLine" + TOSTRING(i+1));
			overlayElement->setCaption("");
			if (i < description.size())
			{
				overlayElement->setCaption(ANSI_TO_UTF(description[i]));
			}
			checkOverflow(overlayElement);
		}

		beam_t *beam = truck->getBeams();
		float average_deformation = 0.0f;
		float beamstress = 0.0f;
		float current_deformation = 0.0f;
		float mass = truck->getTotalMass();
		int beamCount = truck->getBeamCount();
		int beambroken = 0;
		int beamdeformed = 0;

		for (int i=0; i < beamCount; i++, beam++)
		{
			if (beam->broken != 0)
			{
				beambroken++;
			}
			beamstress += beam->stress;
			current_deformation = fabs(beam->L-beam->refL);
			if (fabs(current_deformation) > 0.0001f && beam->type != BEAM_HYDRO && beam->type != BEAM_INVISIBLE_HYDRO)
			{
				beamdeformed++;
			}
			average_deformation += current_deformation;
		}

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamTotal");
		overlayElement->setCaption(_L("beam count: ") + TOUTFSTRING(beamCount));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamBroken");
		overlayElement->setCaption(_L("broken: ") + TOUTFSTRING(beambroken) + U(" (") + TOUTFSTRING(Round((float)beambroken / (float)beamCount, 2) * 100.0f) + U("%)"));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamHealth");
		float health = ((float)beambroken / (float)beamCount) * 10.0f + ((float)beamdeformed / (float)beamCount);
		if (health < 1.0f)
		{
			overlayElement->setCaption(_L("health: ") + TOUTFSTRING(Round((1.0f - health) * 100.0f, 2)) + U("%"));
			overlayElement->setColour(ColourValue(0.6f, 0.8f, 0.4f, 1.0f));
		} else if (health >= 1.0f)
		{
			health = ((float)beambroken / (float)beamCount) * 3.0f;
			health = std::min(health, 1.0f);
			overlayElement->setCaption(_L("destruction: ") + TOUTFSTRING(Round(health * 100.0f, 2)) + U("%"));
			overlayElement->setColour(ColourValue(0.8f, 0.4f, 0.4f, 1.0f));
		}
		checkOverflow(overlayElement);


		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/BeamDeformed");
		overlayElement->setCaption(_L("deformed: ") + TOUTFSTRING(beamdeformed) + U(" (") + TOUTFSTRING(Round((float)beamdeformed / (float)beamCount, 2) * 100.0f) + U("%)"));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/AverageBeamDeformation");
		overlayElement->setCaption(_L("average deformation: ") + TOUTFSTRING(Round((float)average_deformation / (float)beamCount, 4) * 100.0f));
		checkOverflow(overlayElement);
		
		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/AverageBeamStress");
		wchar_t beamstressstr[256];
		swprintf(beamstressstr, 256, L"%+08.0f", 1-(float)beamstress/(float)beamCount);
		overlayElement->setCaption(_L("average stress: ") + UTFString(beamstressstr));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/NodeCount");
		int ncount = truck->getNodeCount();
		int wcount =  truck->getWheelNodeCount();
		wchar_t nodecountstr[256];
		swprintf(nodecountstr, 256, L"%d (wheels: %d)", ncount, wcount);
		overlayElement->setCaption(_L("node count: ") + UTFString(nodecountstr));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/TruckWeight");
		wchar_t truckmassstr[256];
		UTFString massstr = _L("current mass:");
		swprintf(truckmassstr, 256, L"%ls %8.2f kg (%.2f tons)", massstr.asWStr_c_str(), mass, mass / 1000.0f);
		overlayElement->setCaption(UTFString(truckmassstr));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/Gees");
		wchar_t geesstr[256];
		Vector3 gees = truck->getGForces();
		// apply deadzones ==> no flickering +/-
		if (fabs(gees.y) < 0.01) gees.y = 0.0f;
		if (fabs(gees.z) < 0.01) gees.z = 0.0f;
		UTFString tmp = _L("Gees: Vertical %1.2fg // Saggital %1.2fg // Lateral %1.2fg");
		swprintf(geesstr, 256, tmp.asWStr_c_str(), gees.x, gees.y, gees.z);
		overlayElement->setCaption(UTFString(geesstr));
		checkOverflow(overlayElement);

		// max g-forces
		if (truck->driveable == TRUCK || truck->driveable == AIRPLANE || truck->driveable == BOAT)
		{
			if (gees.x > maxPosVerG[truck->driveable])
				maxPosVerG[truck->driveable] = gees.x;
			if (gees.x < maxNegVerG[truck->driveable])
				maxNegVerG[truck->driveable] = gees.x;

			if (gees.y > maxPosSagG[truck->driveable])
				maxPosSagG[truck->driveable] = gees.y;
			if (gees.y < maxNegSagG[truck->driveable])
				maxNegSagG[truck->driveable] = gees.y;

			if (gees.z > maxPosLatG[truck->driveable])
				maxPosLatG[truck->driveable] = gees.z;
			if (gees.z < maxNegLatG[truck->driveable])
				maxNegLatG[truck->driveable] = gees.z;

			tmp = _L("maxG: V %1.2fg %1.2fg // S %1.2fg %1.2fg // L %1.2fg %1.2fg");
			swprintf(geesstr, 256, tmp.asWStr_c_str(),
					maxPosVerG[truck->driveable],
					maxNegVerG[truck->driveable],
					maxPosSagG[truck->driveable],
					maxNegSagG[truck->driveable],
					maxPosLatG[truck->driveable],
					maxNegLatG[truck->driveable]
				);

			overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/Gees2");
			overlayElement->setCaption(UTFString(geesstr));
			checkOverflow(overlayElement);
		}
	}

	Vector3 hdir = Vector3::ZERO;
	if (truck->cameranodepos[0] >= 0 && truck->cameranodepos[0] < MAX_NODES)
	{
		hdir = (truck->nodes[truck->cameranodepos[0]].RelPosition - truck->nodes[truck->cameranodedir[0]].RelPosition).normalisedCopy();
	}
	float g_along_hdir = hdir.dotProduct(truck->ffforce / 10000.0f);

	// always update these statistics, also if not visible!
	overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/CurrentRPM");
	overlayElement->setCaption("");
	UTFString rpmsstr = _L("current RPM:");
	if (truck->driveable == TRUCK && truck->engine)
	{
		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/CurrentRPM");
		overlayElement->setCaption(rpmsstr + U(" ") + TOUTFSTRING(Round(truck->engine->getRPM())) + U(" / ") + TOUTFSTRING(Round(truck->engine->getMaxRPM())));
	} else if (truck->driveable == AIRPLANE)
	{
		for (int i=0; i < 8; i++)
		{
			if (truck->aeroengines[i])
			{
				rpmsstr = rpmsstr + U(" / ") + TOUTFSTRING(Round(truck->aeroengines[i]->getRPM()));
			}
		}
		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/CurrentRPM");
		overlayElement->setCaption(UTFString(rpmsstr));
	}
	checkOverflow(overlayElement);

	UTFString cspeedstr   = _L("current Speed:") + U(" ");
	UTFString mspeedstr   = _L("max Speed:")     + U(" ");
	UTFString altitudestr = _L("Altitude:")      + U(" ");

	if (truck->driveable == TRUCK)
	{
		maxVelos[truck->driveable] = std::max(maxVelos[truck->driveable], truck->WheelSpeed);
		minVelos[truck->driveable] = std::min(truck->WheelSpeed, minVelos[truck->driveable]);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/CurrentVelocity");
		
		float velocityKMH = truck->WheelSpeed* 3.6f;
		float velocityMPH = truck->WheelSpeed * 2.23693629f;
		// apply a deadzone ==> no flickering +/-
		if (fabs(truck->WheelSpeed) < 1.0f)
		{
			velocityKMH = velocityMPH = 0.0f;
		}
		overlayElement->setCaption(cspeedstr + TOUTFSTRING(Round(velocityKMH)) + U(" km/h (") + TOUTFSTRING(Round(velocityMPH)) + U(" mph)"));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/MaxVelocity");
		float velocityMaxKMH = maxVelos[truck->driveable] * 3.6f;
		float velocityMinKMH = minVelos[truck->driveable] * 3.6f;
		float velocityMaxMPH = maxVelos[truck->driveable] * 2.23693629f;
		float velocityMinMPH = minVelos[truck->driveable] * 2.23693629f;
		overlayElement->setCaption(mspeedstr + TOUTFSTRING(Round(velocityMaxKMH)) + U("km/h (") + TOUTFSTRING(Round(velocityMaxMPH)) + U("mph)") + U(", min: ") + TOUTFSTRING(Round(velocityMinKMH)) + U("km/h (") + TOUTFSTRING(Round(velocityMinMPH)) + U("mph)"));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/AverageVelocity");
		overlayElement->setCaption("");
	} else if (truck->driveable == AIRPLANE || truck->driveable == BOAT)
	{
		float velocity = truck->nodes[0].Velocity.length();
		
		if (truck->cameranodepos[0] >= 0 && truck->cameranodedir[0] && truck->driveable == BOAT)
		{
			hdir = (truck->nodes[truck->cameranodepos[0]].RelPosition - truck->nodes[truck->cameranodedir[0]].RelPosition).normalisedCopy();
			velocity = hdir.dotProduct(truck->nodes[truck->cameranodepos[0]].Velocity);
		}
		
		maxVelos[truck->driveable] = std::max(maxVelos[truck->driveable], velocity);
		minVelos[truck->driveable] = std::min(velocity, minVelos[truck->driveable]);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/CurrentVelocity");
		float velocityKN = velocity * 1.94384449f;
		// apply a deadzone ==> no flickering +/-
		if (fabs(velocity) < 1.0f)
		{
			velocityKN = 0.0f;
		}
		overlayElement->setCaption(cspeedstr + TOUTFSTRING(Round(velocityKN)) + U(" kn"));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/MaxVelocity");
		float velocityMaxKN = maxVelos[truck->driveable] * 1.94384449f;
		float velocityMinKN = minVelos[truck->driveable] * 1.94384449f;
		overlayElement->setCaption(mspeedstr + TOUTFSTRING(Round(maxVelos[truck->driveable])) + U(" kn, min: ") + TOUTFSTRING(Round(minVelos[truck->driveable])) + U(" kn"));
		checkOverflow(overlayElement);

		overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/AverageVelocity");
		overlayElement->setCaption("");
		if (truck->driveable == AIRPLANE)
		{
			float altitude = truck->nodes[0].AbsPosition.y * 1.1811f;
			overlayElement->setCaption(altitudestr + TOUTFSTRING(Round(altitude)) + U(" m"));
			checkOverflow(overlayElement);
		}
	} else if (truck->driveable == MACHINE)
	{
		OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/MaxVelocity")->setCaption("");
		OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/CurrentVelocity")->setCaption("");
		OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/AverageVelocity")->setCaption("");
	}

	OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/TimeStats")->setCaption("");

	if (visible)
	{
		// update commands

		// clear them first
		for (int i=1; i <= COMMANDS_VISIBLE; i++)
		{
			overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/Command" + TOSTRING(i));
			overlayElement->setCaption("");
		}

		int filledCommands = 0;
		for (int i=1; i < MAX_COMMANDS && filledCommands < COMMANDS_VISIBLE; i += 2)
		{
			if(truck->commandkey[i].beams.empty() || truck->commandkey[i].description == "hide") continue;

			filledCommands++;
			char commandID[256] = {};
			String keyStr = "";

			sprintf(commandID, "COMMANDS_%02d", i);
			int eventID = RoR::Application::GetInputEngine()->resolveEventName(String(commandID));
			String keya = RoR::Application::GetInputEngine()->getEventCommand(eventID);
			sprintf(commandID, "COMMANDS_%02d", i+1);
			eventID = RoR::Application::GetInputEngine()->resolveEventName(String(commandID));
			String keyb = RoR::Application::GetInputEngine()->getEventCommand(eventID);

			// cut off expl
			if (keya.size() > 6 && keya.substr(0,5) == "EXPL+") keya = keya.substr(5);
			if (keyb.size() > 6 && keyb.substr(0,5) == "EXPL+") keyb = keyb.substr(5);

			keyStr = keya + "/" + keyb;

			overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/Command" + TOSTRING(filledCommands));
			
			if (truck->commandkey[i].description.empty())
			{
				overlayElement->setCaption(keyStr + ": " + _L("unknown function"));
			} else
			{
				overlayElement->setCaption(keyStr + ": " + truck->commandkey[i].description);
			}
			checkOverflow(overlayElement);
		}

		// hide command section title if no commands
		overlayElement = overlayElement = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/CommandsTitleLabel");
		overlayElement->setCaption("");
		if (filledCommands > 0)
		{
			// TODO: Fix the position of this overlay element
			//overlayElement->setCaption(_L("Commands:"));
			checkOverflow(overlayElement);
		}
	}
	return true;
}