Changeset 1387
- Timestamp:
- May 22, 2008, 5:22:33 PM (17 years ago)
- Location:
- code/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/bin/keybindings.ini
r1376 r1387 15 15 KeyEQUALS=activateConsole 16 16 KeyBACK= 17 KeyTAB=cycle Focus17 KeyTAB=cycleRadarFocus 18 18 KeyQ= 19 19 KeyW= -
code/trunk/src/orxonox/Orxonox.cc
r1374 r1387 180 180 { 181 181 // keep in mind: the order of deletion is very important! 182 if (this->orxonoxHUD_)183 delete this->orxonoxHUD_;182 // if (this->orxonoxHUD_) 183 // delete this->orxonoxHUD_; 184 184 Loader::close(); 185 185 InputManager::destroy(); … … 348 348 // Load the HUD 349 349 COUT(3) << "Orxonox: Loading HUD..." << std::endl; 350 orxonoxHUD_ = new HUD(1);350 orxonoxHUD_ = &HUD::getSingleton(); 351 351 352 352 COUT(3) << "Orxonox: Loading Console..." << std::endl; … … 487 487 // orxonoxHUD_->setRocket2(ogreRoot.getCurrentFrameNumber()); 488 488 if (eventTimes[3].back() - eventTimes[3].front() != 0) 489 orxonoxHUD_->setFPS(50000.0f/(eventTimes[3].back() - eventTimes[3].front()));489 HUD::setFPS(50000.0f/(eventTimes[3].back() - eventTimes[3].front())); 490 490 491 491 // Iterate through all Tickables and call their tick(dt) function -
code/trunk/src/orxonox/hud/HUD.cc
r1375 r1387 43 43 namespace orxonox 44 44 { 45 ConsoleCommandShortcut(HUD, cycleRadarFocus, AccessLevel::User); 46 45 47 using namespace Ogre; 46 48 47 HUD::HUD( int zoom){49 HUD::HUD(){ 48 50 om = &Ogre::OverlayManager::getSingleton(); 49 51 … … 103 105 radar->addObject(Vector3(0.0, 4000.0, 0.0)); 104 106 radar->addObject(Vector3(0.0, 0.0, 6800.0)); 105 RadarOverlayElement::cycleFocus(); 107 } 108 109 HUD::~HUD(){ 110 //todo: clean up objects 106 111 } 107 112 … … 123 128 } 124 129 125 void HUD::setFPS(float fps){ 126 fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps)); 130 /*static*/HUD& HUD::getSingleton(){ 131 static HUD theInstance; 132 return theInstance; 127 133 } 128 134 129 HUD::~HUD(void){ 135 /*static*/void HUD::setFPS(float fps){ 136 HUD::getSingleton().fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps)); 137 } 138 139 /*static*/void HUD::cycleRadarFocus(){ 140 HUD::getSingleton().radar->cycleFocus(); 130 141 } 131 142 } -
code/trunk/src/orxonox/hud/HUD.h
r1374 r1387 46 46 { 47 47 private: 48 HUD(); 49 HUD(HUD& instance); 50 ~HUD(); 48 51 Ogre::OverlayManager* om; 49 52 Ogre::Overlay* orxonoxHUD; … … 56 59 57 60 public: 58 HUD(int zoom);59 ~HUD();60 void setFPS(float fps);61 61 virtual void tick(float); 62 62 63 static HUD* instance_s; 64 static HUD& getSingleton(); 65 static void setFPS(float fps); 66 static void cycleRadarFocus(); 63 67 }; 64 68 } -
code/trunk/src/orxonox/hud/RadarOverlayElement.cc
r1362 r1387 30 30 namespace orxonox 31 31 { 32 ConsoleCommandShortcut(RadarOverlayElement, cycleFocus, AccessLevel::User);33 32 34 33 using namespace Ogre; 35 34 36 RadarOverlayElement* RadarOverlayElement::instance_s = NULL;37 38 35 RadarOverlayElement::RadarOverlayElement(const String& name):Ogre::PanelOverlayElement(name){ 39 RadarOverlayElement::instance_s = this;40 36 } 41 37 … … 205 201 } 206 202 207 /*static*/void RadarOverlayElement::cycleFocus(){ 208 if(RadarOverlayElement::instance_s == NULL) return; 209 210 if(RadarOverlayElement::instance_s->focus_ == NULL){ 211 RadarOverlayElement::instance_s->focus_ = RadarOverlayElement::instance_s->firstRadarObject_; 203 void RadarOverlayElement::cycleFocus(){ 204 if(focus_ == NULL){ 205 focus_ = firstRadarObject_; 212 206 } 213 207 else{ 214 RadarOverlayElement::instance_s->focus_->panel_->setMaterialName("Orxonox/RedDot");215 RadarOverlayElement::instance_s->focus_ = RadarOverlayElement::instance_s->focus_->next;216 } 217 218 if( RadarOverlayElement::instance_s->focus_ == NULL){219 RadarOverlayElement::instance_s->navMarker_->hide();220 } 221 else{ 222 RadarOverlayElement::instance_s->navMarker_->show();223 RadarOverlayElement::instance_s->focus_->panel_->setMaterialName("Orxonox/WhiteDot");208 focus_->panel_->setMaterialName("Orxonox/RedDot"); 209 focus_ = focus_->next; 210 } 211 212 if(focus_ == NULL){ 213 navMarker_->hide(); 214 } 215 else{ 216 navMarker_->show(); 217 focus_->panel_->setMaterialName("Orxonox/WhiteDot"); 224 218 } 225 219 } -
code/trunk/src/orxonox/hud/RadarOverlayElement.h
r1362 r1387 72 72 void addObject(Vector3 pos); 73 73 void listObjects(); 74 void cycleFocus(); 74 75 float getDist2Focus(); 75 76 float calcRadius(RadarObject* obj); … … 81 82 RadarObject* lastRadarObject_; // end of linked list 82 83 RadarObject* focus_; // object that is focussed 83 84 static RadarOverlayElement* instance_s;85 static void cycleFocus();86 84 }; 87 85 }
Note: See TracChangeset
for help on using the changeset viewer.