- Timestamp:
- Feb 15, 2018, 12:11:04 AM (7 years ago)
- Location:
- code/branches/Presentation_HS17_merge/src/modules/overlays/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge/src/modules/overlays/hud/StoryModeHUD.cc
r11743 r11745 66 66 { 67 67 RegisterObject(StoryModeHUD); 68 69 this->textSize_ = 1.0; 68 70 } 69 71 70 72 // Destructor of the StoryMode HUD 71 73 StoryModeHUD::~StoryModeHUD() 72 {} 74 { 75 for(Ogre::TextAreaOverlayElement* text : texts) 76 Ogre::OverlayManager::getSingleton().destroyOverlayElement(text); 77 } 73 78 74 79 // Functions of the StoryMode HUD … … 92 97 CameraManager::getInstance().getActiveCamera()->setOrientation(Vector3::UNIT_X, Degree(-30)); 93 98 94 int i = 0;95 99 for(NameableStaticEntity* planet : ObjectList<NameableStaticEntity>()){ 96 100 … … 100 104 101 105 texts.push_back(text); 102 text s[i]->setDimensions(xScale, yScale);106 text->setDimensions(xScale, yScale); 103 107 104 108 //font name of the text needs to be set here, not in the xml setter function 105 text s[i]->setFontName(this->fontName_);106 text s[i]->setCharHeight(this->textSize_ * yScale);109 text->setFontName(this->fontName_); 110 text->setCharHeight(this->textSize_ * yScale); 107 111 108 112 //set text 109 text s[i]->setCaption(planet->getLevelName());113 text->setCaption(planet->getLevelName()); 110 114 111 text s[i]->hide();115 text->hide(); 112 116 113 this->background_->addChild(texts[i]); 114 i++; 117 this->background_->addChild(text); 115 118 } 116 119 } … … 170 173 const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix(); 171 174 172 int i = 0;175 size_t i = 0; 173 176 for(NameableStaticEntity* planet : ObjectList<NameableStaticEntity>()){ 177 if (i >= texts.size()) { 178 break; 179 } 180 Ogre::TextAreaOverlayElement* text = texts[i]; 181 i++; 174 182 175 183 // Transform to screen coordinates … … 180 188 181 189 // Position text 182 text s[i]->setLeft((pos.x+1)/2); // The (0,0) Coordinate is in the upper left corner.183 text s[i]->setTop((-pos.y+1)/2); // With those two calculations we set the desired positions190 text->setLeft((pos.x+1)/2); // The (0,0) Coordinate is in the upper left corner. 191 text->setTop((-pos.y+1)/2); // With those two calculations we set the desired positions 184 192 185 193 // Make sure the overlays are shown 186 text s[i]->show();194 text->show(); 187 195 } 188 i++;189 190 196 } 191 197 } -
code/branches/Presentation_HS17_merge/src/modules/overlays/hud/StoryModeHUD.h
r11743 r11745 50 50 virtual void tick(float dt) override; 51 51 52 private: 53 void initialize(); 52 54 53 private: 54 std::vector<Ogre::TextAreaOverlayElement*> texts; 55 void initialize(); 56 virtual void setTextSize(float size); 57 virtual float getTextSize() const; 55 void setTextSize(float size); 56 float getTextSize() const; 58 57 59 v irtual void setFont(const std::string& font);58 void setFont(const std::string& font); 60 59 const std::string& getFont() const; 61 60 61 std::vector<Ogre::TextAreaOverlayElement*> texts; 62 62 std::string fontName_; 63 63 float textSize_;
Note: See TracChangeset
for help on using the changeset viewer.