Changeset 6054 for code/trunk/src
- Timestamp:
- Nov 13, 2009, 11:12:31 AM (15 years ago)
- Location:
- code/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/overlays/hud/HUDHealthBar.cc
r5929 r6054 48 48 this->textoverlay_ = new OverlayText(this); 49 49 50 assert(this->textoverlay_ );50 assert(this->textoverlay_.get()); 51 51 52 52 this->textoverlay_->setCaption(""); … … 56 56 { 57 57 if (this->isInitialized()) 58 { 58 59 this->textoverlay_->destroy(); 60 this->textoverlay_ = 0; 61 } 59 62 } 60 63 … … 106 109 SUPER(HUDHealthBar, changedOverlayGroup); 107 110 108 this->getOverlayGroup()->addElement(this->textoverlay_ );111 this->getOverlayGroup()->addElement(this->textoverlay_.get()); 109 112 } 110 113 -
code/trunk/src/modules/overlays/hud/HUDHealthBar.h
r5929 r6054 112 112 private: 113 113 WeakPtr<Pawn> owner_; 114 OverlayText*textoverlay_;114 SmartPtr<OverlayText> textoverlay_; 115 115 bool bUseBarColour_; 116 116 ColourValue textColour_; -
code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc
r5929 r6054 34 34 #include "gametypes/UnderAttack.h" 35 35 #include "worldentities/pawns/Destroyer.h" 36 #include "overlays/OverlayGroup.h" 36 37 37 38 namespace orxonox … … 58 59 { 59 60 if (this->isInitialized()) 61 { 60 62 this->text_->destroy(); 63 this->text_ = 0; 64 } 61 65 } 62 66 … … 90 94 } 91 95 } 96 97 void UnderAttackHealthBar::changedOverlayGroup() 98 { 99 SUPER(UnderAttackHealthBar, changedOverlayGroup); 100 101 this->getOverlayGroup()->addElement(this->text_.get()); 102 } 92 103 93 104 void UnderAttackHealthBar::init() -
code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.h
r5929 r6054 46 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 47 virtual void changedOwner(); 48 virtual void changedOverlayGroup(); 48 49 49 50 inline void setDescriptionPickPoint(const Vector2& pickpoint) … … 61 62 62 63 PlayerInfo* owner_; 63 OverlayText*text_;64 SmartPtr<OverlayText> text_; 64 65 Timer inittimer_; 65 66 }; -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r5980 r6054 60 60 OverlayGroup::~OverlayGroup() 61 61 { 62 for (std::set< OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)62 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 63 63 (*it)->destroy(); 64 this->hudElements_.clear(); 64 65 } 65 66 … … 83 84 void OverlayGroup::setScale(const Vector2& scale) 84 85 { 85 for (std::set< OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)86 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 86 87 (*it)->scale(scale / this->scale_); 87 88 this->scale_ = scale; … … 91 92 void OverlayGroup::setScroll(const Vector2& scroll) 92 93 { 93 for (std::set< OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)94 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 94 95 (*it)->scroll(scroll - this->scroll_); 95 96 this->scroll_ = scroll; … … 104 105 void OverlayGroup::addElement(OrxonoxOverlay* element) 105 106 { 106 hudElements_.insert( element);107 hudElements_.insert(SmartPtr<OrxonoxOverlay>(element)); 107 108 element->setOverlayGroup( this ); 108 109 if (this->owner_) … … 120 121 bool OverlayGroup::removeElement(OrxonoxOverlay* element) 121 122 { 122 if(this->hudElements_.erase( element) == 0)123 if(this->hudElements_.erase(SmartPtr<OrxonoxOverlay>(element)) == 0) 123 124 return false; 124 125 return true; … … 130 131 if (index < this->hudElements_.size()) 131 132 { 132 std::set< OrxonoxOverlay*>::const_iterator it = hudElements_.begin();133 std::set< SmartPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin(); 133 134 for (unsigned int i = 0; i != index; ++it, ++i) 134 135 ; 135 return (*it);136 return it->get(); 136 137 } 137 138 else … … 144 145 SUPER( OverlayGroup, changedVisibility ); 145 146 146 for (std::set< OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)147 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 147 148 (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed 148 149 } … … 152 153 this->owner_ = owner; 153 154 154 for (std::set< OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)155 for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 155 156 (*it)->setOwner(owner); 156 157 } -
code/trunk/src/orxonox/overlays/OverlayGroup.h
r5781 r6054 64 64 static void scrollGroup(const std::string& name, const Vector2& scroll); 65 65 66 inline const std::set< OrxonoxOverlay*>& getOverlays() const66 inline const std::set< SmartPtr<OrxonoxOverlay> >& getOverlays() const 67 67 { return this->hudElements_; } 68 68 … … 90 90 91 91 private: 92 std::set< OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group.92 std::set< SmartPtr<OrxonoxOverlay> > hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 93 93 Vector2 scale_; //!< Current scale (independent of the elements). 94 94 Vector2 scroll_; //!< Current scrolling offset.
Note: See TracChangeset
for help on using the changeset viewer.