Changeset 1627 for code/trunk/src/orxonox/overlays/hud/HUDBar.cc
- Timestamp:
- Jun 26, 2008, 7:00:59 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/overlays/hud/HUDBar.cc
r1626 r1627 55 55 BaseObject::XMLPort(xmlElement, mode); 56 56 57 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode); 58 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode); 57 if (mode == XMLPort::LoadObject) 58 { 59 this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 60 this->setPosition(0.0f); 61 } 62 63 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode) 64 .defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0)); 65 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode).defaultValues(0.0f); 59 66 } 60 67 … … 90 97 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2)); 91 98 92 // create bar93 barWidth_s = 0.88f;94 barHeight_s = 1.0f;95 barOffsetLeft_s = 0.06f;96 barOffsetTop_s = 0.0f;97 98 99 this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 99 100 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberStr())); … … 101 102 this->background_->addChild(bar_); 102 103 103 this->setValue(0 );104 this-> autoColour_ = true;105 this-> right2Left_ = false; // default is left to right progress104 this->setValue(0.0f); 105 this->setRightToLeft(false); 106 this->setAutoColour(true); 106 107 } 107 108 108 XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode); 109 XMLPortParam(HUDBar, "right2left", setRightToLeft, getRightToLeft, xmlElement, mode); 109 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode).defaultValues(0.0f); 110 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode).defaultValues(false); 111 XMLPortParam(HUDBar, "autoColour", setAutoColour, getAutoColour, xmlElement, mode).defaultValues(true); 110 112 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode, false, true); 111 113 } 112 114 113 void HUDBar:: setValue(float value)115 void HUDBar::valueChanged() 114 116 { 115 this->value_ = clamp<float>(value, 0, 1);116 117 if (this->autoColour_ && this->textureUnitState_) 117 118 { … … 153 154 { 154 155 // backward casew 155 this->bar_->setPosition( barOffsetLeft_s + barWidth_s * (1 - this->value_), barOffsetTop_s);156 this->bar_->setDimensions( barWidth_s * this->value_, barHeight_s);156 this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), 0.0f); 157 this->bar_->setDimensions(0.88f * this->value_, 1.0f); 157 158 } 158 159 else 159 160 { 160 161 // default case 161 this->bar_->setPosition( barOffsetLeft_s, barOffsetTop_s);162 this->bar_->setDimensions( barWidth_s * this->value_, barHeight_s);162 this->bar_->setPosition(0.06f, 0.0f); 163 this->bar_->setDimensions(0.88f * this->value_, 1.0f); 163 164 } 164 165 if (this->value_ != 0)
Note: See TracChangeset
for help on using the changeset viewer.