Changeset 2819
- Timestamp:
- Mar 22, 2009, 9:59:34 PM (16 years ago)
- Location:
- code/branches/miniprojects/src/orxonox/objects/infos
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.cc
r2806 r2819 54 54 55 55 this->humanHud_ = 0; 56 this->gametypeHud_ = 0; 56 57 57 58 this->setConfigValues(); … … 61 62 HumanPlayer::~HumanPlayer() 62 63 { 63 if (this->BaseObject::isInitialized() && this->humanHud_) 64 delete this->humanHud_; 64 if (this->BaseObject::isInitialized()) 65 { 66 if (this->humanHud_) 67 delete this->humanHud_; 68 69 if (this->gametypeHud_) 70 delete this->gametypeHud_; 71 } 65 72 } 66 73 … … 115 122 116 123 this->createController(); 124 this->updateHumanHUD(); 117 125 } 118 126 } … … 150 158 } 151 159 160 void HumanPlayer::changedGametype() 161 { 162 PlayerInfo::changedGametype(); 163 164 if (this->isInitialized() && this->isLocalPlayer()) 165 if (this->getGametype()->getHUDTemplate() != "") 166 this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate()); 167 } 168 152 169 void HumanPlayer::changedControllableEntity() 153 170 { … … 156 173 if (this->humanHud_) 157 174 this->humanHud_->setOwner(this->getControllableEntity()); 175 176 if (this->gametypeHud_) 177 this->gametypeHud_->setOwner(this->getControllableEntity()); 158 178 } 159 179 … … 166 186 } 167 187 168 if (this-> humanHudTemplate_ != "")188 if (this->isLocalPlayer() && this->humanHudTemplate_ != "") 169 189 { 170 190 this->humanHud_ = new OverlayGroup(this); … … 173 193 } 174 194 } 195 196 void HumanPlayer::updateGametypeHUD() 197 { 198 if (this->gametypeHud_) 199 { 200 delete this->gametypeHud_; 201 this->gametypeHud_ = 0; 202 } 203 204 if (this->isLocalPlayer() && this->gametypeHudTemplate_ != "") 205 { 206 this->gametypeHud_ = new OverlayGroup(this); 207 this->gametypeHud_->addTemplate(this->gametypeHudTemplate_); 208 this->gametypeHud_->setOwner(this->getControllableEntity()); 209 } 210 } 175 211 } -
code/branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.h
r2789 r2819 51 51 void setClientID(unsigned int clientID); 52 52 53 virtual void changedGametype(); 53 54 virtual void changedControllableEntity(); 54 55 … … 63 64 inline const std::string& getHumanHUDTemplate() const 64 65 { return this->humanHudTemplate_; } 65 66 66 inline OverlayGroup* getHumanHUD() const 67 67 { return this->humanHud_; } 68 69 inline void setGametypeHUDTemplate(const std::string& name) 70 { 71 if (name != this->gametypeHudTemplate_) 72 { 73 this->gametypeHudTemplate_ = name; 74 this->updateGametypeHUD(); 75 } 76 } 77 inline const std::string& getGametypeHUDTemplate() const 78 { return this->gametypeHudTemplate_; } 79 inline OverlayGroup* getGametypeHUD() const 80 { return this->gametypeHud_; } 68 81 69 82 protected: … … 76 89 77 90 void updateHumanHUD(); 91 void updateGametypeHUD(); 78 92 79 93 std::string nick_; … … 85 99 std::string humanHudTemplate_; 86 100 OverlayGroup* humanHud_; 101 std::string gametypeHudTemplate_; 102 OverlayGroup* gametypeHud_; 87 103 }; 88 104 } -
code/branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.cc
r2789 r2819 35 35 #include "network/ClientInformation.h" 36 36 #include "objects/gametypes/Gametype.h" 37 #include "overlays/OverlayGroup.h"38 37 39 38 namespace orxonox … … 51 50 this->controllableEntity_ = 0; 52 51 this->controllableEntityID_ = CLIENTID_UNKNOWN; 53 this->gametypeHud_ = 0;54 52 55 53 this->registerVariables(); … … 70 68 if (this->getGametype()) 71 69 this->getGametype()->playerLeft(this); 72 73 if (this->BaseObject::isInitialized() && this->gametypeHud_)74 delete this->gametypeHud_;75 70 } 76 71 } … … 109 104 else 110 105 this->getGametype()->playerEntered(this); 111 112 if (this->isLocalPlayer() && this->isHumanPlayer())113 if (this->getGametype()->getHUDTemplate() != "")114 this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());115 106 } 116 107 } … … 185 176 } 186 177 } 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 }209 178 } -
code/branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.h
r2789 r2819 50 50 51 51 virtual void changedController() {} 52 virtual void changedControllableEntity() ;52 virtual void changedControllableEntity() {} 53 53 54 54 inline bool isHumanPlayer() const … … 77 77 { return this->controller_; } 78 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() const88 { return this->gametypeHudTemplate_; }89 90 inline OverlayGroup* getGametypeHUD() const91 { return this->gametypeHud_; }92 93 79 protected: 94 80 void createController(); … … 102 88 private: 103 89 void networkcallback_changedcontrollableentityID(); 104 void updateGametypeHUD();105 90 106 91 bool bReadyToSpawn_; … … 108 93 ControllableEntity* controllableEntity_; 109 94 unsigned int controllableEntityID_; 110 std::string gametypeHudTemplate_;111 OverlayGroup* gametypeHud_;112 95 }; 113 96 }
Note: See TracChangeset
for help on using the changeset viewer.