OverlayContainer* MenuSheet::createOverlay(int id, const std::string& text, int x, int y, int w, int h) { std::string ovname = mName + "/" + Ogre::StringConverter::toString(id); OverlayContainer* ov; if (text.empty()) ov = static_cast<OverlayContainer*>(OverlayManager::getSingleton().createOverlayElement("Panel", ovname)); else ov = static_cast<OverlayContainer*>(OverlayManager::getSingleton().createOverlayElement("TextArea", ovname)); ov->setMetricsMode(GMM_PIXELS); // text area centered around X point, so we create it with w/2 surplus if (text.empty()) ov->setPosition(x, y); else ov->setPosition(x + w/2, y); ov->setDimensions(w, h); ov->setCaption(text); ov->setParameter("font_name", mFont); ov->setParameter("char_height", StringConverter::toString(mFontSize)); ov->setParameter("alignment", "center"); ov->show(); mOverlay->add2D(ov); return ov; }
void HUD::multiplayer() { OverlayManager& overlayManager = OverlayManager::getSingleton(); // Create a panel OverlayContainer* panel = static_cast<OverlayContainer*>( overlayManager.createOverlayElement("Panel", "MultiplayerPanel")); panel->setMetricsMode(Ogre::GMM_PIXELS); panel->setPosition(20, 20); panel->setDimensions(200, 250); panel->setMaterialName("PanelAchtergrondImage"); // Optional background material // Create a text area m_textMessages = static_cast<TextAreaOverlayElement*>( overlayManager.createOverlayElement("TextArea", "MultiplayerTextArea")); m_textMessages->setMetricsMode(Ogre::GMM_PIXELS); m_textMessages->setPosition(10, 50); m_textMessages->setDimensions(150, 100); m_textMessages->setCaption("GoClient 0.1"); m_textMessages->setCharHeight(16); m_textMessages->setFontName("ArialFont"); m_textMessages->setColourBottom(ColourValue(0.6, 0.6, 0.6)); m_textMessages->setColourTop(ColourValue(1, 1, 1)); // Create an overlay, and add the panel m_overlay = overlayManager.create("MultiplayerOverlay"); m_overlay->add2D(panel); // Add the text area to the panel panel->addChild(m_textMessages); // Show the overlay m_overlay->show(); }
//----------------------------------------------------------------------------------- void Sample_Compositor::setupControls(void) { mTrayMgr->createButton(TL_TOPLEFT, "PageButton", "Compositors", 175); for (size_t i=0; i < COMPOSITORS_PER_PAGE; i++) { String checkBoxName = "Compositor_" + Ogre::StringConverter::toString(i); CheckBox* cb = mTrayMgr->createCheckBox(TL_TOPLEFT, checkBoxName, "Compositor", 175); cb->hide(); } changePage(0); mDebugTextureSelectMenu = mTrayMgr->createThickSelectMenu(TL_TOPRIGHT, "DebugRTTSelectMenu", "Debug RTT", 180, 5); mDebugTextureSelectMenu->addItem("None"); mTrayMgr->createSeparator(TL_TOPRIGHT, "DebugRTTSep1"); // this is a hack to give the debug RTT a bit more room DecorWidget* debugRTTPanel = mTrayMgr->createDecorWidget(TL_NONE, "DebugRTTPanel", "SdkTrays/Picture"); OverlayContainer* debugRTTContainer = (OverlayContainer*)debugRTTPanel->getOverlayElement(); mDebugTextureTUS = debugRTTContainer->getMaterial()->getBestTechnique()->getPass(0)->getTextureUnitState(0); //mDebugTextureTUS->setTextureName("CompositorDemo/DebugView"); debugRTTContainer->setDimensions(128, 128); debugRTTContainer->getChild("DebugRTTPanel/PictureFrame")->setDimensions(144, 144); debugRTTPanel->hide(); mTrayMgr->createSeparator(TL_TOPRIGHT, "DebugRTTSep2"); // this is a hack to give the debug RTT a bit more room mTrayMgr->showCursor(); mTrayMgr->showLogo(TL_BOTTOMLEFT); mTrayMgr->toggleAdvancedFrameStats(); }
void Splash::createScene() { log("[Loading] Creating the splash screen..."); // Loading picture overlayManager = &OverlayManager::getSingleton(); overlay = overlayManager->create("LoadingOverlay"); ((MaterialPtr)MaterialManager::getSingleton().create("LoadingMaterial","splash"))->getTechnique(0)->getPass(0)->createTextureUnitState("loading.png"); OverlayContainer* panel = static_cast<OverlayContainer*>(overlayManager->createOverlayElement("Panel","LoadingPanel")); panel->setMaterialName("LoadingMaterial"); panel->setDimensions(1,0.96f); // Progess bar OverlayContainer* progressBar = static_cast<OverlayContainer*>(overlayManager->createOverlayElement("Panel","ProgressBar")); progressBar->setDimensions(1,0.04f); progressBar->setPosition(0,0.96f); MaterialPtr progressBGMat = MaterialManager::getSingleton().create("progressBG","splash"); progressBGMat->getTechnique(0)->getPass(0)->createTextureUnitState()->setColourOperationEx(LBX_SOURCE1,LBS_MANUAL,LBS_CURRENT,ColourValue(0.9f, 0.9f, 0.9f));; MaterialPtr progressFGMat = MaterialManager::getSingleton().create("progressFG","splash"); progressFGMat->getTechnique(0)->getPass(0)->createTextureUnitState()->setColourOperationEx(LBX_SOURCE1,LBS_MANUAL,LBS_CURRENT,ColourValue(0.23f, 0.88f, 0.5f));; progressBG = static_cast<OverlayContainer*>(overlayManager->createOverlayElement("Panel","ProgressBarBG")); progressBG->setMaterialName("progressBG"); progressBG->setDimensions(1,1); progressFG = static_cast<OverlayContainer*>(overlayManager->createOverlayElement("Panel","ProgressBarFG")); progressFG->setMaterialName("progressFG"); progressFG->setDimensions(0,1); // Loading text FontManager::getSingleton().getByName("BlueHighway")->load(); // HACK: Workaround for bug #324 in Ogre progressText = static_cast<TextAreaOverlayElement*>(overlayManager->createOverlayElement("TextArea", "text")); progressText->setMetricsMode(GuiMetricsMode::GMM_RELATIVE); progressText->setLeft(0.01f); progressText->setTop(0.01f); progressText->setHorizontalAlignment(GHA_LEFT); progressText->setVerticalAlignment(GVA_TOP); progressText->setFontName("BlueHighway"); progressText->setCharHeight(0.03f); progressText->setColour(Ogre::ColourValue(0,0,0)); progressBar->addChild(progressBG); progressBar->addChild(progressFG); progressBar->addChild(progressText); overlay->add2D(panel); overlay->add2D(progressBar); overlay->show(); }