Changeset 2890
- Timestamp:
- Apr 2, 2009, 8:42:11 PM (16 years ago)
- Location:
- code/trunk/src/orxonox
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/gametypes/Gametype.cc
r2839 r2890 229 229 if (it != this->players_.end()) 230 230 it->second.frags_++; 231 } 232 233 int Gametype::getScore(PlayerInfo* player) const 234 { 235 std::map<PlayerInfo*, Player>::const_iterator it = this->players_.find(player); 236 if (it != this->players_.end()) 237 return it->second.frags_; 238 else 239 return 0; 231 240 } 232 241 -
code/trunk/src/orxonox/objects/gametypes/Gametype.h
r2839 r2890 107 107 { return this->players_; } 108 108 109 int getScore(PlayerInfo* player) const; 110 109 111 inline void registerSpawnPoint(SpawnPoint* spawnpoint) 110 112 { this->spawnpoints_.insert(spawnpoint); } -
code/trunk/src/orxonox/objects/gametypes/Pong.cc
r2885 r2890 53 53 this->bat_[0] = 0; 54 54 this->bat_[1] = 0; 55 56 this->setHUDTemplate("PongHUD"); 55 57 56 58 this->starttimer_.setTimer(1.0, false, this, createExecutor(createFunctor(&Pong::startBall))); … … 181 183 this->ball_->setSpeed(this->center_->getBallSpeed()); 182 184 } 185 186 PlayerInfo* Pong::getLeftPlayer() const 187 { 188 if (this->bat_ && this->bat_[0]) 189 return this->bat_[0]->getPlayer(); 190 else 191 return 0; 192 } 193 194 PlayerInfo* Pong::getRightPlayer() const 195 { 196 if (this->bat_ && this->bat_[1]) 197 return this->bat_[1]->getPlayer(); 198 else 199 return 0; 200 } 183 201 } -
code/trunk/src/orxonox/objects/gametypes/Pong.h
r2826 r2890 53 53 { this->center_ = center; } 54 54 55 PlayerInfo* getLeftPlayer() const; 56 PlayerInfo* getRightPlayer() const; 57 55 58 protected: 56 59 void startBall(); -
code/trunk/src/orxonox/objects/infos/HumanPlayer.cc
r2826 r2890 173 173 if (this->humanHud_) 174 174 this->humanHud_->setOwner(this->getControllableEntity()); 175 176 if (this->gametypeHud_)177 this->gametypeHud_->setOwner(this->getControllableEntity());178 175 } 179 176 … … 206 203 this->gametypeHud_ = new OverlayGroup(this); 207 204 this->gametypeHud_->addTemplate(this->gametypeHudTemplate_); 208 this->gametypeHud_->setOwner(this->get ControllableEntity());205 this->gametypeHud_->setOwner(this->getGametype()); 209 206 } 210 207 } -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r2662 r2890 154 154 virtual void changedVisibility(); 155 155 156 inline void setOwner( ControllableEntity* owner)156 inline void setOwner(BaseObject* owner) 157 157 { 158 158 if (this->owner_ != owner) … … 162 162 } 163 163 } 164 inline ControllableEntity* getOwner() const164 inline BaseObject* getOwner() const 165 165 { return this->owner_; } 166 166 virtual void changedOwner() {} … … 206 206 We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */ 207 207 static std::map<std::string, OrxonoxOverlay*> overlays_s; 208 ControllableEntity* owner_;208 BaseObject* owner_; 209 209 OverlayGroup* group_; 210 210 }; -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r2662 r2890 63 63 OverlayGroup::~OverlayGroup() 64 64 { 65 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)66 delete it->second;65 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 66 delete (*it); 67 67 } 68 68 … … 83 83 } 84 84 85 //! Scales every element in the map.85 //! Scales every element in the set. 86 86 void OverlayGroup::setScale(const Vector2& scale) 87 87 { 88 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)89 (*it) .second->scale(scale / this->scale_);88 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 89 (*it)->scale(scale / this->scale_); 90 90 this->scale_ = scale; 91 91 } 92 92 93 //! Scrolls every element in the map.93 //! Scrolls every element in the set. 94 94 void OverlayGroup::setScroll(const Vector2& scroll) 95 95 { 96 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)97 (*it) .second->scroll(scroll - this->scroll_);96 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 97 (*it)->scroll(scroll - this->scroll_); 98 98 this->scroll_ = scroll; 99 99 } … … 101 101 /** 102 102 @brief 103 Adds an element to the map(used when loading with XMLPort).103 Adds an element to the set (used when loading with XMLPort). 104 104 @remarks 105 105 The names of the OrxonoxOverlays have to be unique! … … 107 107 void OverlayGroup::addElement(OrxonoxOverlay* element) 108 108 { 109 if (hudElements_.find(element->getName()) != hudElements_.end()) 110 { 111 COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl; 112 } 113 else 114 { 115 hudElements_[element->getName()] = element; 116 element->setVisible(this->isVisible()); 117 if (this->owner_) 118 element->setOwner(this->owner_); 119 } 109 hudElements_.insert(element); 110 element->setVisible(this->isVisible()); 111 if (this->owner_) 112 element->setOwner(this->owner_); 120 113 } 121 114 … … 125 118 if (index < this->hudElements_.size()) 126 119 { 127 std:: map<std::string,OrxonoxOverlay*>::const_iterator it = hudElements_.begin();120 std::set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin(); 128 121 for (unsigned int i = 0; i != index; ++it, ++i) 129 122 ; 130 return (*it) .second;123 return (*it); 131 124 } 132 125 else … … 137 130 void OverlayGroup::changedVisibility() 138 131 { 139 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)140 (*it) .second->setVisible(this->isVisible());132 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 133 (*it)->setVisible(this->isVisible()); 141 134 } 142 135 143 void OverlayGroup::setOwner( ControllableEntity* owner)136 void OverlayGroup::setOwner(BaseObject* owner) 144 137 { 145 138 this->owner_ = owner; 146 139 147 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)148 (*it) .second->setOwner(owner);140 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 141 (*it)->setOwner(owner); 149 142 } 150 143 -
code/trunk/src/orxonox/overlays/OverlayGroup.h
r2662 r2890 37 37 #include "OrxonoxPrereqs.h" 38 38 39 #include < map>39 #include <set> 40 40 #include <OgrePrerequisites.h> 41 41 #include "core/BaseObject.h" … … 64 64 static void scrollGroup(const std::string& name, const Vector2& scroll); 65 65 66 inline const std:: map<std::string,OrxonoxOverlay*>& getOverlays() const66 inline const std::set<OrxonoxOverlay*>& getOverlays() const 67 67 { return this->hudElements_; } 68 68 69 69 void changedVisibility(); 70 70 71 void setOwner( ControllableEntity* owner);72 inline ControllableEntity* getOwner() const71 void setOwner(BaseObject* owner); 72 inline BaseObject* getOwner() const 73 73 { return this->owner_; } 74 74 … … 89 89 90 90 private: 91 std:: map<std::string,OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group.92 Vector2 scale_; 93 Vector2 scroll_; 94 ControllableEntity* owner_;//!< The owner of this OverlayGroup91 std::set<OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 92 Vector2 scale_; //!< Current scale (independent of the elements). 93 Vector2 scroll_; //!< Current scrolling offset. 94 BaseObject* owner_; //!< The owner of this OverlayGroup 95 95 }; 96 96 } -
code/trunk/src/orxonox/overlays/hud/CMakeLists.txt
r2710 r2890 7 7 ChatOverlay.cc 8 8 GametypeStatus.cc 9 PongScore.cc 9 10 )
Note: See TracChangeset
for help on using the changeset viewer.