Changeset 2789 for code/branches/miniprojects/src/orxonox/objects/infos
- Timestamp:
- Mar 16, 2009, 2:11:14 AM (16 years ago)
- Location:
- code/branches/miniprojects/src/orxonox/objects/infos
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
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.