- Timestamp:
- Jun 3, 2012, 6:05:24 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/src/orxonox/LevelInfo.h
r9269 r9272 24 24 * Co-authors: 25 25 * ... 26 * 26 * 27 27 */ 28 28 … … 79 79 */ 80 80 inline const std::string& getName(void) const { return this->name_; } // tolua_export 81 81 82 82 /** 83 83 @brief Set the screenshot of the Level. … … 117 117 */ 118 118 inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export 119 119 120 120 void setShips(const std::string& ships); //!< Set the starting ship models of the level 121 121 bool addShip(const std::string& ship, bool update = true); //!< Add a model to shipselection … … 125 125 */ 126 126 inline const std::string& getShips(void) const 127 { return this->startingShipsString_; } 127 { return this->startingShipsString_; } 128 128 /** 129 129 @brief Get whether the Level allows a specific starting ship model … … 131 131 @return Returns true if the Level allows the input ship model 132 132 */ 133 inline bool hasShip(const std::string& ship) const { return this->ships_.find(ship) != this->ships_.end(); } // tolua_export 133 inline bool hasShip(const std::string& ship) const { return this->ships_.find(ship) != this->ships_.end(); } // tolua_export 134 134 /** 135 135 @brief Get the XML-filename of the Level. … … 138 138 139 139 inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export 140 140 inline void selectShip (const std::string& ship) { this->changeShip(ship); } // tolua_export 141 141 142 142 … … 153 153 private: 154 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 size_t found = buff.find(pawndesignString.append(shipSelectionTag)); 172 if (found!= std::string::npos) 173 174 175 176 177 178 179 180 } 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 } 181 181 void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. 182 182 void shipsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. … … 199 199 std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with. 200 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. 201 std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection. 202 202 }; // tolua_export 203 203 … … 210 210 - @b screenshot The screenshot of the level. 211 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 212 - @b (optional) startingships The comma-seperated string of starting ship models 213 213 An example would be: 214 214 @code … … 224 224 @author 225 225 Damian 'Mozork' Frick 226 227 226 @edit 227 Matthias Hutter 228 228 @ingroup Orxonox 229 229 */ … … 235 235 236 236 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML. 237 237 238 238 /** 239 239 @brief Set the screenshot of the Level. … … 283 283 */ 284 284 inline const std::string& getShips(void) const 285 { return this->LevelInfoItem::getShips(); } 285 { return this->LevelInfoItem::getShips(); } 286 286 LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object. 287 287 }; … … 302 302 } 303 303 }; 304 304 305 305 } // tolua_export 306 306
Note: See TracChangeset
for help on using the changeset viewer.