- Timestamp:
- Nov 13, 2017, 4:20:31 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/CampaignMap_HS17/src/modules/overlays/hud/StoryModeHUD.cc
r11544 r11560 68 68 { 69 69 RegisterObject(StoryModeHUD); 70 70 71 71 // Set default values 72 this->setFont("Monofur"); 73 this->setTextSize(0.5f); 72 //this->setFont("Monofur"); 73 //this->setTextSize(0.5f); 74 75 // Scales used for dimensions and text size 76 float xScale = this->getActualSize().x; 77 float yScale = this->getActualSize().y; 78 79 // Create text 80 text_ = static_cast<Ogre::TextAreaOverlayElement*>( Ogre::OverlayManager::getSingleton() 81 .createOverlayElement("TextArea", "StoryModeHUD_navText_" + getUniqueNumberString())); 82 //text->setFontName(this->fontName_); 83 //text->setCharHeight(this->textSize_ * yScale); 84 text_->setDimensions(xScale, yScale); 85 86 text_->hide(); 87 88 this->background_->addChild(text_); 74 89 } 75 90 … … 102 117 } 103 118 this->fontName_ = font; 104 for (const auto& mapEntry : this->activeObjectList_) 105 { 106 if (mapEntry.second.text_ != nullptr) 107 mapEntry.second.text_->setFontName(this->fontName_); 108 } 119 if(text_ != nullptr) 120 text_->setFontName(this->fontName_); 109 121 } 110 122 … … 124 136 } 125 137 this->textSize_ = size; 126 for (const auto& mapEntry : this->activeObjectList_) 127 { 128 if (mapEntry.second.text_) 129 mapEntry.second.text_->setCharHeight(size); 130 } 138 131 139 } 132 140 … … 151 159 152 160 153 154 155 text_->setCaption("Hello Muthafuckin' World!");161 //display name next to cursor 162 //TODO: Planet.getName() 163 text_->setCaption("Was geht ab?"); 156 164 157 // Transform to screen coordinates 158 Vector3 pos = camTransform * planet->getRVWorldPosition(); 165 // Transform to screen coordinates 166 Vector3 pos = camTransform * Vector3(0,0,0); // planet->getRVWorldPosition(); 167 168 // If you fly passed the description, it gets out of sight 169 if (pos.z > 1.0) 170 return; 159 171 160 161 text_->setLeft((pos.x + 1.0f + it->second.panel_->getWidth()) * 0.5f);162 it->second.text_->setTop((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f);172 // Position text 173 text_->setLeft((pos.x+1)/2); // The (0,0) Coordinate is in the upper left corner. 174 text_->setTop((-pos.y+1)/2); // With those two calculations we set the desired positions 163 175 164 165 it->second.text_->show();176 // Make sure the overlays are shown 177 text_->show(); 166 178 167 179 } 168 180 169 void StoryModeHUD::addObject() 170 { 171 // Scales used for dimensions and text size 172 float xScale = this->getActualSize().x; 173 float yScale = this->getActualSize().y; 181 //void StoryModeHUD::addObject() 174 182 175 // Create text 176 Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>( Ogre::OverlayManager::getSingleton() 177 .createOverlayElement("TextArea", "StoryModeHUD_navText_" + getUniqueNumberString())); 178 text->setFontName(this->fontName_); 179 text->setCharHeight(this->textSize_ * yScale); 180 text->setColour(object->getRadarObjectColour()); 181 182 text->hide(); 183 184 this->background_->addChild(text); 185 } 186 187 void StoryModeHUD::removeObject(RadarViewable* viewable) 183 /*void StoryModeHUD::removeObject(RadarViewable* viewable) 188 184 { 189 185 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.text_); 190 } 186 }*/ 191 187 }
Note: See TracChangeset
for help on using the changeset viewer.