Changeset 9208 for code/branches/presentation2012/src/orxonox/LevelInfo.h
- 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.h
r9016 r9208 24 24 * Co-authors: 25 25 * ... 26 * 26 * 27 27 */ 28 28 … … 43 43 44 44 #include "core/BaseObject.h" 45 #include <iostream> 46 #include <fstream> 45 47 #include "core/OrxonoxClass.h" 46 48 … … 115 117 */ 116 118 inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export 117 119 120 void setShips(const std::string& ships); //!< Set the starting ship models of the level 121 bool addShip(const std::string& ship, bool update = true); //!< Add a model to shipselection 122 /** 123 @brief Get the set of starting ship models the Level allows 124 @return Returns a comma-seperated string of all the allowed ship models for the shipselection. 125 */ 126 inline const std::string& getShips(void) const 127 { return this->startingShipsString_; } 128 /** 129 @brief Get whether the Level allows a specific starting ship model 130 @param ship The ship model for which is checked. 131 @return Returns true if the Level allows the input ship model 132 */ 133 inline bool hasShip(const std::string& ship) const { return this->ships_.find(ship) != this->ships_.end(); } // tolua_export 118 134 /** 119 135 @brief Get the XML-filename of the Level. 120 136 @return Returns the XML-filename (including *.oxw extension) of the Level. 121 137 */ 138 122 139 inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export 140 inline void selectShip (const std::string& ship) { this->changeShip(ship); } // tolua_export 141 123 142 124 143 protected: … … 133 152 134 153 private: 154 155 inline void changeShip (const std::string& model) { 156 static std::string shipSelectionTag = "shipselection"; 157 //HACK: Read Level XML File, find "shipselection", replace with ship model 158 std::string levelPath = "../levels/"; 159 levelPath.append(this->getXMLFilename()); 160 std::string tempPath = "../levels/"; 161 tempPath.append("_temp.oxw"); 162 orxout(user_status) << levelPath << endl; 163 orxout(user_status) << tempPath << endl; 164 std::ifstream myLevel (levelPath.c_str()); 165 std::ofstream tempLevel (tempPath.c_str()); 166 while(!myLevel.eof()) 167 { 168 std::string buff; 169 std::getline(myLevel, buff); 170 std::string pawndesignString = "pawndesign="; 171 size_t found = buff.find(pawndesignString.append(shipSelectionTag)); 172 if (found!= std::string::npos) 173 buff = buff.substr(0, found + 11) + model + buff.substr(found+11+shipSelectionTag.length(), std::string::npos); 174 tempLevel.write(buff.c_str(), buff.length()); 175 tempLevel << std::endl; 176 } 177 myLevel.close(); 178 tempLevel.close(); 179 orxout(user_status) << "done" << endl; 180 } 135 181 void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. 136 182 void shipsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. 137 183 static void initializeTags(void); //!< Initialize the set of allowed tags. 138 184 /** … … 152 198 std::set<std::string> tags_; //!< The set of tags the Level is tagged with. 153 199 std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with. 200 std::set<std::string> ships_; //!< The set of starting ship models the Level allows. 201 std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection. 154 202 }; // tolua_export 155 203 … … 161 209 - @b description The description of the level. 162 210 - @b screenshot The screenshot of the level. 163 - @b tags A comma-seperated string of tags. Allowed tags are: <em>test</em>, <em>singleplayer</em>, <em>multiplayer</em>, <em>showcase</em>, <em>tutorial</em>, <em>presentation</em> .164 211 - @b tags A comma-seperated string of tags. Allowed tags are: <em>test</em>, <em>singleplayer</em>, <em>multiplayer</em>, <em>showcase</em>, <em>tutorial</em>, <em>presentation</em>, <em>shipselection</em>. 212 - @b (optional) startingships The comma-seperated string of starting ship models 165 213 An example would be: 166 214 @code … … 176 224 @author 177 225 Damian 'Mozork' Frick 178 226 @edit 227 Matthias Hutter 179 228 @ingroup Orxonox 180 229 */ … … 223 272 inline const std::string& getTags(void) const 224 273 { return this->LevelInfoItem::getTags(); } 225 274 /** 275 @brief Set the starting ship models of the level 276 @param A comma-seperated string of all the allowed ship models for the shipselection. 277 */ 278 inline void setShips(const std::string& ships) 279 { this->LevelInfoItem::setShips(ships); } 280 /** 281 @brief Get the starting ship models of the level 282 @return Returns a comma-seperated string of all the allowed ship models for the shipselection. 283 */ 284 inline const std::string& getShips(void) const 285 { return this->LevelInfoItem::getShips(); } 226 286 LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object. 227 228 287 }; 229 288
Note: See TracChangeset
for help on using the changeset viewer.