Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11186


Ignore:
Timestamp:
May 12, 2016, 4:07:25 PM (4 years ago)
Author:
binderm
Message:

LevelStatus and levelmanager in two files, LevelStatus saves and changes the actual campaign progress

Location:
code/branches/bindermFS16
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/bindermFS16/data/gui/layouts/CampaignMenu.layout

    r11180 r11186  
    1313            <Property Name="Visible" Value="False"/>
    1414            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    15             <Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.01,0},{0.3,0},{0.06,0}}" />
     15            <Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.34,0},{0.3,0},{0.39,0}}" />
    1616            <Event Name="Clicked" Function="CampaignMenu.Mission1Button_clicked"/>
    1717        </Window>
     
    2121            <Property Name="Visible" Value="False"/>
    2222            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    23             <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.18,0},{0.65,0},{0.23,0}}" />
    24             <Property Name="Disabled" Value="True" />
     23            <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.26,0},{0.4,0},{0.31,0}}" />
     24            <Property Name="Disabled" Value="True"/>
    2525            <Event Name="Clicked" Function="CampaignMenu.Mission2Button_clicked"/>
    2626        </Window>
     
    3030            <Property Name="Visible" Value="False"/>
    3131            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    32             <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.26,0},{0.65,0},{0.31,0}}" />
     32            <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.42,0},{0.4,0},{0.47,0}}" />
    3333            <Property Name="Disabled" Value="True" />
    3434            <Event Name="Clicked" Function="CampaignMenu.Mission3Button_clicked"/>
     
    3939            <Property Name="Visible" Value="False"/>
    4040            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    41             <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.34,0},{0.65,0},{0.39,0}}" />
     41            <Property Name="UnifiedAreaRect" Value="{{0.41,0},{0.26,0},{0.71,0},{0.31,0}}" />
    4242            <Property Name="Disabled" Value="True" />
    4343            <Event Name="Clicked" Function="CampaignMenu.Mission4Button_clicked"/>
     
    4848            <Property Name="Visible" Value="False"/>
    4949            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    50             <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.42,0},{0.65,0},{0.47,0}}" />
     50            <Property Name="UnifiedAreaRect" Value="{{0.41,0},{0.42,0},{0.71,0},{0.47,0}}" />
    5151            <Property Name="Disabled" Value="True" />
    5252            <Event Name="Clicked" Function="CampaignMenu.Mission5Button_clicked"/>
     
    5757            <Property Name="Visible" Value="False"/>
    5858            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    59             <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.50,0},{0.65,0},{0.55,0}}" />
     59            <Property Name="UnifiedAreaRect" Value="{{0.72,0},{0.10,0},{0.99,0},{0.15,0}}" />
    6060            <Property Name="Disabled" Value="True" />
    6161            <Event Name="Clicked" Function="CampaignMenu.Mission6Button_clicked"/>
     
    6666            <Property Name="Visible" Value="False"/>
    6767            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    68             <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.58,0},{0.65,0},{0.63,0}}" />
     68            <Property Name="UnifiedAreaRect" Value="{{0.72,0},{0.18,0},{0.99,0},{0.23,0}}" />
    6969            <Property Name="Disabled" Value="True" />
    7070            <Event Name="Clicked" Function="CampaignMenu.Mission7Button_clicked"/>
     
    7575            <Property Name="Visible" Value="False"/>
    7676            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    77             <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.66,0},{0.65,0},{0.71,0}}" />
     77            <Property Name="UnifiedAreaRect" Value="{{0.72,0},{0.50,0},{0.99,0},{0.55,0}}" />
    7878            <Property Name="Disabled" Value="True" />
    7979            <Event Name="Clicked" Function="CampaignMenu.Mission8Button_clicked"/>
     
    8484            <Property Name="Visible" Value="False"/>
    8585            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    86             <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.74,0},{0.65,0},{0.79,0}}" />
     86            <Property Name="UnifiedAreaRect" Value="{{0.72,0},{0.58,0},{0.99,0},{0.63,0}}" />
    8787            <Property Name="Disabled" Value="True" />
    8888            <Event Name="Clicked" Function="CampaignMenu.Mission9Button_clicked"/>
  • code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua

    r11180 r11186  
    2626
    2727function P.updateButton(index, button)
     28    local lastMission = orxonox.LevelManager:getInstance():getLastWonMission()
     29    if (lastMission == "") then
     30    else
     31        local lastwon =P.getIndexOfLastFinishedMission()
     32        orxonox.LevelManager:getInstance():updatewon(lastwon)
     33    end
     34
    2835    local test =orxonox.LevelManager:getInstance():missionactivate(index)
     36
    2937    if (test==1) then
    3038        button:setProperty("Visible", "True")
     
    4856--end
    4957
    50 --function P.getIndexOfLastFinishedMission()
    51 --    local lastMission = orxonox.LevelManager:getInstance():getLastFinishedCampaignMission()
    52 --    if (lastMission and lastMission ~= "") then
    53 --        local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
    54 --        local index = 0
    55 --        while index < size do
    56 --            local mission = orxonox.LevelManager:getInstance():getCampaignMission(index)
    57 --            if (mission == lastMission) then
    58 --                return index
    59 --            end
    60 --            index = index + 1
    61 --        end
    62 --    end
    63 --    return -1
    64 --end
     58function P.getIndexOfLastFinishedMission()
     59    local lastMission = orxonox.LevelManager:getInstance():getLastWonMission()
     60    if (lastMission and lastMission ~= "") then
     61        local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
     62        local index = 0
     63        while index < size do
     64            local mission = orxonox.LevelManager:getInstance():getCampaignMission(index)
     65            if (mission == lastMission) then
     66                return index
     67            end
     68            index = index + 1
     69        end
     70    end
     71    return -1
     72end
    6573
    6674function P.Mission1Button_clicked(e)
  • code/branches/bindermFS16/src/orxonox/CMakeLists.txt

    r11173 r11186  
    2626  Level.cc
    2727  LevelInfo.cc
     28  LevelStatus.cc
    2829  LevelManager.cc
    2930  Main.cc
     
    6162    LevelInfo.h
    6263    LevelManager.h
     64    LevelStatus.h
    6365    MoodManager.h
    6466    controllers/HumanController.h
  • code/branches/bindermFS16/src/orxonox/LevelManager.cc

    r11181 r11186  
    4747#include "PlayerManager.h"
    4848
     49
    4950namespace orxonox
    5051{
    5152
    52     LevelStatus::LevelStatus()
    53     {
    54         this->won = false;
    55         this->nextLevels.insert(this->nextLevels.begin(),1);
    56     }
    57 
    58     LevelStatus::~LevelStatus()
    59     {}
    60 
    61 
     53//Mission endmission true
    6254    //check if index level is activated...
    6355    int LevelManager::missionactivate(int index)
    6456    {
    65 
    66         if (allLevelStatus_[index].won)
    67             return 1;
    68 
    69         //check if level is activated
    70         for(unsigned int i=0;i<allLevelStatus_.size();i++)
    71         {
    72             std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
    73             bool won=allLevelStatus_[i].won;
    74             if(nextLevels[index]==1&&won)
    75                 return 1;
    76         };
    77 
    78         //check if level visible but not activated
    79         for(unsigned int i=0;i<allLevelStatus_.size();i++)
    80         {
    81             std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
    82             bool won=allLevelStatus_[i].won;
    83             if(nextLevels[index]==2&&won)
    84                 return 2;
    85         };
    86         return 0;
     57        updateAllLevelStatus();
     58        int activated = allLevelStatus_[index].activated;
     59        return activated;
     60    }
     61
     62    void LevelManager::updatewon(int lastwon)
     63    {
     64        allLevelStatus_[lastwon].won=true;
     65
     66    }
     67
     68    void LevelManager::updateAllLevelStatus()
     69    {
     70        for(unsigned int i =0;i<allLevelStatus_.size();i++)
     71        {
     72            if(allLevelStatus_[i].won)
     73            {
     74                allLevelStatus_[i].activated=1;
     75                std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
     76                for(unsigned int j=i+1;j<allLevelStatus_.size();j++)
     77                {
     78                    allLevelStatus_[j].activated=nextLevels[j];
     79                }
     80            }
     81        }
    8782    }
    8883
    8984    //updates the won variable of the corresponding LevelStatus in allLevelStatus_
    90     void LevelManager::setLevelStatus(const int completedLevel)
    91     {
    92         allLevelStatus_[completedLevel].won=true;   
    93     }
     85    void LevelManager::setLevelStatus(const std::string& LevelWon)
     86    {
     87        ModifyConfigValue(lastWonMission_, set, LevelWon); 
     88    }
     89
    9490
    9591    //build up allLevelStatus
     
    9995    {
    10096        LevelStatus level;
    101         allLevelStatus_.assign (10,level);
    102         allLevelStatus_[0].won=true;
    103 
    104        
    105         allLevelStatus_[1].nextLevels.push_back(2);
     97        allLevelStatus_.assign (campaignMissions_.size(),level);
     98        allLevelStatus_[0].activated=1;
     99        //allLevelStatus_[0].won=true;
     100
     101
     102        allLevelStatus_[0].nextLevels.push_back(1);
     103        allLevelStatus_[0].nextLevels.push_back(1);
     104        allLevelStatus_[0].nextLevels.push_back(0);
     105        allLevelStatus_[0].nextLevels.push_back(0);
     106        allLevelStatus_[0].nextLevels.push_back(0);
     107        allLevelStatus_[0].nextLevels.push_back(0);
     108        allLevelStatus_[0].nextLevels.push_back(0);
     109
     110        allLevelStatus_[1].nextLevels.push_back(1);
    106111        allLevelStatus_[1].nextLevels.push_back(2);
    107112        allLevelStatus_[1].nextLevels.push_back(1);
    108         allLevelStatus_[1].nextLevels.push_back(2);
     113        allLevelStatus_[1].nextLevels.push_back(0);
     114        allLevelStatus_[1].nextLevels.push_back(0);
     115        allLevelStatus_[1].nextLevels.push_back(0);
     116        allLevelStatus_[1].nextLevels.push_back(0);
     117
     118        allLevelStatus_[2].nextLevels.push_back(2);
     119        allLevelStatus_[2].nextLevels.push_back(1);
     120        allLevelStatus_[2].nextLevels.push_back(0);
     121        allLevelStatus_[2].nextLevels.push_back(0);
     122        allLevelStatus_[2].nextLevels.push_back(1);
     123        allLevelStatus_[2].nextLevels.push_back(0);
     124        allLevelStatus_[2].nextLevels.push_back(0);
     125
    109126
    110127
     
    159176        SetConfigValue(defaultLevelName_, "missionOne.oxw")
    160177            .description("Sets the pre selection of the level in the main menu.");
    161         SetConfigValue(lastFinishedCampaignMission_,  "")
     178        SetConfigValue(lastWonMission_,  "")
    162179            .description("The last finished mission of a campaign");
    163180        SetConfigValue(campaignMissions_,  std::vector<std::string>())
    164181            .description("The list of missions in the campaign");
     182        SetConfigValue(test_,  std::vector<int>())
     183            .description("The list of missions and their statuses");
     184           
    165185    }
    166186
     
    168188     * @brief Stores the argument in the corresponding config value.
    169189     */
    170     void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission)
    171     {
    172         ModifyConfigValue(lastFinishedCampaignMission_, set, lastFinishedCampaignMission);
    173     }
    174 
     190/*    void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission)
     191    {
     192        ModifyConfigValue(lastWonMission_, set, lastFinishedCampaignMission);
     193    }
     194*/
    175195
    176196
  • code/branches/bindermFS16/src/orxonox/LevelManager.h

    r11180 r11186  
    4747#include "util/Singleton.h"
    4848#include "core/config/Configurable.h"
     49#include "LevelStatus.h"
    4950
    50 
    51 namespace orxonox
    52 {
    53 
    54     class LevelStatus
    55     {
    56     public:
    57         LevelStatus();
    58         virtual ~LevelStatus();
    59        
    60         bool won;
    61         std::vector<int> nextLevels;
    62 
    63     };
    64 }
    6551
    6652// tolua_begin
     
    9581            virtual ~LevelManager();
    9682
    97             void setLevelStatus(const int integer);
     83            //void setLevelStatus(const int integer);
    9884            void buildallLevelStatus();
     85            void updateAllLevelStatus();
     86            void setLevelStatus(const std::string& LevelWon);
    9987
    10088
     
    10795
    10896            // tolua_begin
     97            void updatewon(int lastwon);
    10998            int missionactivate(int index);
    11099            void setDefaultLevel(const std::string& levelName); //!< Set the default Level.
     
    118107            LevelInfoItem* getAvailableLevelListItem(unsigned int index); //!< Get the LevelInfoItem at the given index in the list of available Levels.
    119108
    120             void setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission);
    121             inline const std::string& getLastFinishedCampaignMission() const
    122                 { return this->lastFinishedCampaignMission_; }
     109            //void setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission);
     110            inline const std::string& getLastWonMission() const
     111                { return this->lastWonMission_; }
    123112
    124113            inline unsigned int getNumberOfCampaignMissions()
     
    156145            // config values
    157146            std::string defaultLevelName_;
    158             std::string lastFinishedCampaignMission_;
     147            std::string lastWonMission_;
    159148            std::vector<std::string> campaignMissions_;
    160 
     149            std::vector<int> test_;
    161150            std::vector<LevelStatus> allLevelStatus_;
    162151
  • code/branches/bindermFS16/src/orxonox/gametypes/Mission.cc

    r11180 r11186  
    9191            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
    9292
    93             LevelManager::getInstance().setLastFinishedCampaignMission(this->getFilename());
     93            //LevelManager::getInstance().setLastFinishedCampaignMission(this->getFilename());
    9494
    9595            //gibt index von bestandenem level weiter
    96             LevelManager::getInstance().setLevelStatus(7);
     96            LevelManager::getInstance().setLevelStatus(this->getFilename());
    9797        }
    9898        else if (!this->gtinfo_->hasEnded())
Note: See TracChangeset for help on using the changeset viewer.