// Dim a menu item void Menu::dimItem(int i) { if(mNumItems == 0) return; TextAreaOverlayElement *item = static_cast<TextAreaOverlayElement*>(OverlayManager::getSingleton().getOverlayElement(mMenuName + StringConverter::toString(i+1))); item->setColourTop(ColourValue(0.5f,0.6f,0.7f,0.5f)); item->setColourBottom(ColourValue(1,1,1,0.5f)); }
// Enter a new name to the high scores void Menu::enterName(int place) { mEnteringName = true; mNewScorePlace = place; mNewName = hiscoreList.mList[place].name; strcpy(mNewName, ""); mTextPos = 0; // Change the text TextAreaOverlayElement *item = static_cast<TextAreaOverlayElement*>(OverlayManager::getSingleton().getOverlayElement("HighScores1")); item->setCaption("Congratulations!"); // Change the colours mNewItem = item = static_cast<TextAreaOverlayElement*>(OverlayManager::getSingleton().getOverlayElement("Name" + StringConverter::toString(place+1))); item->setColourTop(ColourValue(0.7f, 0.7f, 0.7f)); item->setColourBottom(ColourValue(1,1,1)); mNewItem->setCaption("^"); item = static_cast<TextAreaOverlayElement*>(OverlayManager::getSingleton().getOverlayElement("Score" + StringConverter::toString(place+1))); item->setColourTop(ColourValue(0.7f, 0.7f, 0.7f)); item->setColourBottom(ColourValue(1,1,1)); }
// Fade the item selection void Menu::fadeItem(Real delta) { // Fade the title screen here, too if(mMenuName != "TitleScreen") { if(titleAlpha > 0) { titleAlpha -= delta * 0.5f; if(titleAlpha < 0) { titleAlpha = 0; OverlayManager::getSingleton().getByName("TitleScreen")->hide(); } // Update the alpha MaterialPtr mat = MaterialManager::getSingleton().getByName("TitleScreen"); mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setAlphaOperation(LBX_MODULATE, LBS_TEXTURE, LBS_MANUAL, 1.0f, titleAlpha); } } else { if(titleAlpha < 1.0f) { titleAlpha += delta * 0.75f; if(titleAlpha > 1.0f) titleAlpha = 1.0f; // Update the alpha MaterialPtr mat = MaterialManager::getSingleton().getByName("TitleScreen"); mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setAlphaOperation(LBX_MODULATE, LBS_TEXTURE, LBS_MANUAL, 1.0f, titleAlpha); } } if(mNumItems == 0) return; mItemAlpha += delta * 10; Real alpha = 0.75f + Math::Sin(Radian(mItemAlpha)) * 0.25f; TextAreaOverlayElement *item = static_cast<TextAreaOverlayElement*>(OverlayManager::getSingleton().getOverlayElement(mMenuName + StringConverter::toString(mSelection+1))); ColourValue col = item->getColourTop(); col.a = alpha; item->setColourTop(col); col = item->getColourBottom(); col.a = alpha; item->setColourBottom(col); }
//Grabbed from Ogre3D Wiki void Utility::drawText(Ogre::String tText, int tSize, Ogre::Vector2 tPosition, Ogre::ColourValue tTopColor, Ogre::ColourValue tBotColor) { // Create a text area TextAreaOverlayElement* textArea = static_cast<TextAreaOverlayElement*>( overlayManager->createOverlayElement( "TextArea", tText)); //"TextAreaName" + StringConverter::toString(Ogre::Timer::Timer().getMicrosecondsCPU()) ) ); textArea->setMetricsMode(Ogre::GMM_PIXELS); textArea->setPosition(tPosition.x, tPosition.y); textArea->setDimensions(100, 100); textArea->setCaption(tText); textArea->setCharHeight(tSize); textArea->setFontName("StarWars"); /*textArea->setColourBottom(ColourValue(0.3, 0.5, 0.3)); textArea->setColourTop(ColourValue(0.5, 0.7, 0.5));*/ textArea->setColourBottom(tBotColor); textArea->setColourTop(tTopColor); // Add the text area to the panel panel->addChild(textArea); }