Changeset 9016 for code/trunk/src/modules/overlays/hud
- Timestamp:
- Feb 15, 2012, 11:51:58 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/overlays/hud/CMakeLists.txt
r8706 r9016 7 7 HUDHealthBar.cc 8 8 HUDTimer.cc 9 HUDEnemyHealthBar.cc 9 10 ChatOverlay.cc 10 11 AnnounceMessage.cc -
code/trunk/src/modules/overlays/hud/HUDHealthBar.h
r7401 r9016 110 110 { return this->textoverlay_->getSpaceWidth(); } 111 111 112 inline void setOverlayText(SmartPtr<OverlayText> textoverlay) 113 { this->textoverlay_ = textoverlay; } 114 inline SmartPtr<OverlayText> getOverlayText() const 115 {return this->textoverlay_; } 116 112 117 private: 113 118 WeakPtr<Pawn> owner_; -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r8891 r9016 25 25 * Reto Grieder 26 26 * Oliver Scheuss 27 * Matthias Spalinger 27 28 * 28 29 */ … … 63 64 { 64 65 SetConfigValue(markerLimit_, 3); 65 66 SetConfigValue(showDistance, false); 66 67 } 67 68 … … 75 76 76 77 // Set default values 77 setFont ( "Monofur" );78 setTextSize ( 0.05f );79 setNavMarkerSize ( 0.05f );80 setDetectionLimit( 10000.0f );78 this->setFont ( "Monofur" ); 79 this->setTextSize ( 0.05f ); 80 this->setNavMarkerSize ( 0.05f ); 81 this->setDetectionLimit( 10000.0f ); 81 82 } 82 83 … … 97 98 SUPER ( HUDNavigation, XMLPort, xmlelement, mode ); 98 99 99 XMLPortParam ( HUDNavigation, "font", setFont, getFont,xmlelement, mode );100 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize,xmlelement, mode );101 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize,xmlelement, mode );102 XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode ); 100 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xmlelement, mode ); 101 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xmlelement, mode ); 102 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode ); 103 XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode ); 103 104 } 104 105 … … 144 145 } 145 146 146 147 float HUDNavigation::getArrowSizeX(int dist) 148 { 149 if (dist < 600) 150 dist = 600; 151 return this->getActualSize().x * 900 * navMarkerSize_ / dist; 152 } 153 154 float HUDNavigation::getArrowSizeY(int dist) 155 { 156 if (dist < 600) 157 dist = 600; 158 return this->getActualSize().y * 900 * navMarkerSize_ / dist; 159 } 147 160 148 161 void HUDNavigation::tick ( float dt ) … … 165 178 unsigned int markerCount_ = 0; 166 179 bool closeEnough_ = false; //only display objects that are close enough to be relevant for the player 180 167 181 // for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it) 168 182 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt ) … … 170 184 ObjectMap::iterator it = activeObjectList_.find ( listIt->first ); 171 185 closeEnough_ = listIt->second < detectionLimit_ ; 172 if ( markerCount_ < markerLimit_ && (closeEnough_ || detectionLimit_ < 0) ) // display on HUD if the statement is true 186 // display radarviewables on HUD if the marker limit and max-distance is not exceeded 187 if ( markerCount_ < markerLimit_ && (closeEnough_ || detectionLimit_ < 0) ) 173 188 { 174 189 … … 176 191 // Get Distance to HumanController and save it in the TextAreaOverlayElement. 177 192 int dist = listIt->second; 193 float textLength = 0.0f; 194 195 //display distance next to cursor 196 if (showDistance){ 178 197 it->second.text_->setCaption ( multi_cast<std::string> ( dist ) ); 179 float textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f; 198 textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f; 199 } 200 201 //display name next to cursor 202 else{ 203 it->second.text_->setCaption(it->first->getRVName()); 204 textLength = it->first->getRVName().size() * it->second.text_->getCharHeight() * 0.3f; 205 } 180 206 181 207 // Transform to screen coordinates … … 194 220 else 195 221 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0; 196 // Get Distance to HumanController and save it in the TextAreaOverlayElement.197 it->second.text_->setCaption ( multi_cast<std::string> ( dist ) );198 222 199 223 if ( outOfView ) … … 207 231 it->second.wasOutOfView_ = true; 208 232 } 233 234 //float xDistScale = this->getActualSize().x * 1000.0f * navMarkerSize_ / dist; 235 //float yDistScale = this->getActualSize().y * 1000.0f * navMarkerSize_ / dist; 236 237 // Adjust Arrowsize according to distance 238 it->second.panel_->setDimensions(getArrowSizeX(dist),getArrowSizeY(dist)); 209 239 210 240 // Switch between top, bottom, left and right position of the arrow at the screen border … … 263 293 //it->second.panel_->setMaterialName ( "Orxonox/NavTDC" ); 264 294 it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "tdc.png", it->first->getRadarObjectColour()) ); 295 it->second.panel_->setDimensions ( navMarkerSize_ * this->getActualSize().x, navMarkerSize_ * this->getActualSize().y ); 265 296 it->second.wasOutOfView_ = false; 266 297 } … … 280 311 it->second.text_->show(); 281 312 } 282 else // do not display on HUD 313 else // do not display on HUD 283 314 { 284 315 it->second.panel_->hide(); … … 312 343 void HUDNavigation::addObject ( RadarViewable* object ) 313 344 { 314 if( showObject(object) ==false )345 if( showObject(object)==false ) 315 346 return; 316 347 … … 399 430 return false; 400 431 assert( rv->getWorldEntity() ); 401 if ( rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() ==false )432 if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false ) 402 433 return false; 403 434 return true; -
code/trunk/src/modules/overlays/hud/HUDNavigation.h
r8891 r9016 24 24 * Co-authors: 25 25 * Reto Grieder 26 * Matthias Spalinger 26 27 * 27 28 */ … … 54 55 virtual void tick ( float dt ); 55 56 57 // RadarListener interface 56 58 virtual void addObject ( RadarViewable* object ); 57 59 virtual void removeObject ( RadarViewable* viewable ); … … 66 68 inline float getRadarSensitivity() const 67 69 { return 1.0f; } 70 71 unsigned int getMarkerLimit() { return this->markerLimit_; } 68 72 69 73 private: … … 81 85 // XMLPort accessors 82 86 void setNavMarkerSize ( float size ) 83 { navMarkerSize_ = size; this->sizeChanged(); }87 { navMarkerSize_ = size; this->sizeChanged(); } 84 88 float getNavMarkerSize() const 85 { return navMarkerSize_; } 86 87 void setDetectionLimit( float limit ) 88 { this->detectionLimit_ = limit; } 89 float getDetectionLimit() const 90 { return this->detectionLimit_; } 89 { return navMarkerSize_; } 90 void setDetectionLimit( float limit ) 91 { this->detectionLimit_ = limit; } 92 float getDetectionLimit() const 93 { return this->detectionLimit_; } 91 94 92 95 void setTextSize ( float size ); … … 102 105 sortedList sortedObjectList_; 103 106 107 float getArrowSizeX(int dist); 108 float getArrowSizeY(int dist); 104 109 105 110 float navMarkerSize_; 106 111 std::string fontName_; 107 112 float textSize_; 113 bool showDistance; 108 114 109 unsigned int markerLimit_; //TODO: is it possible to set this over the console and/or the IG-Setting110 float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value. 111 //!< In order to bypass this behaviour, set a negative detectionLimit_. Then the detection range is "infinite". 115 unsigned int markerLimit_; 116 float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value. 117 112 118 }; 113 119 }
Note: See TracChangeset
for help on using the changeset viewer.