Changeset 9208 for code/branches/presentation2012/src/orxonox/LevelInfo.cc
- Timestamp:
- May 18, 2012, 3:39:47 PM (12 years ago)
- Location:
- code/branches/presentation2012
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012
- Property svn:mergeinfo changed
/code/branches/shipSelection (added) merged: 9038-9039,9045-9046,9057,9074,9101,9127-9128,9157,9185,9201
- Property svn:mergeinfo changed
-
code/branches/presentation2012/src/orxonox/LevelInfo.cc
r9016 r9208 93 93 LevelInfoItem::possibleTags_s.insert("gametype"); 94 94 LevelInfoItem::possibleTags_s.insert("minigame"); 95 LevelInfoItem::possibleTags_s.insert("shipselection"); 95 96 } 96 97 } … … 110 111 111 112 this->tagsUpdated(); 113 } 114 /** 115 @brief 116 Set the starting ship models of the level 117 @param tags 118 A comma-seperated string of all the allowed ship models for the shipselection. 119 */ 120 void LevelInfoItem::setShips(const std::string& ships) 121 { 122 SubString substr = SubString(ships, ",", " "); // Split the string into tags. 123 const std::vector<std::string>& strings = substr.getAllStrings(); 124 for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++) 125 this->addShip(*it, false); 126 127 this->shipsUpdated(); 112 128 } 113 129 … … 137 153 /** 138 154 @brief 155 Add a ship model to allowed models for the shipselection 156 @param ship 157 The ship model to be added. 158 @param update 159 Whether the comma-seperated string of all ship models should be updated. Default is true. 160 @return 161 Returns true if the ship was successfully added, if the ship was already present it returns false. 162 */ 163 bool LevelInfoItem::addShip(const std::string& ship, bool update) 164 { 165 bool success = this->ships_.insert(ship).second; 166 if(update && success) 167 this->shipsUpdated(); 168 169 return success; 170 } 171 172 173 /** 174 @brief 139 175 Updates the comma-seperated string of all tags, if the set of tags has changed. 140 176 */ … … 155 191 } 156 192 193 /** 194 @brief 195 Updates the comma-seperated string of all ships, if the set of tags has changed. 196 */ 197 void LevelInfoItem::shipsUpdated(void) 198 { 199 std::stringstream stream; 200 std::set<std::string>::iterator temp; 201 for(std::set<std::string>::iterator it = this->ships_.begin(); it != this->ships_.end(); ) 202 { 203 temp = it; 204 if(++it == this->ships_.end()) // If this is the last ship we don't add a comma. 205 stream << *temp; 206 else 207 stream << *temp << ", "; 208 } 209 210 this->startingShipsString_ = std::string(stream.str()); 211 } 157 212 // LevelInfo 158 213 … … 192 247 XMLPortParam(LevelInfo, "screenshot", setScreenshot, getScreenshot, xmlelement, mode); 193 248 XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode); 249 XMLPortParam(LevelInfo, "startingships", setShips, getShips, xmlelement, mode); 194 250 } 195 251 … … 207 263 info->setScreenshot(this->getScreenshot()); 208 264 info->setTags(this->getTags()); 265 info->setShips(this->getShips()); 209 266 return info; 210 267 }
Note: See TracChangeset
for help on using the changeset viewer.