Changeset 1618 for code/branches/hud/src/orxonox/overlays/hud/HUDBar.cc
- Timestamp:
- Jun 22, 2008, 11:47:09 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud/src/orxonox/overlays/hud/HUDBar.cc
r1616 r1618 43 43 namespace orxonox 44 44 { 45 CreateFactory(BarColour); 46 47 BarColour::BarColour() 48 : position_(0.0) 49 { 50 RegisterObject(BarColour); 51 } 52 53 void BarColour::XMLPort(Element& xmlElement, XMLPort::Mode mode) 54 { 55 BaseObject::XMLPort(xmlElement, mode); 56 57 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode); 58 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode); 59 } 60 61 45 62 unsigned int HUDBar::materialcount_s = 0; 46 63 … … 87 104 this->autoColour_ = true; 88 105 this->right2Left_ = false; // default is left to right progress 89 90 this->addColour(0.7, ColourValue(0.2, 0.7, 0.2));91 this->addColour(0.4, ColourValue(0.7, 0.5, 0.2));92 this->addColour(0.1, ColourValue(0.7, 0.2, 0.2));93 106 } 94 107 95 108 XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode); 109 XMLPortParam(HUDBar, "right2left", setRightToLeft, getRightToLeft, xmlElement, mode); 110 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode, false, true); 96 111 } 97 112 … … 154 169 } 155 170 156 void HUDBar::addColour( float value, const ColourValue&colour)171 void HUDBar::addColour(BarColour* colour) 157 172 { 158 value = clamp<float>(value, 0, 1); 159 this->colours_[value] = colour; 173 float value = clamp<float>(colour->getPosition(), 0.0, 1.0); 174 this->colours_[value] = colour->getColour(); 175 176 this->barColours_.push_back(colour); 177 } 178 179 BarColour* HUDBar::getColour(unsigned int index) 180 { 181 if (index < this->barColours_.size()) 182 return barColours_[index]; 183 else 184 return 0; 160 185 } 161 186
Note: See TracChangeset
for help on using the changeset viewer.