[Orxonox-commit 6545] r11186 - in code/branches/bindermFS16: data/gui/layouts data/gui/scripts src/orxonox src/orxonox/gametypes

binderm at orxonox.net binderm at orxonox.net
Thu May 12 16:07:25 CEST 2016


Author: binderm
Date: 2016-05-12 16:07:25 +0200 (Thu, 12 May 2016)
New Revision: 11186

Added:
   code/branches/bindermFS16/src/orxonox/LevelStatus.cc
   code/branches/bindermFS16/src/orxonox/LevelStatus.h
Modified:
   code/branches/bindermFS16/data/gui/layouts/CampaignMenu.layout
   code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua
   code/branches/bindermFS16/src/orxonox/CMakeLists.txt
   code/branches/bindermFS16/src/orxonox/LevelManager.cc
   code/branches/bindermFS16/src/orxonox/LevelManager.h
   code/branches/bindermFS16/src/orxonox/gametypes/Mission.cc
Log:
LevelStatus and levelmanager in two files, LevelStatus saves and changes the actual campaign progress 


Modified: code/branches/bindermFS16/data/gui/layouts/CampaignMenu.layout
===================================================================
--- code/branches/bindermFS16/data/gui/layouts/CampaignMenu.layout	2016-05-12 14:03:47 UTC (rev 11185)
+++ code/branches/bindermFS16/data/gui/layouts/CampaignMenu.layout	2016-05-12 14:07:25 UTC (rev 11186)
@@ -12,7 +12,7 @@
             <Property Name="Text" Value="Mission One" />
             <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.01,0},{0.3,0},{0.06,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.34,0},{0.3,0},{0.39,0}}" />
             <Event Name="Clicked" Function="CampaignMenu.Mission1Button_clicked"/>
         </Window>
 
@@ -20,8 +20,8 @@
             <Property Name="Text" Value="Fight in our Back" />
             <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.18,0},{0.65,0},{0.23,0}}" />
-            <Property Name="Disabled" Value="True" />
+            <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.26,0},{0.4,0},{0.31,0}}" />
+            <Property Name="Disabled" Value="True"/>
             <Event Name="Clicked" Function="CampaignMenu.Mission2Button_clicked"/>
         </Window>
 
@@ -29,7 +29,7 @@
             <Property Name="Text" Value="Pirate Attack" />
             <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.26,0},{0.65,0},{0.31,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.42,0},{0.4,0},{0.47,0}}" />
             <Property Name="Disabled" Value="True" />
             <Event Name="Clicked" Function="CampaignMenu.Mission3Button_clicked"/>
         </Window>
@@ -38,7 +38,7 @@
             <Property Name="Text" Value="Trip to Area 51" />
             <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.34,0},{0.65,0},{0.39,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.41,0},{0.26,0},{0.71,0},{0.31,0}}" />
             <Property Name="Disabled" Value="True" />
             <Event Name="Clicked" Function="CampaignMenu.Mission4Button_clicked"/>
         </Window>
@@ -47,7 +47,7 @@
             <Property Name="Text" Value="Area 51 under Fire" />
             <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.42,0},{0.65,0},{0.47,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.41,0},{0.42,0},{0.71,0},{0.47,0}}" />
             <Property Name="Disabled" Value="True" />
             <Event Name="Clicked" Function="CampaignMenu.Mission5Button_clicked"/>
         </Window>
@@ -56,7 +56,7 @@
             <Property Name="Text" Value="Escape the Bastards" />
             <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.50,0},{0.65,0},{0.55,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.72,0},{0.10,0},{0.99,0},{0.15,0}}" />
             <Property Name="Disabled" Value="True" />
             <Event Name="Clicked" Function="CampaignMenu.Mission6Button_clicked"/>
         </Window>
@@ -65,7 +65,7 @@
             <Property Name="Text" Value="Expedition to Sector 5C" />
             <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.58,0},{0.65,0},{0.63,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.72,0},{0.18,0},{0.99,0},{0.23,0}}" />
             <Property Name="Disabled" Value="True" />
             <Event Name="Clicked" Function="CampaignMenu.Mission7Button_clicked"/>
         </Window>
@@ -74,7 +74,7 @@
             <Property Name="Text" Value="Shuttle under Attack" />
             <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.66,0},{0.65,0},{0.71,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.72,0},{0.50,0},{0.99,0},{0.55,0}}" />
             <Property Name="Disabled" Value="True" />
             <Event Name="Clicked" Function="CampaignMenu.Mission8Button_clicked"/>
         </Window>
@@ -83,7 +83,7 @@
             <Property Name="Text" Value="Retaliation" />
             <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.35,0},{0.74,0},{0.65,0},{0.79,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.72,0},{0.58,0},{0.99,0},{0.63,0}}" />
             <Property Name="Disabled" Value="True" />
             <Event Name="Clicked" Function="CampaignMenu.Mission9Button_clicked"/>
         </Window>

Modified: code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua
===================================================================
--- code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua	2016-05-12 14:03:47 UTC (rev 11185)
+++ code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua	2016-05-12 14:07:25 UTC (rev 11186)
@@ -25,7 +25,15 @@
 end
 
 function P.updateButton(index, button)
+    local lastMission = orxonox.LevelManager:getInstance():getLastWonMission()
+    if (lastMission == "") then
+    else
+        local lastwon =P.getIndexOfLastFinishedMission()
+        orxonox.LevelManager:getInstance():updatewon(lastwon)
+    end
+
     local test =orxonox.LevelManager:getInstance():missionactivate(index)
+
     if (test==1) then
         button:setProperty("Visible", "True")
         button:setProperty("Disabled", "False")
@@ -47,21 +55,21 @@
 --    return index <= P.getIndexOfLastFinishedMission() + 1
 --end
 
---function P.getIndexOfLastFinishedMission()
---    local lastMission = orxonox.LevelManager:getInstance():getLastFinishedCampaignMission()
---    if (lastMission and lastMission ~= "") then
---        local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
---        local index = 0
---        while index < size do
---            local mission = orxonox.LevelManager:getInstance():getCampaignMission(index)
---            if (mission == lastMission) then 
---                return index
---            end
---            index = index + 1
---        end
---    end
---    return -1
---end
+function P.getIndexOfLastFinishedMission()
+    local lastMission = orxonox.LevelManager:getInstance():getLastWonMission()
+    if (lastMission and lastMission ~= "") then
+        local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
+        local index = 0
+        while index < size do
+            local mission = orxonox.LevelManager:getInstance():getCampaignMission(index)
+            if (mission == lastMission) then 
+                return index
+            end
+            index = index + 1
+        end
+    end
+    return -1
+end
 
 function P.Mission1Button_clicked(e)
     P.loadLevel(P.FindLevel(0))

Modified: code/branches/bindermFS16/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/bindermFS16/src/orxonox/CMakeLists.txt	2016-05-12 14:03:47 UTC (rev 11185)
+++ code/branches/bindermFS16/src/orxonox/CMakeLists.txt	2016-05-12 14:07:25 UTC (rev 11186)
@@ -25,6 +25,7 @@
 SET_SOURCE_FILES(ORXONOX_SRC_FILES
   Level.cc
   LevelInfo.cc
+  LevelStatus.cc
   LevelManager.cc
   Main.cc
   MoodManager.cc
@@ -60,6 +61,7 @@
     overlays/CampaignMenu.h
     LevelInfo.h
     LevelManager.h
+    LevelStatus.h
     MoodManager.h
     controllers/HumanController.h
     infos/PlayerInfo.h

Modified: code/branches/bindermFS16/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelManager.cc	2016-05-12 14:03:47 UTC (rev 11185)
+++ code/branches/bindermFS16/src/orxonox/LevelManager.cc	2016-05-12 14:07:25 UTC (rev 11186)
@@ -46,68 +46,85 @@
 #include "Level.h"
 #include "PlayerManager.h"
 
+
 namespace orxonox
 {
 
-    LevelStatus::LevelStatus()
+//Mission endmission true
+    //check if index level is activated...
+    int LevelManager::missionactivate(int index)
     {
-        this->won = false;
-        this->nextLevels.insert(this->nextLevels.begin(),1);
+        updateAllLevelStatus();
+        int activated = allLevelStatus_[index].activated;
+        return activated;
     }
 
-    LevelStatus::~LevelStatus()
-    {}
+    void LevelManager::updatewon(int lastwon)
+    {
+        allLevelStatus_[lastwon].won=true;
 
+    }
 
-    //check if index level is activated...
-    int LevelManager::missionactivate(int index)
+    void LevelManager::updateAllLevelStatus()
     {
-
-        if (allLevelStatus_[index].won)
-            return 1;
-
-        //check if level is activated
-        for(unsigned int i=0;i<allLevelStatus_.size();i++)
+        for(unsigned int i =0;i<allLevelStatus_.size();i++)
         {
-            std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
-            bool won=allLevelStatus_[i].won;
-            if(nextLevels[index]==1&&won)
-                return 1;
-        };
-
-        //check if level visible but not activated
-        for(unsigned int i=0;i<allLevelStatus_.size();i++)
-        {
-            std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
-            bool won=allLevelStatus_[i].won;
-            if(nextLevels[index]==2&&won)
-                return 2;
-        };
-        return 0;
+            if(allLevelStatus_[i].won)
+            {
+                allLevelStatus_[i].activated=1;
+                std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
+                for(unsigned int j=i+1;j<allLevelStatus_.size();j++)
+                {
+                    allLevelStatus_[j].activated=nextLevels[j];
+                }
+            }
+        }
     }
 
     //updates the won variable of the corresponding LevelStatus in allLevelStatus_
-    void LevelManager::setLevelStatus(const int completedLevel)
+    void LevelManager::setLevelStatus(const std::string& LevelWon)
     {
-        allLevelStatus_[completedLevel].won=true;   
+        ModifyConfigValue(lastWonMission_, set, LevelWon);  
     }
 
+
     //build up allLevelStatus
     //has to be done once per game (not per level)
     //all connections between the levels are saved in here
     void LevelManager::buildallLevelStatus()
     {
         LevelStatus level;
-        allLevelStatus_.assign (10,level);
-        allLevelStatus_[0].won=true;
+        allLevelStatus_.assign (campaignMissions_.size(),level);
+        allLevelStatus_[0].activated=1;
+        //allLevelStatus_[0].won=true;
 
-        
+
+        allLevelStatus_[0].nextLevels.push_back(1);
+        allLevelStatus_[0].nextLevels.push_back(1);
+        allLevelStatus_[0].nextLevels.push_back(0);
+        allLevelStatus_[0].nextLevels.push_back(0);
+        allLevelStatus_[0].nextLevels.push_back(0);
+        allLevelStatus_[0].nextLevels.push_back(0);
+        allLevelStatus_[0].nextLevels.push_back(0);
+
+        allLevelStatus_[1].nextLevels.push_back(1);
         allLevelStatus_[1].nextLevels.push_back(2);
-        allLevelStatus_[1].nextLevels.push_back(2);
         allLevelStatus_[1].nextLevels.push_back(1);
-        allLevelStatus_[1].nextLevels.push_back(2);
+        allLevelStatus_[1].nextLevels.push_back(0);
+        allLevelStatus_[1].nextLevels.push_back(0);
+        allLevelStatus_[1].nextLevels.push_back(0);
+        allLevelStatus_[1].nextLevels.push_back(0);
 
+        allLevelStatus_[2].nextLevels.push_back(2);
+        allLevelStatus_[2].nextLevels.push_back(1);
+        allLevelStatus_[2].nextLevels.push_back(0);
+        allLevelStatus_[2].nextLevels.push_back(0);
+        allLevelStatus_[2].nextLevels.push_back(1);
+        allLevelStatus_[2].nextLevels.push_back(0);
+        allLevelStatus_[2].nextLevels.push_back(0);
 
+
+
     }
 
 
@@ -158,22 +175,25 @@
     {
         SetConfigValue(defaultLevelName_, "missionOne.oxw")
             .description("Sets the pre selection of the level in the main menu.");
-        SetConfigValue(lastFinishedCampaignMission_,  "")
+        SetConfigValue(lastWonMission_,  "")
             .description("The last finished mission of a campaign");
         SetConfigValue(campaignMissions_,  std::vector<std::string>())
             .description("The list of missions in the campaign");
+        SetConfigValue(test_,  std::vector<int>())
+            .description("The list of missions and their statuses");
+            
     }
 
     /**
      * @brief Stores the argument in the corresponding config value.
      */
-    void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission)
+/*    void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission)
     {
-        ModifyConfigValue(lastFinishedCampaignMission_, set, lastFinishedCampaignMission);
+        ModifyConfigValue(lastWonMission_, set, lastFinishedCampaignMission);
     }
+*/
 
 
-
     /**
     @brief
         Request activity for the input Level.

Modified: code/branches/bindermFS16/src/orxonox/LevelManager.h
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelManager.h	2016-05-12 14:03:47 UTC (rev 11185)
+++ code/branches/bindermFS16/src/orxonox/LevelManager.h	2016-05-12 14:07:25 UTC (rev 11186)
@@ -46,23 +46,9 @@
 
 #include "util/Singleton.h"
 #include "core/config/Configurable.h"
+#include "LevelStatus.h"
 
 
-namespace orxonox
-{
-
-    class LevelStatus
-    {
-    public:
-        LevelStatus();
-        virtual ~LevelStatus();
-        
-        bool won;
-        std::vector<int> nextLevels;
-
-    };
-}
-
 // tolua_begin
 namespace orxonox
 {
@@ -94,8 +80,10 @@
             LevelManager();
             virtual ~LevelManager();
 
-            void setLevelStatus(const int integer);
+            //void setLevelStatus(const int integer);
             void buildallLevelStatus();
+            void updateAllLevelStatus();
+            void setLevelStatus(const std::string& LevelWon);
 
 
             void setConfigValues(); //!< Set the config values for this object.
@@ -106,6 +94,7 @@
             Level* getActiveLevel(); //!< Get the currently active Level.
 
             // tolua_begin
+            void updatewon(int lastwon);
             int missionactivate(int index);
             void setDefaultLevel(const std::string& levelName); //!< Set the default Level.
             /**
@@ -117,9 +106,9 @@
             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& getLastFinishedCampaignMission() const
-                { return this->lastFinishedCampaignMission_; }
+            //void setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission);
+            inline const std::string& getLastWonMission() const
+                { return this->lastWonMission_; }
 
             inline unsigned int getNumberOfCampaignMissions()
                 { return this->campaignMissions_.size(); }
@@ -155,9 +144,9 @@
 
             // config values
             std::string defaultLevelName_;
-            std::string lastFinishedCampaignMission_;
+            std::string lastWonMission_;
             std::vector<std::string> campaignMissions_;
-
+            std::vector<int> test_;
             std::vector<LevelStatus> allLevelStatus_;
 
 

Added: code/branches/bindermFS16/src/orxonox/LevelStatus.cc
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelStatus.cc	                        (rev 0)
+++ code/branches/bindermFS16/src/orxonox/LevelStatus.cc	2016-05-12 14:07:25 UTC (rev 11186)
@@ -0,0 +1,34 @@
+
+
+#include "LevelStatus.h"
+
+#include <map>
+
+#include "core/singleton/ScopedSingletonIncludes.h"
+#include "core/commandline/CommandLineIncludes.h"
+#include "core/config/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/ClassTreeMask.h"
+#include "core/Loader.h"
+#include "core/Resource.h"
+#include "core/XMLFile.h"
+#include "Level.h"
+#include "PlayerManager.h"
+
+namespace orxonox
+{
+    RegisterClass(LevelStatus);
+
+    LevelStatus::LevelStatus()
+    {
+        RegisterObject(LevelStatus);
+        this->won = false;
+        this->nextLevels.insert(this->nextLevels.begin(),1);
+        this->activated=0;
+    }
+
+    LevelStatus::~LevelStatus()
+    {}
+
+
+}

Added: code/branches/bindermFS16/src/orxonox/LevelStatus.h
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelStatus.h	                        (rev 0)
+++ code/branches/bindermFS16/src/orxonox/LevelStatus.h	2016-05-12 14:07:25 UTC (rev 11186)
@@ -0,0 +1,68 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Damian 'Mozork' Frick
+ *
+ */
+
+/**
+    @file LevelManager.h
+    @brief Definition of the LevelManager singleton.
+    @ingroup Orxonox
+*/
+#ifndef _LevelStatus_H__
+#define _LevelStatus_H__
+
+
+#include "OrxonoxPrereqs.h"
+
+#include <cassert>
+#include <list>
+#include <map>
+#include <string>
+
+#include "LevelInfo.h"
+
+#include "util/Singleton.h"
+#include "core/config/Configurable.h"
+
+
+namespace orxonox
+{
+
+
+    class _OrxonoxExport LevelStatus : public BaseObject
+    {
+    public:
+        LevelStatus();
+        virtual ~LevelStatus();
+        
+        bool won;                           //if the Level is won or not
+        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
+        int activated;                      //0 not activated, 1 activated, 2 visible
+
+    };
+}
+
+#endif /* _LevelStatus_H__ */

Modified: code/branches/bindermFS16/src/orxonox/gametypes/Mission.cc
===================================================================
--- code/branches/bindermFS16/src/orxonox/gametypes/Mission.cc	2016-05-12 14:03:47 UTC (rev 11185)
+++ code/branches/bindermFS16/src/orxonox/gametypes/Mission.cc	2016-05-12 14:07:25 UTC (rev 11186)
@@ -90,10 +90,10 @@
         {
             this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
 
-            LevelManager::getInstance().setLastFinishedCampaignMission(this->getFilename());
+            //LevelManager::getInstance().setLastFinishedCampaignMission(this->getFilename());
 
             //gibt index von bestandenem level weiter
-            LevelManager::getInstance().setLevelStatus(7);
+            LevelManager::getInstance().setLevelStatus(this->getFilename());
         }
         else if (!this->gtinfo_->hasEnded())
             this->gtinfo_->sendAnnounceMessage("Mission failed!");




More information about the Orxonox-commit mailing list