Changeset 2789 for code/branches
- Timestamp:
- Mar 16, 2009, 2:11:14 AM (16 years ago)
- Location:
- code/branches/miniprojects/src/orxonox/objects
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/miniprojects/src/orxonox/objects/controllers/Controller.cc
r2662 r2789 43 43 this->player_ = 0; 44 44 this->controllableEntity_ = 0; 45 this->hud_ = 0;46 this->bUpdateHUD_ = false;47 45 } 48 46 49 47 Controller::~Controller() 50 48 { 51 if (this->isInitialized() && this->hud_)52 delete this->hud_;53 }54 55 void Controller::changedControllableEntity()56 {57 if (this->bUpdateHUD_)58 {59 this->updateHUD();60 this->bUpdateHUD_ = false;61 }62 63 if (this->hud_)64 this->hud_->setOwner(this->getControllableEntity());65 }66 67 void Controller::updateHUD()68 {69 if (this->hud_)70 {71 delete this->hud_;72 this->hud_ = 0;73 }74 75 if (this->hudtemplate_ != "")76 {77 this->hud_ = new OverlayGroup(this);78 this->hud_->addTemplate(this->hudtemplate_);79 this->hud_->setOwner(this->getControllableEntity());80 }81 49 } 82 50 } -
code/branches/miniprojects/src/orxonox/objects/controllers/Controller.h
r2662 r2789 57 57 inline ControllableEntity* getControllableEntity() const 58 58 { return this->controllableEntity_; } 59 virtual void changedControllableEntity(); 60 61 inline void setHUDTemplate(const std::string& name) 62 { 63 if (name != this->hudtemplate_) 64 { 65 this->hudtemplate_ = name; 66 if (this->controllableEntity_) 67 this->updateHUD(); 68 else 69 this->bUpdateHUD_ = true; 70 } 71 } 72 inline const std::string& getHUDTemplate() const 73 { return this->hudtemplate_; } 74 75 inline OverlayGroup* getHUD() const 76 { return this->hud_; } 59 virtual void changedControllableEntity() {} 77 60 78 61 protected: 79 void updateHUD();80 81 62 PlayerInfo* player_; 82 63 ControllableEntity* controllableEntity_; 83 std::string hudtemplate_;84 OverlayGroup* hud_;85 bool bUpdateHUD_;86 64 }; 87 65 } -
code/branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h
r2768 r2789 112 112 { return this->gtinfo_.startCountdown_; } 113 113 114 inline void setHUDTemplate(const std::string& name) 115 { this->gtinfo_.hudtemplate_ = name; } 116 inline const std::string& getHUDTemplate() const 117 { return this->gtinfo_.hudtemplate_; } 118 114 119 void addBots(unsigned int amount); 115 120 void killBots(unsigned int amount = 0); -
code/branches/miniprojects/src/orxonox/objects/infos/GametypeInfo.cc
r2662 r2789 58 58 registerVariable(this->startCountdown_, variableDirection::toclient); 59 59 registerVariable(this->bStartCountdownRunning_, variableDirection::toclient); 60 registerVariable(this->hudtemplate_, variableDirection::toclient); 60 61 } 61 62 } -
code/branches/miniprojects/src/orxonox/objects/infos/GametypeInfo.h
r2662 r2789 56 56 { return this->startCountdown_; } 57 57 58 inline const std::string& getHUDTemplate() const 59 { return this->hudtemplate_; } 60 58 61 private: 59 62 bool bStarted_; … … 61 64 bool bStartCountdownRunning_; 62 65 float startCountdown_; 66 std::string hudtemplate_; 63 67 }; 64 68 } -
code/branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.cc
r2662 r2789 53 53 this->defaultController_ = Class(HumanController); 54 54 55 this->humanHud_ = 0; 56 55 57 this->setConfigValues(); 56 58 this->registerVariables(); … … 59 61 HumanPlayer::~HumanPlayer() 60 62 { 63 if (this->isInitialized() && this->humanHud_) 64 delete this->humanHud_; 61 65 } 62 66 … … 89 93 void HumanPlayer::configvaluecallback_changedHUDTemplate() 90 94 { 91 this-> changedController();95 this->setHumanHUDTemplate(this->hudtemplate_); 92 96 } 93 97 … … 146 150 } 147 151 148 void HumanPlayer::changedControll er()152 void HumanPlayer::changedControllableEntity() 149 153 { 150 if (this->getController()) 154 PlayerInfo::changedControllableEntity(); 155 156 if (this->humanHud_) 157 this->humanHud_->setOwner(this->getControllableEntity()); 158 } 159 160 void HumanPlayer::updateHumanHUD() 161 { 162 if (this->humanHud_) 151 163 { 152 this->getController()->setHUDTemplate(this->hudtemplate_); 164 delete this->humanHud_; 165 this->humanHud_ = 0; 166 } 153 167 154 if (this->getController() && this->getController()->getHUD()) 155 this->getController()->getHUD()->setOwner(this->getControllableEntity()); 168 if (this->humanHudTemplate_ != "") 169 { 170 this->humanHud_ = new OverlayGroup(this); 171 this->humanHud_->addTemplate(this->humanHudTemplate_); 172 this->humanHud_->setOwner(this->getControllableEntity()); 156 173 } 157 174 } -
code/branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.h
r2662 r2789 51 51 void setClientID(unsigned int clientID); 52 52 53 virtual void changedController(); 53 virtual void changedControllableEntity(); 54 55 inline void setHumanHUDTemplate(const std::string& name) 56 { 57 if (name != this->humanHudTemplate_) 58 { 59 this->humanHudTemplate_ = name; 60 this->updateHumanHUD(); 61 } 62 } 63 inline const std::string& getHumanHUDTemplate() const 64 { return this->humanHudTemplate_; } 65 66 inline OverlayGroup* getHumanHUD() const 67 { return this->humanHud_; } 54 68 55 69 protected: … … 61 75 void networkcallback_client_initialized(); 62 76 77 void updateHumanHUD(); 78 63 79 std::string nick_; 64 80 std::string synchronize_nick_; … … 66 82 bool server_initialized_; 67 83 bool client_initialized_; 84 85 std::string humanHudTemplate_; 86 OverlayGroup* humanHud_; 68 87 }; 69 88 } -
code/branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.cc
r2662 r2789 35 35 #include "network/ClientInformation.h" 36 36 #include "objects/gametypes/Gametype.h" 37 #include "overlays/OverlayGroup.h" 37 38 38 39 namespace orxonox … … 50 51 this->controllableEntity_ = 0; 51 52 this->controllableEntityID_ = CLIENTID_UNKNOWN; 53 this->gametypeHud_ = 0; 52 54 53 55 this->registerVariables(); … … 68 70 if (this->getGametype()) 69 71 this->getGametype()->playerLeft(this); 72 73 if (this->BaseObject::isInitialized() && this->gametypeHud_) 74 delete this->gametypeHud_; 70 75 } 71 76 } … … 104 109 else 105 110 this->getGametype()->playerEntered(this); 111 112 if (this->isLocalPlayer() && this->isHumanPlayer()) 113 if (this->getGametype()->getHUDTemplate() != "") 114 this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate()); 106 115 } 107 116 } … … 141 150 if (this->controller_) 142 151 this->controller_->setControllableEntity(entity); 152 153 this->changedControllableEntity(); 143 154 } 144 155 … … 155 166 if (callback) 156 167 entity->removePlayer(); 168 169 this->changedControllableEntity(); 157 170 } 158 171 } … … 172 185 } 173 186 } 187 188 void PlayerInfo::changedControllableEntity() 189 { 190 if (this->gametypeHud_) 191 this->gametypeHud_->setOwner(this->getControllableEntity()); 192 } 193 194 void PlayerInfo::updateGametypeHUD() 195 { 196 if (this->gametypeHud_) 197 { 198 delete this->gametypeHud_; 199 this->gametypeHud_ = 0; 200 } 201 202 if (this->isLocalPlayer() && this->isHumanPlayer() && this->gametypeHudTemplate_ != "") 203 { 204 this->gametypeHud_ = new OverlayGroup(this); 205 this->gametypeHud_->addTemplate(this->gametypeHudTemplate_); 206 this->gametypeHud_->setOwner(this->getControllableEntity()); 207 } 208 } 174 209 } -
code/branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.h
r2662 r2789 49 49 virtual void changedGametype(); 50 50 51 virtual void changedController() {} 52 virtual void changedControllableEntity(); 53 51 54 inline bool isHumanPlayer() const 52 55 { return this->bHumanPlayer_; } … … 73 76 inline Controller* getController() const 74 77 { return this->controller_; } 75 virtual void changedController() {} 78 79 inline void setGametypeHUDTemplate(const std::string& name) 80 { 81 if (name != this->gametypeHudTemplate_) 82 { 83 this->gametypeHudTemplate_ = name; 84 this->updateGametypeHUD(); 85 } 86 } 87 inline const std::string& getGametypeHUDTemplate() const 88 { return this->gametypeHudTemplate_; } 89 90 inline OverlayGroup* getGametypeHUD() const 91 { return this->gametypeHud_; } 76 92 77 93 protected: … … 86 102 private: 87 103 void networkcallback_changedcontrollableentityID(); 104 void updateGametypeHUD(); 88 105 89 106 bool bReadyToSpawn_; … … 91 108 ControllableEntity* controllableEntity_; 92 109 unsigned int controllableEntityID_; 110 std::string gametypeHudTemplate_; 111 OverlayGroup* gametypeHud_; 93 112 }; 94 113 }
Note: See TracChangeset
for help on using the changeset viewer.