Changeset 11588 for code/branches/CampaignMap_HS17/src/modules/overlays/hud
- Timestamp:
- Nov 24, 2017, 1:15:12 PM (7 years ago)
- Location:
- code/branches/CampaignMap_HS17/src/modules/overlays/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/CampaignMap_HS17/src/modules/overlays/hud/StoryModeHUD.cc
r11584 r11588 92 92 93 93 94 for(unsigned int i = 0; i < ObjectList<StoryModePlanet>().size(); i++){ 94 int i = 0; 95 for(StoryModePlanet* planet : ObjectList<StoryModePlanet>()){ 96 95 97 96 98 Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>( Ogre::OverlayManager::getSingleton() … … 98 100 99 101 texts.push_back(text); 100 //text->setFontName(this->fontName_);101 //text->setCharHeight(this->textSize_ * yScale);102 102 texts[i]->setDimensions(xScale, yScale); 103 104 //PROBLEM: function doesn't get called automatically by the xml macro, 105 //which is why we need to call it manually here. works with storymodeplanet.h... 106 this->setFont("Monofur"); 107 this->setTextSize(0.05f); 108 109 //font name of the text needs to be set here, not in the xml setter function 110 texts[i]->setFontName(this->fontName_); 111 texts[i]->setCharHeight(this->textSize_ * yScale); 112 113 //set text 114 texts[i]->setCaption(planet->getLevelName()); 103 115 104 116 texts[i]->hide(); 105 117 106 118 this->background_->addChild(texts[i]); 119 i++; 107 120 } 108 //this->setFont("Monofur");109 //this->setTextSize("0.5f");110 121 } 111 122 112 // Set the Font size of the Text.123 // Set the Font of this HUD. 113 124 void StoryModeHUD::setFont(const std::string& font) 114 125 { … … 116 127 if (fontPtr.isNull()) 117 128 { 118 orxout(internal_warning) << "StoryModeHUD: Font '" << font << "' not found" << endl; 129 this->fontName_ = "Monofur"; 130 orxout(internal_warning) << "StoryModeHUD: Font '" << font << "' not found. Font has been set to Monofur." << endl; 119 131 return; 120 132 } 121 133 this->fontName_ = font; 122 for(Ogre::TextAreaOverlayElement* text : texts)123 if(text != nullptr)124 text->setFontName(this->fontName_);125 134 } 126 135 127 // Gets the Font of th e Text136 // Gets the Font of this HUD 128 137 const std::string& StoryModeHUD::getFont() const 129 138 { … … 136 145 if (size <= 0.0f) 137 146 { 138 orxout(internal_warning) << "StoryModeHUD: Negative font size not allowed" << endl; 147 this->textSize_ = 0.05f; 148 orxout(internal_warning) << "StoryModeHUD: Non positive font size not allowed. Font size has been set to 0.05" << endl; 139 149 return; 140 150 } … … 165 175 for(StoryModePlanet* planet : ObjectList<StoryModePlanet>()){ 166 176 167 //display name next to cursor168 texts[i]->setCaption(planet->getLevelName());169 170 177 // Transform to screen coordinates 171 178 Vector3 pos = camTransform * planet->getWorldPosition(); -
code/branches/CampaignMap_HS17/src/modules/overlays/hud/StoryModeHUD.h
r11584 r11588 54 54 std::vector<Ogre::TextAreaOverlayElement*> texts; 55 55 void initialize(); 56 v oid setTextSize(float size);57 float getTextSize() const;56 virtual void setTextSize(float size); 57 virtual float getTextSize() const; 58 58 59 v oid setFont(const std::string& font);59 virtual void setFont(const std::string& font); 60 60 const std::string& getFont() const; 61 61
Note: See TracChangeset
for help on using the changeset viewer.