[Orxonox-commit 6554] r11194 - code/branches/bindermFS16/src/orxonox

binderm at orxonox.net binderm at orxonox.net
Thu May 26 14:40:16 CEST 2016


Author: binderm
Date: 2016-05-26 14:40:16 +0200 (Thu, 26 May 2016)
New Revision: 11194

Modified:
   code/branches/bindermFS16/src/orxonox/LevelManager.cc
   code/branches/bindermFS16/src/orxonox/LevelManager.h
   code/branches/bindermFS16/src/orxonox/LevelStatus.cc
   code/branches/bindermFS16/src/orxonox/LevelStatus.h
Log:
final commit

Modified: code/branches/bindermFS16/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelManager.cc	2016-05-26 12:15:53 UTC (rev 11193)
+++ code/branches/bindermFS16/src/orxonox/LevelManager.cc	2016-05-26 12:40:16 UTC (rev 11194)
@@ -23,6 +23,7 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
  *      Damian 'Mozork' Frick
+ *      Matthias Binder
  *
  */
 
@@ -90,6 +91,10 @@
         // Delete all the LevelInfoItem objects because the LevelManager created them
         for (LevelInfoItem* info : availableLevels_)
             info->destroy();
+        for(unsigned int i = 0; i<allLevelStatus_.size();++i)
+        {
+            allLevelStatus_[i]->destroy();
+        }
     }
 
     /**
@@ -105,21 +110,9 @@
             .description("The last finished mission of a campaign");
         SetConfigValue(campaignMissions_,  std::vector<std::string>())
             .description("The list of missions in the campaign");
-        //std::vector<int> v (allLevelStatus_.size(),0);
-        //SetConfigValue(allLevelWon_, v)
-        //    .description("The list of all won missions");
     }
 
-    /**
-     * @brief Stores the argument in the corresponding config value.
-     */
-/*    void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission)
-    {
-        ModifyConfigValue(lastWonMission_, set, lastFinishedCampaignMission);
-    }
-*/
 
-
     /**
     @brief
         Request activity for the input Level.
@@ -336,37 +329,56 @@
     }
 
 
-//Mission endmission true
-    //check if index level is activated...
+
+    /**
+    @brief
+        first updates allLevelStatus and then check if the level with index i is activated
+    */
     int LevelManager::missionactivate(int index)
     {
         updateAllLevelStatus();
-        int activated = allLevelStatus_[index].activated;
+        int activated = allLevelStatus_[index]->activated;
         return activated;
     }
+    /**
+    @brief
+        update the last won mission to won=true
+    */
 
     void LevelManager::updatewon(int lastwon)
     {
-        allLevelStatus_[lastwon].won=true;
+        allLevelStatus_[lastwon]->won=true;
 
     }
 
+    /**
+    @brief
+        checks if a level is won
+        if a level is won, the other levels should be shown as saved in 'nextLevels' of the won level
+        therefore 'activated' of all other levels will be updated to the correct value
+        if more than one level is won, the level with the highes index decides which other levels will be shown, activated or not activated
+    */
+
     void LevelManager::updateAllLevelStatus()
     {
         for(unsigned int i =0;i<allLevelStatus_.size();i++)
         {
-            if(allLevelStatus_[i].won)
+            if(allLevelStatus_[i]->won)
             {
-                allLevelStatus_[i].activated=1;
-                std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
+                allLevelStatus_[i]->activated=1;
+                std::vector<int> nextLevels=allLevelStatus_[i]->nextLevels;
                 for(unsigned int j=0;j<allLevelStatus_.size();j++)
                 {
-                    allLevelStatus_[j].activated=nextLevels[j];
+                    allLevelStatus_[j]->activated=nextLevels[j];
                 }
             }
         }
     }
 
+    /**
+    @brief
+        the name of the last won mission is saved in the config file
+    */
 
     void LevelManager::setLevelStatus(const std::string& LevelWon)
     {
@@ -374,61 +386,60 @@
             
         ModifyConfigValue(lastWonMission_, set, LevelWon);
 
-        std::vector<int> v (allLevelStatus_.size(),0);
-        for(unsigned int i = 0;i<allLevelStatus_.size();i++)
-        {
-            if(allLevelStatus_[i].won)
-                v[i] =1;
-        }
-
-        SetConfigValue(allLevelWon_, v)
-            .description("The list of all won missions");
-
-            for (unsigned int i = 0; i < allLevelWon_.size(); ++i)
-            {
-                ModifyConfigValue(allLevelWon_[i], set, v[i]);
-            }
-
+        /**
+        TODO: save allLevelWon_ into the config file
+        */
     }
 
 
-    //build up allLevelStatus_
-    //has to be done once per game (not per level)
-    //all connections between the levels are saved in the allLevelStatus_
-    //also the won variable of the LevelStatus is set to the corresponding allLevelWon_ value
+    /**
+    @brief
+        build up allLevelStatus_
+        has to be done once per game (not per level)
+        all connections between the levels are saved in the allLevelStatus_
+        also the won variable of the LevelStatus have to be set to the corresponding allLevelWon_ values
+    */
     void LevelManager::buildallLevelStatus()
     {
-        LevelStatus* level=new LevelStatus(this->getContext());
-        allLevelStatus_.assign (campaignMissions_.size(),*level);
-        allLevelStatus_[0].activated=1;
+        for(unsigned int i =0;i<campaignMissions_.size();++i)
+        {
+            LevelStatus* level= new LevelStatus(this->getContext());
+            allLevelStatus_.push_back(level);
+        }
 
+        /**
+        TODO: allLevelWon_ should be loaded into the allLevelSatus_ such that the progress of the campaign can be saved
+        */
 
+        allLevelStatus_[0]->activated=1;
+
+
         std::vector<int> v={1,1,1,0,0,0,0,0,0};
-        allLevelStatus_[0].nextLevels=v;
+        allLevelStatus_[0]->nextLevels=v;
 
         v={1,1,2,1,0,0,0,0,0};
-        allLevelStatus_[1].nextLevels=v;
+        allLevelStatus_[1]->nextLevels=v;
 
         v={1,2,1,0,1,0,0,0,0};
-        allLevelStatus_[2].nextLevels=v;
+        allLevelStatus_[2]->nextLevels=v;
 
         v={1,1,2,1,0,1,1,0,0};
-        allLevelStatus_[3].nextLevels=v;
+        allLevelStatus_[3]->nextLevels=v;
 
         v={1,2,1,0,1,0,0,1,1};
-        allLevelStatus_[4].nextLevels=v;
+        allLevelStatus_[4]->nextLevels=v;
 
         v={1,1,2,1,0,1,2,0,0};
-        allLevelStatus_[5].nextLevels=v;
+        allLevelStatus_[5]->nextLevels=v;
 
         v={1,1,2,1,0,2,1,0,0};
-        allLevelStatus_[6].nextLevels=v;
+        allLevelStatus_[6]->nextLevels=v;
 
         v={1,2,1,0,1,0,0,1,2};
-        allLevelStatus_[7].nextLevels=v;
+        allLevelStatus_[7]->nextLevels=v;
 
         v={1,2,1,0,1,0,0,2,1};
-        allLevelStatus_[8].nextLevels=v;
+        allLevelStatus_[8]->nextLevels=v;
 
     }
 }

Modified: code/branches/bindermFS16/src/orxonox/LevelManager.h
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelManager.h	2016-05-26 12:15:53 UTC (rev 11193)
+++ code/branches/bindermFS16/src/orxonox/LevelManager.h	2016-05-26 12:40:16 UTC (rev 11194)
@@ -81,7 +81,6 @@
             LevelManager();
             virtual ~LevelManager();
 
-            //void setLevelStatus(const int integer);
             void buildallLevelStatus();
             void updateAllLevelStatus();
             void setLevelStatus(const std::string& LevelWon);
@@ -107,7 +106,6 @@
             unsigned int getNumberOfLevels(void);
             LevelInfoItem* getAvailableLevelListItem(unsigned int index); //!< Get the LevelInfoItem at the given index in the list of available Levels.
 
-            //void setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission);
             inline const std::string& getLastWonMission() const
                 { return this->lastWonMission_; }
 
@@ -147,8 +145,8 @@
             std::string defaultLevelName_;
             std::string lastWonMission_;
             std::vector<std::string> campaignMissions_;
-            std::vector<int> allLevelWon_;
-            std::vector<LevelStatus> allLevelStatus_;
+            std::vector<int> allLevelWon_;                  //level i is won if allLevelWon_[i]=1
+            std::vector<LevelStatus*> allLevelStatus_;
 
 
 

Modified: code/branches/bindermFS16/src/orxonox/LevelStatus.cc
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelStatus.cc	2016-05-26 12:15:53 UTC (rev 11193)
+++ code/branches/bindermFS16/src/orxonox/LevelStatus.cc	2016-05-26 12:40:16 UTC (rev 11194)
@@ -1,5 +1,32 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Matthias Binder
+ *
+ */
 
 
+
+
 #include "LevelStatus.h"
 
 #include <map>
@@ -19,6 +46,11 @@
 {
     RegisterClass(LevelStatus);
 
+
+    /**
+    @brief
+        Constructor. sets config values and initializes variables.
+    */
     LevelStatus::LevelStatus(Context* context) : BaseObject(context)
     {
         RegisterObject(LevelStatus);
@@ -29,6 +61,4 @@
 
     LevelStatus::~LevelStatus()
     {}
-
-
 }

Modified: code/branches/bindermFS16/src/orxonox/LevelStatus.h
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelStatus.h	2016-05-26 12:15:53 UTC (rev 11193)
+++ code/branches/bindermFS16/src/orxonox/LevelStatus.h	2016-05-26 12:40:16 UTC (rev 11194)
@@ -48,8 +48,8 @@
     /**
     @brief
         LevelStatus:
-        In the LevelStatus class all necessary information off a mission in the campaign can be saved.
-        It is only used in the LevelManager to steer the campaign menu. It is now possible to have a treelike campaign menu structure.
+        In the LevelStatus class all necessary information of a mission in the campaign is saved.
+        It is only used in the LevelManager to save the progress of the campaign. It is now possible to have a treelike campaign menu structure.
         
     */
 




More information about the Orxonox-commit mailing list