Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9057


Ignore:
Timestamp:
Mar 23, 2012, 4:24:24 PM (12 years ago)
Author:
huttemat
Message:

test2

Location:
code/branches/shipSelection
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua

    r9046 r9057  
    22
    33local P = createMenuSheet("ShipSelectionMenu")
    4 level = nil
    54P.activeTabIndexes = {}
    65P.scrollbarWidth = 13
    7 function P.loadShips(levelname)
    8     --orxonox.execute("echo " .. levelname)
    9     --level = levelname
    10 end
     6
    117function P.onLoad()
    12 --[[    P.createLevelList()
    13    
     8   orxonox.execute("orxout internal_warning Ships= " .. selectedlevel.getShips())
     9   P.createLevelList(selectedlevel)
     10--[[     
    1411    -- create tabs with desired tab as argument (nil for all)
    1512    P.createFilterTab("Gametypes", "gametype")
     
    4037    })--]]
    4138end
    42 --[[
    43 function P.createLevelList()
    44     P.levelList = {}
     39
     40function P.createShipList(level)
     41
     42    orxonox.execute("orxout internal_warning Ships= " .. selectedlevel:getShips())
     43    --local stream = selectedlevel:getShips()
     44    --local substr = stream
     45    --while substr.find(",")
     46    --[[
    4547    local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
    4648    local index = 0
     
    6062        end
    6163        index = index + 1
    62     end
     64    end--]]
    6365end
     66
     67
    6468
    6569function P.createFilterTab(name, tag)
  • code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua

    r9046 r9057  
    66P.activeTabIndexes = {}
    77P.scrollbarWidth = 13
     8selectedlevel = {} -- level for ship selection
    89
    910function P.onLoad()
     
    141142
    142143function P.SingleplayerStartButton_clicked(e)
    143     local level = P.SingleplayerGetSelectedLevel()
    144     if level ~= nil then
    145 
    146         if level:hasTag("shipselection") then
     144    selectedlevel = P.SingleplayerGetSelectedLevel()
     145    if selectedlevel ~= nil then
     146        if selectedlevel:hasTag("shipselection") then
    147147            local shipSelectionMenu = showMenuSheet("ShipSelectionMenu", true)
    148             shipSelectionMenu:loadShips(level:getXMLFilename())
    149148        else
    150             orxonox.execute("startGame " .. level:getXMLFilename())
     149            orxonox.execute("startGame " .. selectedlevel:getXMLFilename())
    151150            hideAllMenuSheets()
    152151        end
  • code/branches/shipSelection/data/levels/tutorial.oxw

    r9046 r9057  
    44 tags = "tutorial, shipselection"
    55 screenshot = "codingtutorial.png"
     6 startingships = "spaceshipGhost, spaceshipPirate, spaceshipSpacecruiser"
    67/>
    78
  • code/branches/shipSelection/src/orxonox/LevelInfo.cc

    r9045 r9057  
    112112        this->tagsUpdated();
    113113    }
     114    /**
     115    @brief
     116        Set the starting ship models of the level
     117    @param tags
     118        A comma-seperated string of all the allowed ship models for the shipselection.
     119    */
     120    void LevelInfoItem::setShips(const std::string& ships)
     121    {
     122        SubString substr = SubString(ships, ",", " "); // Split the string into tags.
     123        const std::vector<std::string>& strings = substr.getAllStrings();
     124        for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
     125            this->addShip(*it, false);
     126
     127        this->shipsUpdated();
     128    }
    114129
    115130    /**
     
    138153    /**
    139154    @brief
     155        Add a ship model to allowed models for the shipselection
     156    @param ship
     157        The ship model to be added.
     158    @param update
     159        Whether the comma-seperated string of all ship models should be updated. Default is true.
     160    @return
     161        Returns true if the ship was successfully added, if the ship was already present it returns false.
     162    */
     163    bool LevelInfoItem::addShip(const std::string& ship, bool update)
     164    {
     165        bool success = this->tags_.insert(ship).second;
     166        if(update && success)
     167            this->tagsUpdated();
     168        return success;
     169    }
     170
     171
     172    /**
     173    @brief
    140174        Updates the comma-seperated string of all tags, if the set of tags has changed.
    141175    */
     
    156190    }
    157191
     192    /**
     193    @brief
     194        Updates the comma-seperated string of all ships, if the set of tags has changed.
     195    */
     196    void LevelInfoItem::shipsUpdated(void)
     197    {
     198        std::stringstream stream;
     199        std::set<std::string>::iterator temp;
     200        for(std::set<std::string>::iterator it = this->ships_.begin(); it != this->ships_.end(); )
     201        {
     202            temp = it;
     203            if(++it == this->ships_.end()) // If this is the last ship we don't add a comma.
     204                stream << *temp;
     205            else
     206                stream << *temp << ", ";
     207        }
     208
     209        this->startingShipsString_ = std::string(stream.str());
     210    }
    158211    // LevelInfo
    159212
     
    193246        XMLPortParam(LevelInfo, "screenshot", setScreenshot, getScreenshot, xmlelement, mode);
    194247        XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode);
     248        XMLPortParam(LevelInfo, "startingships", setShips, getShips, xmlelement, mode);
    195249    }
    196250
     
    208262        info->setScreenshot(this->getScreenshot());
    209263        info->setTags(this->getTags());
     264        info->setShips(this->getShips());
    210265        return info;
    211266    }
  • code/branches/shipSelection/src/orxonox/LevelInfo.h

    r9016 r9057  
    2424 *   Co-authors:
    2525 *      ...
    26  *
     26 *   
    2727 */
    2828
     
    115115            */
    116116            inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
    117 
     117 
     118            void setShips(const std::string& ships); //!< Set the starting ship models of the level
     119            bool addShip(const std::string& ship, bool update = true); //!< Add a model to shipselection
     120            /**
     121            @brief Get the set of starting ship models the Level allows
     122            @return Returns a comma-seperated string of all the allowed ship models for the shipselection.
     123            */
     124            inline const std::string& getShips(void) const
     125                { return this->startingShipsString_; }   
     126            /**
     127            @brief Get whether the Level allows a specific starting ship model
     128            @param ship The ship model for which is checked.
     129            @return Returns true if the Level allows the input ship model
     130            */
     131            inline bool hasShip(const std::string& ship) const { return this->ships_.find(ship) != this->ships_.end(); } // tolua_export       
    118132            /**
    119133            @brief Get the XML-filename of the Level.
    120134            @return Returns the XML-filename (including *.oxw extension) of the Level.
    121135            */
     136
    122137            inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export
    123138
     
    134149        private:
    135150            void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
    136 
     151            void shipsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
    137152            static void initializeTags(void); //!< Initialize the set of allowed tags.
    138153            /**
     
    152167            std::set<std::string> tags_; //!< The set of tags the Level is tagged with.
    153168            std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with.
     169            std::set<std::string> ships_; //!< The set of starting ship models the Level allows.
     170            std::string startingShipsString_; //!< The comma-seperated string of all the allowed ship models for the shipselection.           
    154171    }; // tolua_export
    155172
     
    161178        - @b description The description of the level.
    162179        - @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 
     180        - @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>.
     181        - @b (optional) startingships The comma-seperated string of starting ship models
    165182        An example would be:
    166183        @code
     
    176193    @author
    177194        Damian 'Mozork' Frick
    178 
     195        @edit
     196                Matthias Hutter
    179197    @ingroup Orxonox
    180198    */
     
    223241            inline const std::string& getTags(void) const
    224242                { return this->LevelInfoItem::getTags(); }
    225 
     243            /**
     244            @brief Set the starting ship models of the level
     245            @param A comma-seperated string of all the allowed ship models for the shipselection.
     246            */
     247            inline void setShips(const std::string& ships)
     248                { this->LevelInfoItem::setShips(ships); }
     249            /**
     250            @brief Get the starting ship models of the level
     251            @return Returns a comma-seperated string of all the allowed ship models for the shipselection.
     252            */
     253            inline const std::string& getShips(void) const
     254                { return this->LevelInfoItem::getShips(); }             
    226255            LevelInfoItem* copy(void); //!< Copies the contents of this LevelInfo object to a new LevelInfoItem object.
    227 
    228256    };
    229257
Note: See TracChangeset for help on using the changeset viewer.