Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 9, 2012, 3:51:51 PM (12 years ago)
Author:
landauf
Message:

small cleanup in ship selection:

  • renamed some functions
  • moved implementation of changeStartingShip() from header to source file
  • removed ShipManager which doesn't seem to be used nor compiled (and it's just a copy of LevelManager anyway)
File:
1 edited

Legend:

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

    r9272 r9281  
    118118            inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
    119119
    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
     120            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
    122122            /**
    123123            @brief Get the set of starting ship models the Level allows
    124124            @return Returns a comma-seperated string of all the allowed ship models for the shipselection.
    125125            */
    126             inline const std::string& getShips(void) const
     126            inline const std::string& getStartingShips(void) const
    127127                { return this->startingShipsString_; }
    128128            /**
     
    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 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
    134135            /**
    135136            @brief Get the XML-filename of the Level.
    136137            @return Returns the XML-filename (including *.oxw extension) of the Level.
    137138            */
    138 
    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
    141140
    142141
     
    152151
    153152        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.
    181155            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.
    183156            static void initializeTags(void); //!< Initialize the set of allowed tags.
    184157            /**
     
    198171            std::set<std::string> tags_; //!< The set of tags the Level is tagged with.
    199172            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.
     173            std::set<std::string> startingShips_; //!< The set of starting ship models the Level allows.
    201174            std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection.
    202175    }; // tolua_export
     
    276249            @param A comma-seperated string of all the allowed ship models for the shipselection.
    277250            */
    278             inline void setShips(const std::string& ships)
    279                 { this->LevelInfoItem::setShips(ships); }
     251            inline void setStartingShips(const std::string& ships)
     252                { this->LevelInfoItem::setStartingShips(ships); }
    280253            /**
    281254            @brief Get the starting ship models of the level
    282255            @return Returns a comma-seperated string of all the allowed ship models for the shipselection.
    283256            */
    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
    286260            LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object.
    287261    };
Note: See TracChangeset for help on using the changeset viewer.