Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2016, 5:37:05 PM (9 years ago)
Author:
binderm
Message:

The Campaign menu now works. The levels are structured in a tree. If one goes the left branch, the right one can't be taken anymore. The last challenge is to save the progress in the config variables. to set does work, but not to modify those variables.

Location:
code/branches/bindermFS16
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua

    r11186 r11191  
    1717    P.updateButton(7, winMgr:getWindow("orxonox/Mission8Button"))
    1818    P.updateButton(8, winMgr:getWindow("orxonox/Mission9Button"))
     19end
    1920
    20 
    21 --    if (P.getIndexOfLastFinishedMission() == orxonox.LevelManager:getInstance():getNumberOfCampaignMissions() - 1) then
    22 --        local label = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
    23 --        label:setProperty("Visible","True")
    24 --    end
    25 end
    2621
    2722function P.updateButton(index, button)
     
    4641    end
    4742end
    48 
    49 --function P.shouldDisplayButton(index)
    50 --    local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
    51 --    return index < size
    52 --end
    53 
    54 --function P.shouldActivateButton(index) --checks if button should be activated or not
    55 --    return index <= P.getIndexOfLastFinishedMission() + 1
    56 --end
    5743
    5844function P.getIndexOfLastFinishedMission()
  • code/branches/bindermFS16/src/orxonox/CMakeLists.txt

    r11186 r11191  
    6262    LevelInfo.h
    6363    LevelManager.h
    64     LevelStatus.h
    6564    MoodManager.h
    6665    controllers/HumanController.h
  • code/branches/bindermFS16/src/orxonox/LevelManager.cc

    r11188 r11191  
    9999    void LevelManager::setConfigValues()
    100100    {
     101
    101102        SetConfigValue(defaultLevelName_, "missionOne.oxw")
    102103            .description("Sets the pre selection of the level in the main menu.");
     
    105106        SetConfigValue(campaignMissions_,  std::vector<std::string>())
    106107            .description("The list of missions in the campaign");
    107         //SetConfigValue(test_,  std::vector<int>())
    108          //   .description("The list of missions and their statuses");
    109            
     108        //std::vector<int> v (allLevelStatus_.size(),0);
     109        //SetConfigValue(allLevelWon_, v)
     110        //    .description("The list of all won missions");
    110111    }
    111112
     
    185186    void LevelManager::activateNextLevel()
    186187    {
     188
    187189        if (this->levels_.size() > 0)
    188190        {
     
    358360                allLevelStatus_[i].activated=1;
    359361                std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
    360                 for(unsigned int j=i+1;j<allLevelStatus_.size();j++)
     362                for(unsigned int j=0;j<allLevelStatus_.size();j++)
    361363                {
    362364                    allLevelStatus_[j].activated=nextLevels[j];
     
    366368    }
    367369
    368     //updates the won variable of the corresponding LevelStatus in allLevelStatus_
     370
    369371    void LevelManager::setLevelStatus(const std::string& LevelWon)
    370372    {
    371         ModifyConfigValue(lastWonMission_, set, LevelWon); 
    372     }
    373 
    374 
    375     //build up allLevelStatus
     373       
     374           
     375        ModifyConfigValue(lastWonMission_, set, LevelWon);
     376
     377        std::vector<int> v (allLevelStatus_.size(),0);
     378        for(unsigned int i = 0;i<allLevelStatus_.size();i++)
     379        {
     380            if(allLevelStatus_[i].won)
     381                v[i] =1;
     382        }
     383
     384        SetConfigValue(allLevelWon_, v)
     385            .description("The list of all won missions");
     386
     387            for (unsigned int i = 0; i < allLevelWon_.size(); ++i)
     388            {
     389                ModifyConfigValue(allLevelWon_[i], set, v[i]);
     390            }
     391
     392    }
     393
     394
     395    //build up allLevelStatus_
    376396    //has to be done once per game (not per level)
    377     //all connections between the levels are saved in here
     397    //all connections between the levels are saved in the allLevelStatus_
     398    //also the won variable of the LevelStatus is set to the corresponding allLevelWon_ value
    378399    void LevelManager::buildallLevelStatus()
    379400    {
    380         LevelStatus* level = new LevelStatus(this->getContext());
    381 
    382         /*LevelStatus level;
    383         allLevelStatus_.assign (campaignMissions_.size(),level);
     401        LevelStatus* level=new LevelStatus(this->getContext());
     402        allLevelStatus_.assign (campaignMissions_.size(),*level);
    384403        allLevelStatus_[0].activated=1;
    385         //allLevelStatus_[0].won=true;
    386 
    387 
    388         allLevelStatus_[0].nextLevels.push_back(1);
    389         allLevelStatus_[0].nextLevels.push_back(1);
    390         allLevelStatus_[0].nextLevels.push_back(0);
    391         allLevelStatus_[0].nextLevels.push_back(0);
    392         allLevelStatus_[0].nextLevels.push_back(0);
    393         allLevelStatus_[0].nextLevels.push_back(0);
    394         allLevelStatus_[0].nextLevels.push_back(0);
    395 
    396         allLevelStatus_[1].nextLevels.push_back(1);
    397         allLevelStatus_[1].nextLevels.push_back(2);
    398         allLevelStatus_[1].nextLevels.push_back(1);
    399         allLevelStatus_[1].nextLevels.push_back(0);
    400         allLevelStatus_[1].nextLevels.push_back(0);
    401         allLevelStatus_[1].nextLevels.push_back(0);
    402         allLevelStatus_[1].nextLevels.push_back(0);
    403 
    404         allLevelStatus_[2].nextLevels.push_back(2);
    405         allLevelStatus_[2].nextLevels.push_back(1);
    406         allLevelStatus_[2].nextLevels.push_back(0);
    407         allLevelStatus_[2].nextLevels.push_back(0);
    408         allLevelStatus_[2].nextLevels.push_back(1);
    409         allLevelStatus_[2].nextLevels.push_back(0);
    410         allLevelStatus_[2].nextLevels.push_back(0);*/
    411 
    412 
     404
     405
     406        std::vector<int> v={1,1,1,0,0,0,0,0,0};
     407        allLevelStatus_[0].nextLevels=v;
     408
     409        v={1,1,2,1,0,0,0,0,0};
     410        allLevelStatus_[1].nextLevels=v;
     411
     412        v={1,2,1,0,1,0,0,0,0};
     413        allLevelStatus_[2].nextLevels=v;
     414
     415        v={1,1,2,1,0,1,1,0,0};
     416        allLevelStatus_[3].nextLevels=v;
     417
     418        v={1,2,1,0,1,0,0,1,1};
     419        allLevelStatus_[4].nextLevels=v;
     420
     421        v={1,1,2,1,0,1,2,0,0};
     422        allLevelStatus_[5].nextLevels=v;
     423
     424        v={1,1,2,1,0,2,1,0,0};
     425        allLevelStatus_[6].nextLevels=v;
     426
     427        v={1,2,1,0,1,0,0,1,2};
     428        allLevelStatus_[7].nextLevels=v;
     429
     430        v={1,2,1,0,1,0,0,2,1};
     431        allLevelStatus_[8].nextLevels=v;
    413432
    414433    }
  • code/branches/bindermFS16/src/orxonox/LevelManager.h

    r11186 r11191  
    2424 *   Co-authors:
    2525 *      Damian 'Mozork' Frick
     26 *      Matthias Binder
    2627 *
    2728 */
     
    147148            std::string lastWonMission_;
    148149            std::vector<std::string> campaignMissions_;
    149             std::vector<int> test_;
     150            std::vector<int> allLevelWon_;
    150151            std::vector<LevelStatus> allLevelStatus_;
    151152
  • code/branches/bindermFS16/src/orxonox/LevelStatus.h

    r11188 r11191  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
    24  *   Co-authors:
    25  *      Damian 'Mozork' Frick
     23 *      Matthias Binder
    2624 *
    2725 */
    2826
    29 /**
    30     @file LevelManager.h
    31     @brief Definition of the LevelManager singleton.
    32     @ingroup Orxonox
    33 */
     27
    3428#ifndef _LevelStatus_H__
    3529#define _LevelStatus_H__
     
    5246{
    5347
     48    /**
     49    @brief
     50        LevelStatus:
     51        In the LevelStatus class all necessary information off a mission in the campaign can be saved.
     52        It is only used in the LevelManager to steer the campaign menu. It is now possible to have a treelike campaign menu structure.
     53       
     54    */
     55
    5456
    5557    class _OrxonoxExport LevelStatus : public BaseObject
     
    6062       
    6163        bool won;                           //if the Level is won or not
    62         std::vector<int> nextLevels;        //in this vector at the index i is saved if the ith level should be activated =1, visible but not activated =2, or not activated =0
     64        std::vector<int> nextLevels;        //if this Level is won, the ith element of this vector shows, what to do with the other leves
    6365        int activated;                      //0 not activated, 1 activated, 2 visible
    6466    };
  • code/branches/bindermFS16/src/orxonox/gametypes/Mission.h

    r11071 r11191  
    4545
    4646            virtual void start() override;
    47             virtual void end() override;
     47            virtual void end() override;  //checks if the mission was accomplished and sends the name of the won mission to the LevelManager
    4848            virtual void setTeams();
    4949            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
Note: See TracChangeset for help on using the changeset viewer.