Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 3, 2012, 6:05:24 PM (12 years ago)
Author:
landauf
Message:

replaced tabs with spaces (no code changed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2012merge/src/orxonox/LevelInfo.h

    r9269 r9272  
    2424 *   Co-authors:
    2525 *      ...
    26  *   
     26 *
    2727 */
    2828
     
    7979            */
    8080            inline const std::string& getName(void) const { return this->name_; } // tolua_export
    81        
     81
    8282            /**
    8383            @brief Set the screenshot of the Level.
     
    117117            */
    118118            inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
    119  
     119
    120120            void setShips(const std::string& ships); //!< Set the starting ship models of the level
    121121            bool addShip(const std::string& ship, bool update = true); //!< Add a model to shipselection
     
    125125            */
    126126            inline const std::string& getShips(void) const
    127                 { return this->startingShipsString_; }   
     127                { return this->startingShipsString_; }
    128128            /**
    129129            @brief Get whether the Level allows a specific starting ship model
     
    131131            @return Returns true if the Level allows the input ship model
    132132            */
    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
    134134            /**
    135135            @brief Get the XML-filename of the Level.
     
    138138
    139139            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
     140            inline void selectShip (const std::string& ship) { this->changeShip(ship); } // tolua_export
    141141
    142142
     
    153153        private:
    154154
    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             }
     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            }
    181181            void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
    182182            void shipsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
     
    199199            std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with.
    200200            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.
    202202    }; // tolua_export
    203203
     
    210210        - @b screenshot The screenshot of the level.
    211211        - @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
    213213        An example would be:
    214214        @code
     
    224224    @author
    225225        Damian 'Mozork' Frick
    226         @edit
    227                 Matthias Hutter
     226    @edit
     227        Matthias Hutter
    228228    @ingroup Orxonox
    229229    */
     
    235235
    236236            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a LevelInfo object through XML.
    237        
     237
    238238            /**
    239239            @brief Set the screenshot of the Level.
     
    283283            */
    284284            inline const std::string& getShips(void) const
    285                 { return this->LevelInfoItem::getShips(); }             
     285                { return this->LevelInfoItem::getShips(); }
    286286            LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object.
    287287    };
     
    302302            }
    303303    };
    304    
     304
    305305} // tolua_export
    306306
Note: See TracChangeset for help on using the changeset viewer.