Changeset 980 for code/branches/hud/src
- Timestamp:
- Apr 3, 2008, 2:52:50 PM (17 years ago)
- Location:
- code/branches/hud/src/orxonox/hud
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud/src/orxonox/hud/Bar.cc
r979 r980 3 3 * 4 4 * 5 * License notice: asdf5 * License notice: 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 28 28 #include <OgreOverlayManager.h> 29 29 #include <OgreOverlayElement.h> 30 #include <OgreTextAreaOverlayElement.h> 30 31 #include <OgreStringConverter.h> 31 #include <OgreColourValue.h>32 32 #include <string.h> 33 33 … … 37 37 { 38 38 using namespace Ogre; 39 40 Bar::Bar(Real left, Real top, Real width, Real height, 41 int dir, int colour, std::string name){ 42 Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton(); 43 element = overlayManager.createOverlayElement("Panel",name); 44 element->setMetricsMode(Ogre::GMM_PIXELS); 45 dir_ = dir; 46 left_ = left; 47 top_ = top; 48 width_ = width; 49 height_ = height; 50 element->setPosition(left_,top_); 51 element->setDimensions(width_,height_); 52 setColour(colour); 53 } 54 55 Bar::~Bar(void){} 56 57 58 void Bar::reset(int percentage){ 59 switch(dir_){ 60 case 1: 61 element->setPosition(left_,top_); 62 element->setDimensions(width_,height_*percentage/100); 63 break; 64 case 2: 65 element->setPosition(left_+width_-width_*percentage/100,top_); 66 element->setDimensions(width_*percentage/100,height_); 67 break; 68 case 3: 69 element->setPosition(left_,top_+height_-height_*percentage/100); 70 element->setDimensions(width_,height_*percentage/100); 71 break; 72 default: 73 element->setPosition(left_,top_); 74 element->setDimensions(width_*percentage/100,height_); 75 } 76 } 39 77 40 Bar::Bar(void){} 78 void Bar::setColour(int colour){ 79 switch(colour){ 80 case 0: 81 element->setMaterialName("Orxonox/Red"); 82 break; 83 case 1: 84 element->setMaterialName("Orxonox/Yellow"); 85 break; 86 case 2: 87 element->setMaterialName("Orxonox/Green"); 88 } 89 } 41 90 42 Bar::~Bar(void){} 91 void Bar::show(){element->show();} 92 93 void Bar::hide(){element->hide();} 94 95 SmartBar::SmartBar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height, 96 int dir, std::string name) : Bar::Bar(left, top, width, height, dir, Bar::YELLOW, name){ 97 } 98 99 SmartBar::~SmartBar(void){} 43 100 44 101 45 /* void Bar::setPercentage(Ogre::Real percentage){ 46 percentage_=percentage; 47 if(horz_){setWidth(int(percentage_* maxLength_));} 48 else {setHeight(int(percentage_ * maxHeight_));} 49 } 50 */ 51 52 void Bar::setPercentage(Ogre::Real percentage){ 53 percentage_ = percentage; 54 // setWidth(getWidth()); 102 void SmartBar::reset(int percentage){ 103 if (percentage>50) {setColour(Bar::GREEN);} 104 else if (percentage>25) {setColour(Bar::YELLOW);} 105 else setColour(Bar::RED); 106 Bar::reset(percentage); 55 107 } 56 108 109 } 57 110 58 111 59 60 void Bar::setColor(ColourValue color){61 color_=color;62 setColour(color);63 }64 65 66 } -
code/branches/hud/src/orxonox/hud/Bar.h
r825 r980 30 30 #define _BAR_H__ 31 31 32 #include <string> 33 #include <OgreColourValue.h> 32 #include <string.h> 34 33 #include <OgreOverlayElement.h> 34 #include <OgreTextAreaOverlayElement.h> 35 35 #include <OgrePrerequisites.h> 36 #include <string.h>37 36 #include "../OrxonoxPrereqs.h" 38 37 39 38 40 39 41 // namespace hud42 40 namespace orxonox 43 41 { 44 class Bar : public Ogre::OverlayElement42 class _OrxonoxExport Bar 45 43 { 46 44 private: 47 double percentage_; 48 bool horz_; 49 Ogre::ColourValue color_; 45 int percentage_; 46 int dir_; 47 int left_; 48 int top_; 49 int width_; 50 int height_; 51 52 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 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 }; 50 73 51 74 75 class _OrxonoxExport SmartBar : public Bar 76 { 77 private: 78 52 79 public: 53 Bar(void);54 ~Bar(void);55 void setPercentage(Ogre::Real percentage);56 void setColor(Ogre::ColourValue color);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); 57 84 }; 58 85 } -
code/branches/hud/src/orxonox/hud/HUD.cc
r964 r980 8 8 * modify it under the terms of the GNU General Public License 9 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) asdfany later version.10 * of the License, or (at your option) any later version. 11 11 * 12 12 * This program is distributed in the hope that it will be useful, … … 26 26 */ 27 27 28 28 29 #include "OrxonoxStableHeaders.h" 30 #include <OgreOverlay.h> 31 #include <OgreOverlayContainer.h> 32 #include <OgreOverlayManager.h> 33 34 #include "HUD.h" 35 #include "Bar.h" 36 37 38 namespace orxonox 39 { 40 using namespace Ogre; 41 42 43 44 45 46 HUD::HUD(int zoom){ 47 48 Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton(); 49 50 energyCounter = new Bar(0,0,100,20,Bar::LEFT,Bar::YELLOW,"Orxonox/HUD/energyCounterPanel/energyCounter"); 51 52 Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel")); 53 energyCounterPanel->setLeft(-50); 54 energyCounterPanel->setTop(10); 55 energyCounterPanel->setWidth(100); 56 energyCounterPanel->setHeight(20); 57 energyCounterPanel->setHorizontalAlignment(Ogre::GHA_CENTER); 58 energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS); 59 energyCounterPanel->show(); 60 energyCounterPanel->addChild(energyCounter->element); 61 62 Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD"); 63 orxonoxOverlay->add2D(energyCounterPanel); 64 orxonoxOverlay->show(); 65 } 66 67 HUD::~HUD(void){} 68 69 70 71 } 72 73 74 75 76 77 78 /*#include "OrxonoxStableHeaders.h" 29 79 30 80 #include <OgreOverlayManager.h> … … 34 84 #include "HUD.h" 35 85 #include "Bar.h" 36 37 86 38 87 namespace orxonox … … 51 100 setTargetWindowDistance(30); 52 101 53 setEnergyValue(60 .0);102 setEnergyValue(60); 54 103 55 104 setShieldLeftTopValue(true); … … 69 118 energyDistrPixelX_ = 100; 70 119 energyDistrPixelY_ = 86; 120 71 121 72 122 } … … 218 268 219 269 } 270 */ -
code/branches/hud/src/orxonox/hud/HUD.h
r790 r980 26 26 */ 27 27 28 28 29 #ifndef _HUD_H__ 30 #define _HUD_H__ 31 32 #include <string.h> 33 #include <OgreOverlayElement.h> 34 #include <OgreTextAreaOverlayElement.h> 35 #include <OgrePrerequisites.h> 36 #include "../OrxonoxPrereqs.h" 37 38 #include "Bar.h" 39 40 41 namespace orxonox 42 { 43 class _OrxonoxExport HUD 44 { 45 private: 46 47 public: 48 HUD(int zoom); 49 ~HUD(); 50 51 Bar* energyCounter; 52 }; 53 } 54 55 56 57 58 59 60 61 62 63 #endif _HUD_H_ 64 65 /*#ifndef _HUD_H__ 29 66 #define _HUD_H__ 30 67
Note: See TracChangeset
for help on using the changeset viewer.