Changeset 11071 for code/trunk/src/modules/overlays/hud/HUDWeapon.cc
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/overlays/hud/HUDWeapon.cc
r11052 r11071 44 44 weaponModeHUDActualSize_ = Vector2(0.0f,0.0f); 45 45 46 weaponModes_ = NULL;47 46 weaponIndex_ = 0; 48 47 hudWeaponModes_.clear(); … … 77 76 if (!weapon_) 78 77 { 79 // TODO: destroy this HUD id the Weapon does no more exist. (Wehen the weak pointer is NULL)78 // TODO: destroy this HUD id the Weapon does no more exist. (Wehen the weak pointer is null) 80 79 } 81 80 } … … 115 114 bool visible = this->isVisible(); 116 115 117 for ( std::vector<WeakPtr<HUDWeaponMode> >::iterator it = hudWeaponModes_.begin(); it != hudWeaponModes_.end(); ++it)118 { 119 (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed120 (*it)->setVisible(visible);116 for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_) 117 { 118 hudWeaponMode->changedVisibility(); //inform all Child Overlays that our visibility has changed 119 hudWeaponMode->setVisible(visible); 121 120 } 122 121 } … … 141 140 void HUDWeapon::updateWeaponModeList() 142 141 { 143 if (owner_ == NULL || weapon_ == NULL)142 if (owner_ == nullptr || weapon_ == nullptr) 144 143 { 145 144 return; … … 147 146 148 147 destroyHUDChilds(); 149 150 weaponModes_ = weapon_->getAllWeaponmodes();151 148 152 149 updateSize(); … … 157 154 void HUDWeapon::createHUDChilds() 158 155 { 159 if (weapon Modes_ == NULL)156 if (weapon_ == nullptr) 160 157 { 161 158 return; … … 164 161 int positionIndex = 0; 165 162 166 for ( std::multimap<unsigned int, WeaponMode*>::iterator it = weaponModes_->begin(); it != weaponModes_->end(); ++it)163 for (const auto& mapEntry : weapon_->getAllWeaponmodes()) 167 164 { 168 165 HUDWeaponMode* hudWeaponMode = new HUDWeaponMode(this->getContext()); … … 170 167 hudWeaponMode->setOverlayGroup(this->getOverlayGroup()); 171 168 hudWeaponMode->setVisible(this->isVisible()); 172 hudWeaponMode->setWeaponMode( it->second);169 hudWeaponMode->setWeaponMode(mapEntry.second); 173 170 hudWeaponMode->setWeaponIndex(this->weaponIndex_); 174 171 hudWeaponMode->setAspectCorrection(false); … … 185 182 int positionIndex = 0; 186 183 187 for ( std::vector<WeakPtr<HUDWeaponMode> >::iterator it = hudWeaponModes_.begin(); it != hudWeaponModes_.end(); ++it)188 { 189 (*it)->setPositionOffset(this->positionOffset_);190 (*it)->setWeaponModeIndex(positionIndex);191 (*it)->setWeaponIndex(this->weaponIndex_);192 (*it)->setWeaponModeHUDActualSize(this->weaponModeHUDActualSize_);184 for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_) 185 { 186 hudWeaponMode->setPositionOffset(this->positionOffset_); 187 hudWeaponMode->setWeaponModeIndex(positionIndex); 188 hudWeaponMode->setWeaponIndex(this->weaponIndex_); 189 hudWeaponMode->setWeaponModeHUDActualSize(this->weaponModeHUDActualSize_); 193 190 194 191 ++ positionIndex; … … 198 195 void HUDWeapon::destroyHUDChilds() 199 196 { 200 for ( std::vector<WeakPtr<HUDWeaponMode> >::iterator it = hudWeaponModes_.begin(); it != hudWeaponModes_.end(); ++it)201 { 202 (*it)->destroy();197 for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_) 198 { 199 hudWeaponMode->destroy(); 203 200 } 204 201 … … 208 205 void HUDWeapon::updateSize() 209 206 { 210 if (weapon Modes_ != NULL)211 { 212 this->setSize(Vector2(weaponModeHUDActualSize_.x,weaponModeHUDActualSize_.y*weapon Modes_->size()));207 if (weapon_ != nullptr) 208 { 209 this->setSize(Vector2(weaponModeHUDActualSize_.x,weaponModeHUDActualSize_.y*weapon_->getAllWeaponmodes().size())); 213 210 updatePosition(); 214 211 } … … 217 214 void HUDWeapon::updatePosition() 218 215 { 219 if (weapon Modes_ != NULL)216 if (weapon_ != nullptr) 220 217 { 221 218 this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f) + this->positionOffset_);
Note: See TracChangeset
for help on using the changeset viewer.