Changeset 1002 for code/branches
- Timestamp:
- Apr 8, 2008, 11:12:22 AM (17 years ago)
- Location:
- code/branches/hud2/src/orxonox
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud2/src/orxonox/Orxonox.cc
r991 r1002 375 375 // show the current time in the HUD 376 376 //orxonoxHUD_->setTime((int)now, 0); 377 orxonoxHUD_->energyCounter->reset(20);377 // orxonoxHUD_->energyCounter->reset(20); 378 378 379 379 -
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 -
code/branches/hud2/src/orxonox/hud/Bar.h
r991 r1002 30 30 #define _BAR_H__ 31 31 32 #include <string> 33 #include <OgreColourValue.h> 34 #include <OgreOverlayElement.h> 35 #include <OgrePrerequisites.h> 32 36 #include <string.h> 33 #include <OgreOverlayElement.h>34 #include <OgreTextAreaOverlayElement.h>35 #include <OgrePrerequisites.h>36 37 #include "../OrxonoxPrereqs.h" 37 38 … … 40 41 namespace orxonox 41 42 { 42 class _OrxonoxExport Bar43 class Bar : public Ogre::OverlayElement 43 44 { 44 45 private: 45 int percentage_; 46 int dir_; 47 int left_; 48 int top_; 49 int width_; 50 int height_; 46 float percentage_; 47 bool dir_; 48 Ogre::ColourValue color_; 49 51 50 52 51 public: 53 static const int LEFT = 0;54 static const int UP = 1;55 static const int RIGHT = 2;56 static const int DOWN = 3;57 52 58 static const int RED = 0; 59 static const int YELLOW = 1; 60 static const int GREEN = 2; 61 62 Ogre::OverlayElement* element; 63 64 Bar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height, 65 int dir, int colour, std::string name); 66 ~Bar(void); 67 void reset(int percentage); 68 void setColour(int colour); 69 void show(); 70 void hide(); 71 72 }; 53 Bar(const Ogre::String& name); 54 // virtual ~Bar(); 73 55 74 56 75 class _OrxonoxExport SmartBar : public Bar76 {77 private:78 57 79 public: 80 SmartBar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height, 81 int dir, std::string name);82 ~SmartBar(void);83 void reset(int percentage);84 };58 59 /* Bar(const Ogre::String& s); 60 ~Bar(void); 61 void setPercentage(float percentage); 62 void setColor(Ogre::ColourValue color); 63 */ }; 85 64 } 86 65 -
code/branches/hud2/src/orxonox/hud/HUD.cc
r1000 r1002 35 35 #include "HUD.h" 36 36 #include "Bar.h" 37 #include " TestElement.h"37 #include "Factories.h" 38 38 // ugly hack 39 39 #include "Orxonox.h" … … 52 52 Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton(); 53 53 54 energyCounter = new Bar(0,0,100,20,Bar::LEFT,Bar::YELLOW,"Orxonox/HUD/energyCounterPanel/energyCounter");54 // energyCounter = new Bar(0,0,100,20,Bar::LEFT,Bar::YELLOW,"Orxonox/HUD/energyCounterPanel/energyCounter"); 55 55 56 56 Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel")); … … 62 62 energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS); 63 63 energyCounterPanel->show(); 64 energyCounterPanel->addChild(energyCounter->element);65 66 TestOverlayElementFactory *factory = new TestOverlayElementFactory();64 // energyCounterPanel->addChild(energyCounter->element); 65 66 BarOverlayElementFactory *factory = new BarOverlayElementFactory(); 67 67 overlayManager.addOverlayElementFactory(factory); 68 Ogre::OverlayElement* testElement = overlayManager.createOverlayElementFromFactory("Test", "testElement"); 68 Ogre::OverlayElement* BarElement = overlayManager.createOverlayElementFromFactory("Bar", "BarElement"); 69 70 71 72 69 73 70 74 Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD");
Note: See TracChangeset
for help on using the changeset viewer.