Changeset 1002 for code/branches/hud2/src/orxonox/hud/Bar.cc
- Timestamp:
- Apr 8, 2008, 11:12:22 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud2/src/orxonox/hud/Bar.cc
r1000 r1002 26 26 */ 27 27 28 #include "OrxonoxStableHeaders.h"29 30 28 #include <OgreOverlayManager.h> 31 29 #include <OgreOverlayElement.h> 32 #include <OgreTextAreaOverlayElement.h>33 30 #include <OgreStringConverter.h> 31 #include <OgreColourValue.h> 34 32 #include <string.h> 35 33 36 #include "Bar .h"34 #include "BarV1.h" 37 35 38 36 namespace orxonox 39 37 { 40 38 using namespace Ogre; 41 42 Bar::Bar(Real left, Real top, Real width, Real height, 43 int dir, int colour, std::string name){ 44 Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton(); 45 element = overlayManager.createOverlayElement("Panel",name); 46 element->setMetricsMode(Ogre::GMM_PIXELS); 47 dir_ = dir; 48 left_ = left; 49 top_ = top; 50 width_ = width; 51 height_ = height; 52 element->setPosition(left_,top_); 53 element->setDimensions(width_,height_); 54 setColour(colour); 55 } 39 40 Bar::Bar(const String& name):Ogre::OverlayElement(name){} 41 42 43 44 45 46 47 /* Bar::Bar(const Ogre::String& s){} 56 48 57 49 Bar::~Bar(void){} 58 50 59 60 void Bar::reset(int percentage){ 61 switch(dir_){ 62 case 1: 63 element->setPosition(left_,top_); 64 element->setDimensions(width_,height_*percentage/100); 65 break; 66 case 2: 67 element->setPosition(left_+width_-width_*percentage/100,top_); 68 element->setDimensions(width_*percentage/100,height_); 69 break; 70 case 3: 71 element->setPosition(left_,top_+height_-height_*percentage/100); 72 element->setDimensions(width_,height_*percentage/100); 73 break; 74 default: 75 element->setPosition(left_,top_); 76 element->setDimensions(width_*percentage/100,height_); 51 */ 52 /* void Bar::setPercentage(float percentage){ 53 percentage_=percentage; 54 if(dir_){setWidth(int(percentage_* getWidth()));} 55 else {setHeight(int(percentage_ * getHeight()));} 77 56 } 57 58 59 void Bar::setPercentage(float percentage){ 60 percentage_ = percentage; 61 // setWidth(getWidth()); 78 62 } 79 63 80 void Bar::setColour(int colour){81 switch(colour){82 case 0:83 element->setMaterialName("Orxonox/Red");84 break;85 case 1:86 element->setMaterialName("Orxonox/Yellow");87 break;88 case 2:89 element->setMaterialName("Orxonox/Green");90 }91 }92 93 void Bar::show(){element->show();}94 95 void Bar::hide(){element->hide();}96 97 SmartBar::SmartBar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height,98 int dir, std::string name) : Bar(left, top, width, height, dir, Bar::YELLOW, name){99 }100 101 SmartBar::~SmartBar(void){}102 64 103 65 104 void SmartBar::reset(int percentage){ 105 if (percentage>50) {setColour(Bar::GREEN);} 106 else if (percentage>25) {setColour(Bar::YELLOW);} 107 else setColour(Bar::RED); 108 Bar::reset(percentage); 66 67 void Bar::setColor(ColourValue color){ 68 color_=color; 69 setColour(color); 109 70 } 110 71 */ 72 111 73 } 112 74
Note: See TracChangeset
for help on using the changeset viewer.