Changeset 9281
- Timestamp:
- Jun 9, 2012, 3:51:51 PM (12 years ago)
- Location:
- code/branches/presentation2012merge
- Files:
-
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/data/gui/scripts/ShipSelectionMenu.lua
r9272 r9281 19 19 P.shipList = {} 20 20 for line in io.lines("../levels/templates/.shipmodels") do --checks if shipmodel is included in level file 21 if selectedlevel:hasS hip(string.lower(line)) then21 if selectedlevel:hasStartingShip(string.lower(line)) then 22 22 P.shipList[#P.shipList+1] = string.lower(line) 23 23 end … … 32 32 for k,v in pairs(P.shipList) do 33 33 --TODO: only add ship if is in the right filter tab 34 --if tag == nil or v:hasS hip(tag) then34 --if tag == nil or v:hasStartingShip(tag) then 35 35 local item = CEGUI.createListboxTextItem(v) 36 36 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") … … 107 107 108 108 if (selectedlevel ~= nil and P.ShipSelectionGetSelectedModel() ~= nil) then 109 selectedlevel:selectS hip(P.ShipSelectionGetSelectedModel())109 selectedlevel:selectStartingShip(P.ShipSelectionGetSelectedModel()) 110 110 orxonox.execute("startGame " .. "_temp.oxw") 111 111 hideAllMenuSheets() -
code/branches/presentation2012merge/data/gui/scripts/SingleplayerMenu.lua
r9272 r9281 48 48 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 49 49 if (level ~= nil and level:getXMLFilename() ~= "_temp.oxw") then 50 --os.execute("echo " .. level:getXMLFilename() .." >> ~/outputorx")51 50 local levelXMLFilename = level:getXMLFilename() 52 51 -- create an imageset for each screenshot -
code/branches/presentation2012merge/src/orxonox/LevelInfo.cc
r9269 r9281 42 42 43 43 // LevelInfoItem 44 44 45 45 //! The list of allowed tags. 46 46 /*static*/ std::set<std::string> LevelInfoItem::possibleTags_s = std::set<std::string>(); … … 107 107 SubString substr = SubString(tags, ",", " "); // Split the string into tags. 108 108 const std::vector<std::string>& strings = substr.getAllStrings(); 109 for (std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)109 for (std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++) 110 110 this->addTag(*it, false); 111 111 … … 118 118 A comma-seperated string of all the allowed ship models for the shipselection. 119 119 */ 120 void LevelInfoItem::setS hips(const std::string& ships)120 void LevelInfoItem::setStartingShips(const std::string& ships) 121 121 { 122 122 SubString substr = SubString(ships, ",", " "); // Split the string into tags. 123 123 const std::vector<std::string>& strings = substr.getAllStrings(); 124 124 for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++) 125 this->addS hip(*it, false);126 127 this->s hipsUpdated();125 this->addStartingShip(*it, false); 126 127 this->startingshipsUpdated(); 128 128 } 129 129 … … 161 161 Returns true if the ship was successfully added, if the ship was already present it returns false. 162 162 */ 163 bool LevelInfoItem::addS hip(const std::string& ship, bool update)164 { 165 bool success = this->s hips_.insert(ship).second;163 bool LevelInfoItem::addStartingShip(const std::string& ship, bool update) 164 { 165 bool success = this->startingShips_.insert(ship).second; 166 166 if(update && success) 167 this->s hipsUpdated();168 167 this->startingshipsUpdated(); 168 169 169 return success; 170 170 } … … 195 195 Updates the comma-seperated string of all ships, if the set of tags has changed. 196 196 */ 197 void LevelInfoItem::s hipsUpdated(void)197 void LevelInfoItem::startingshipsUpdated(void) 198 198 { 199 199 std::stringstream stream; 200 200 std::set<std::string>::iterator temp; 201 for(std::set<std::string>::iterator it = this->s hips_.begin(); it != this->ships_.end(); )201 for(std::set<std::string>::iterator it = this->startingShips_.begin(); it != this->startingShips_.end(); ) 202 202 { 203 203 temp = it; 204 if(++it == this->s hips_.end()) // If this is the last ship we don't add a comma.204 if(++it == this->startingShips_.end()) // If this is the last ship we don't add a comma. 205 205 stream << *temp; 206 206 else … … 210 210 this->startingShipsString_ = std::string(stream.str()); 211 211 } 212 213 void LevelInfoItem::changeStartingShip(const std::string& model) 214 { 215 static std::string shipSelectionTag = "shipselection"; 216 //HACK: Read Level XML File, find "shipselection", replace with ship model 217 std::string levelPath = "../levels/"; 218 levelPath.append(this->getXMLFilename()); 219 std::string tempPath = "../levels/"; 220 tempPath.append("_temp.oxw"); 221 orxout(user_status) << levelPath << endl; 222 orxout(user_status) << tempPath << endl; 223 std::ifstream myLevel (levelPath.c_str()); 224 std::ofstream tempLevel (tempPath.c_str()); 225 while(!myLevel.eof()) 226 { 227 std::string buff; 228 std::getline(myLevel, buff); 229 std::string pawndesignString = "pawndesign="; 230 size_t found = buff.find(pawndesignString.append(shipSelectionTag)); 231 if (found!= std::string::npos) 232 buff = buff.substr(0, found + 11) + model + buff.substr(found+11+shipSelectionTag.length(), std::string::npos); 233 tempLevel.write(buff.c_str(), buff.length()); 234 tempLevel << std::endl; 235 } 236 myLevel.close(); 237 tempLevel.close(); 238 orxout(user_status) << "done" << endl; 239 } 240 241 212 242 // LevelInfo 213 243 … … 247 277 XMLPortParam(LevelInfo, "screenshot", setScreenshot, getScreenshot, xmlelement, mode); 248 278 XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode); 249 XMLPortParam(LevelInfo, "startingships", setS hips, getShips, xmlelement, mode);279 XMLPortParam(LevelInfo, "startingships", setStartingShips, getStartingShips, xmlelement, mode); 250 280 } 251 281 … … 263 293 info->setScreenshot(this->getScreenshot()); 264 294 info->setTags(this->getTags()); 265 info->setS hips(this->getShips());295 info->setStartingShips(this->getStartingShips()); 266 296 return info; 267 297 } -
code/branches/presentation2012merge/src/orxonox/LevelInfo.h
r9272 r9281 118 118 inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export 119 119 120 void setS hips(const std::string& ships); //!< Set the starting ship models of the level121 bool addS hip(const std::string& ship, bool update = true); //!< Add a model to shipselection120 void setStartingShips(const std::string& ships); //!< Set the starting ship models of the level 121 bool addStartingShip(const std::string& ship, bool update = true); //!< Add a model to shipselection 122 122 /** 123 123 @brief Get the set of starting ship models the Level allows 124 124 @return Returns a comma-seperated string of all the allowed ship models for the shipselection. 125 125 */ 126 inline const std::string& getS hips(void) const126 inline const std::string& getStartingShips(void) const 127 127 { return this->startingShipsString_; } 128 128 /** … … 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 hasStartingShip(const std::string& ship) const { return this->startingShips_.find(ship) != this->startingShips_.end(); } // tolua_export 134 inline void selectStartingShip(const std::string& ship) { this->changeStartingShip(ship); } // tolua_export 134 135 /** 135 136 @brief Get the XML-filename of the Level. 136 137 @return Returns the XML-filename (including *.oxw extension) of the Level. 137 138 */ 138 139 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_export141 140 142 141 … … 152 151 153 152 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 } 153 void changeStartingShip (const std::string& model); 154 void startingshipsUpdated(void); //!< Updates the comma-seperated string of all possible starting ships. 181 155 void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed. 182 void shipsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.183 156 static void initializeTags(void); //!< Initialize the set of allowed tags. 184 157 /** … … 198 171 std::set<std::string> tags_; //!< The set of tags the Level is tagged with. 199 172 std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with. 200 std::set<std::string> s hips_; //!< The set of starting ship models the Level allows.173 std::set<std::string> startingShips_; //!< The set of starting ship models the Level allows. 201 174 std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection. 202 175 }; // tolua_export … … 276 249 @param A comma-seperated string of all the allowed ship models for the shipselection. 277 250 */ 278 inline void setS hips(const std::string& ships)279 { this->LevelInfoItem::setS hips(ships); }251 inline void setStartingShips(const std::string& ships) 252 { this->LevelInfoItem::setStartingShips(ships); } 280 253 /** 281 254 @brief Get the starting ship models of the level 282 255 @return Returns a comma-seperated string of all the allowed ship models for the shipselection. 283 256 */ 284 inline const std::string& getShips(void) const 285 { return this->LevelInfoItem::getShips(); } 257 inline const std::string& getStartingShips(void) const 258 { return this->LevelInfoItem::getStartingShips(); } 259 286 260 LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object. 287 261 };
Note: See TracChangeset
for help on using the changeset viewer.