Changeset 2036 for code/branches/overlay/src/orxonox
- Timestamp:
- Oct 28, 2008, 10:55:49 PM (16 years ago)
- Location:
- code/branches/overlay/src/orxonox
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/overlay/src/orxonox/gamestates/GSLevel.cc
r1887 r2036 58 58 , startLevel_(0) 59 59 , hud_(0) 60 , stats_(0) 60 61 { 61 62 RegisterObject(GSLevel); … … 93 94 hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo"); 94 95 Loader::load(hud_); 96 97 // Load statistics 98 COUT(3) << "Orxonox: Loading statistics overlay" << std::endl; 99 stats_ = new Level(Settings::getDataPath() + "overlay/stats.oxo"); 100 Loader::load(stats_); 95 101 96 102 // reset game speed to normal … … 115 121 Loader::unload(hud_); 116 122 delete this->hud_; 123 124 Loader::unload(stats_); 125 delete this->stats_; 117 126 118 127 // this call will delete every BaseObject! -
code/branches/overlay/src/orxonox/gamestates/GSLevel.h
r1887 r2036 70 70 Level* startLevel_; //!< current hard coded default level 71 71 Level* hud_; //!< 'level' object fo the HUD 72 Level* stats_; //!< 'level' object fo the stats overlay 72 73 73 74 // config values -
code/branches/overlay/src/orxonox/overlays/OrxonoxOverlay.cc
r1755 r2036 60 60 { 61 61 RegisterObject(OrxonoxOverlay); 62 63 // add this overlay to the static map of OrxonoxOverlays 64 if (overlays_s.find(this->getName()) != overlays_s.end()) 65 { 66 COUT(1) << "Overlay names should be unique or you cannnot access them via console." << std::endl; 67 } 68 overlays_s[this->getName()] = this; 69 70 // create the Ogre::Overlay 71 overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_" 72 + convertToString(hudOverlayCounter_s++)); 73 74 // create background panel (can be used to show any picture) 75 this->background_ = static_cast<Ogre::PanelOverlayElement*>( 76 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", 77 "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++))); 78 this->overlay_->add2D(this->background_); 79 80 // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets 81 // called automatically by the GraphicsEngine. 82 this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), 83 GraphicsEngine::getInstance().getWindowHeight()); 84 85 this->changedVisibility(); 62 86 } 63 87 … … 93 117 { 94 118 SUPER(OrxonoxOverlay, XMLPort, xmlElement, mode); 95 96 if (mode == XMLPort::LoadObject)97 {98 // add this overlay to the static map of OrxonoxOverlays99 if (overlays_s.find(this->getName()) != overlays_s.end())100 {101 COUT(1) << "Overlay names should be unique or you cannnot access them via console." << std::endl;102 }103 overlays_s[this->getName()] = this;104 105 // create the Ogre::Overlay106 overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_"107 + convertToString(hudOverlayCounter_s++));108 109 // create background panel (can be used to show any picture)110 this->background_ = static_cast<Ogre::PanelOverlayElement*>(111 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel",112 "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++)));113 this->overlay_->add2D(this->background_);114 115 // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets116 // called automatically by the GraphicsEngine.117 this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),118 GraphicsEngine::getInstance().getWindowHeight());119 120 this->changedVisibility();121 }122 119 123 120 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlElement, mode) -
code/branches/overlay/src/orxonox/overlays/OverlayText.cc
r1784 r2036 31 31 32 32 #include <OgreOverlayManager.h> 33 #include <OgreTextAreaOverlayElement.h>34 33 #include <OgrePanelOverlayElement.h> 35 34 … … 46 45 { 47 46 RegisterObject(OverlayText); 47 48 this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 49 .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberStr())); 50 this->text_->setCharHeight(1.0); 51 52 this->background_->addChild(this->text_); 48 53 } 49 54 50 55 OverlayText::~OverlayText() 51 56 { 52 if (this-> text_)57 if (this->isInitialized()) 53 58 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->text_); 54 59 } … … 57 62 { 58 63 SUPER(OverlayText, XMLPort, xmlElement, mode); 59 60 if (mode == XMLPort::LoadObject)61 {62 this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()63 .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberStr()));64 this->text_->setCharHeight(1.0);65 66 this->background_->addChild(this->text_);67 }68 64 69 65 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode).defaultValues("Monofur"); … … 74 70 void OverlayText::setFont(const std::string& font) 75 71 { 76 if ( this->text_ &&font != "")72 if (font != "") 77 73 this->text_->setFontName(font); 78 74 } … … 80 76 const std::string& OverlayText::getFont() const 81 77 { 82 if (this->text_) 83 return this->text_->getFontName(); 84 else 85 return blankString; 78 return this->text_->getFontName(); 86 79 } 87 80 -
code/branches/overlay/src/orxonox/overlays/OverlayText.h
r1625 r2036 34 34 #include <string> 35 35 #include <OgrePrerequisites.h> 36 #include <OgreTextAreaOverlayElement.h> 36 37 #include "OrxonoxOverlay.h" 37 38 … … 46 47 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 47 48 48 protected: 49 virtual void sizeChanged(); 50 51 void setCaption(const std::string& caption) { this->caption_ = caption; } 52 const std::string& getCaption() const { return this->caption_; } 49 void setCaption(const std::string& caption) { this->text_->setCaption(caption); } 50 std::string getCaption() const { return this->text_->getCaption(); } 53 51 54 52 void setFont(const std::string& font); … … 58 56 float getTextSize() const { return this->getSize().y; } 59 57 60 Ogre::TextAreaOverlayElement* text_; 58 protected: 59 virtual void sizeChanged(); 61 60 62 61 private: 63 std::string caption_; 62 63 Ogre::TextAreaOverlayElement* text_; 64 64 }; 65 65 } -
code/branches/overlay/src/orxonox/overlays/debug/DebugFPSText.cc
r1755 r2036 50 50 { 51 51 float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond(); 52 this-> text_->setCaption(this->getCaption() +convertToString(fps));52 this->setCaption(convertToString(fps)); 53 53 } 54 54 } -
code/branches/overlay/src/orxonox/overlays/debug/DebugRTRText.cc
r1755 r2036 50 50 { 51 51 float rtr = GraphicsEngine::getInstance().getAverageTickTime(); 52 this-> text_->setCaption(this->getCaption() +convertToString(rtr));52 this->setCaption(convertToString(rtr)); 53 53 } 54 54 }
Note: See TracChangeset
for help on using the changeset viewer.