Changeset 1329 for code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc
- Timestamp:
- May 19, 2008, 10:51:53 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc
r1328 r1329 49 49 color_ = 2; 50 50 autoColor_ = true; 51 dir_ = BarOverlayElement::RIGHT;51 left2Right = false; // default: right to left progress 52 52 53 53 // get window data... … … 66 66 67 67 // create background... 68 bar_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", name_+"Bar")); 69 bar_->show(); 70 container_->addChild(bar_); 71 bar_->setPosition(left_, top_); 72 bar_->setDimensions(width_, height_); 73 bar_->setMetricsMode(Ogre::GMM_PIXELS); 74 bar_->setMaterialName("Orxonox/Green"); 68 background_ = static_cast<OverlayContainer*>(om->createOverlayElement("Panel", name_+"container")); 69 background_->show(); 70 container_->addChild(background_); 71 background_->setMetricsMode(Ogre::GMM_PIXELS); 72 background_->setMaterialName("Orxonox/BarBackground"); 75 73 76 s etPosition(left_,top_);77 setDimensions(width_,height_);74 show(); 75 background_->addChild(this); 78 76 setMetricsMode(Ogre::GMM_PIXELS); 79 setMaterialName("Orxonox/BarBackground"); 77 setMaterialName("Orxonox/Green"); 78 resize(); 79 } 80 81 void BarOverlayElement::resize(){ 82 windowW_ = GraphicsEngine::getSingleton().getWindowWidth(); 83 windowH_ = GraphicsEngine::getSingleton().getWindowHeight(); 84 // cálculate new absolute coordinates... 85 left_ = leftRel_ * windowW_; 86 top_ = topRel_ * windowH_; 87 width_ = widthRel_ * windowW_; 88 height_ = heightRel_ * windowH_; 89 // adapt background 90 background_->setPosition(left_, top_); 91 background_->setDimensions(width_, height_); 92 // adapt bar 80 93 setValue(value_); 81 94 } 82 95 83 84 void BarOverlayElement::setValue(float value){ 96 void BarOverlayElement::setValue(float value){ 85 97 value_ = value; 86 98 // set color, if nescessary … … 91 103 } 92 104 // set value 93 switch(dir_){ 94 case BarOverlayElement::DOWN: 95 bar_->setPosition(left_,top_); 96 bar_->setDimensions(width_,height_*value_); 97 break; 98 case BarOverlayElement::LEFT: 99 bar_->setPosition(left_+width_-width_*value_,top_); 100 bar_->setDimensions(width_*value_,height_); 101 break; 102 case BarOverlayElement::UP: 103 bar_->setPosition(left_,top_+height_-height_*value_); 104 bar_->setDimensions(width_,height_*value_); 105 break; 106 default: 107 bar_->setPosition(left_,top_); 108 bar_->setDimensions(width_*value_,height_); 109 break; 105 if(left2Right){ // backward case 106 setPosition(0+width_-width_*value_, 0); 107 setDimensions(width_*value_,height_); 108 }else{ // default case 109 setPosition(0, 0); 110 setDimensions(width_*value_,height_); 110 111 } 111 } 112 113 void BarOverlayElement::setDir(int dir){ 112 if(value_ != 0) setTiling(value_, 1.0); 114 113 } 115 114 … … 118 117 switch(color){ 119 118 case 0: 120 bar_->setMaterialName("Orxonox/Red");119 setMaterialName("Orxonox/Red"); 121 120 break; 122 121 case 1: 123 bar_->setMaterialName("Orxonox/Yellow");122 setMaterialName("Orxonox/Yellow"); 124 123 break; 125 124 case 2: 126 bar_->setMaterialName("Orxonox/Green");125 setMaterialName("Orxonox/Green"); 127 126 } 128 127 }
Note: See TracChangeset
for help on using the changeset viewer.