Changeset 2890 for code/trunk/src/orxonox/overlays
- Timestamp:
- Apr 2, 2009, 8:42:11 PM (16 years ago)
- Location:
- code/trunk/src/orxonox/overlays
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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.