- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc
r2907 r2908 63 63 OverlayGroup::~OverlayGroup() 64 64 { 65 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)66 delete (*it);65 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 66 delete it->second; 67 67 } 68 68 … … 83 83 } 84 84 85 //! Scales every element in the set.85 //! Scales every element in the map. 86 86 void OverlayGroup::setScale(const Vector2& scale) 87 87 { 88 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)89 (*it) ->scale(scale / this->scale_);88 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 89 (*it).second->scale(scale / this->scale_); 90 90 this->scale_ = scale; 91 91 } 92 92 93 //! Scrolls every element in the set.93 //! Scrolls every element in the map. 94 94 void OverlayGroup::setScroll(const Vector2& scroll) 95 95 { 96 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)97 (*it) ->scroll(scroll - this->scroll_);96 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 97 (*it).second->scroll(scroll - this->scroll_); 98 98 this->scroll_ = scroll; 99 99 } … … 101 101 /** 102 102 @brief 103 Adds an element to the set(used when loading with XMLPort).103 Adds an element to the map (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 hudElements_.insert(element); 110 element->setVisible(this->isVisible()); 111 if (this->owner_) 112 element->setOwner(this->owner_); 113 } 114 115 /** 109 this->insertElement(element, element->getName()); 110 } 111 112 /** 113 @brief 114 Adds an element to the map. 115 @param element 116 The element to be added. 117 @param name 118 The name of the element. 119 @remarks 120 The names of the OrxonoxOverlays have to be unique! 121 */ 122 void OverlayGroup::insertElement(OrxonoxOverlay* element, const std::string & name) 123 { 124 element->setName(name); 125 if (hudElements_.find(name) != hudElements_.end()) 126 { 127 COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl; 128 } 129 else 130 { 131 hudElements_[name] = element; 132 element->setVisible(this->isVisible()); 133 if (this->owner_) 134 element->setOwner(this->owner_); 135 } 136 } 137 138 /** 116 139 @brief 117 140 Removes an element from the map. 118 @param element119 The element that is to beremoved.141 @param name 142 The name of the element that is removed. 120 143 @return 121 144 Returns true if there was such an element to remove, false if not. 122 145 */ 123 bool OverlayGroup::removeElement( OrxonoxOverlay* element)124 { 125 if(this->hudElements_.erase( element) == 0)146 bool OverlayGroup::removeElement(const std::string & name) 147 { 148 if(this->hudElements_.erase(name) == 0) 126 149 return false; 127 150 return true; … … 133 156 if (index < this->hudElements_.size()) 134 157 { 135 std:: set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin();158 std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin(); 136 159 for (unsigned int i = 0; i != index; ++it, ++i) 137 160 ; 138 return (*it) ;161 return (*it).second; 139 162 } 140 163 else … … 145 168 void OverlayGroup::changedVisibility() 146 169 { 147 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)148 (*it) ->setVisible(this->isVisible());149 } 150 151 void OverlayGroup::setOwner( BaseObject* owner)170 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 171 (*it).second->setVisible(this->isVisible()); 172 } 173 174 void OverlayGroup::setOwner(ControllableEntity* owner) 152 175 { 153 176 this->owner_ = owner; 154 177 155 for (std:: set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)156 (*it) ->setOwner(owner);178 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 179 (*it).second->setOwner(owner); 157 180 } 158 181
Note: See TracChangeset
for help on using the changeset viewer.