[Orxonox-commit 6550] r11191 - in code/branches/bindermFS16: data/gui/scripts src/orxonox src/orxonox/gametypes
binderm at orxonox.net
binderm at orxonox.net
Thu May 19 17:37:06 CEST 2016
Author: binderm
Date: 2016-05-19 17:37:05 +0200 (Thu, 19 May 2016)
New Revision: 11191
Modified:
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/LevelStatus.h
code/branches/bindermFS16/src/orxonox/gametypes/Mission.h
Log:
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.
Modified: code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua
===================================================================
--- code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua 2016-05-19 15:34:38 UTC (rev 11190)
+++ code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua 2016-05-19 15:37:05 UTC (rev 11191)
@@ -16,14 +16,9 @@
P.updateButton(6, winMgr:getWindow("orxonox/Mission7Button"))
P.updateButton(7, winMgr:getWindow("orxonox/Mission8Button"))
P.updateButton(8, winMgr:getWindow("orxonox/Mission9Button"))
-
-
--- if (P.getIndexOfLastFinishedMission() == orxonox.LevelManager:getInstance():getNumberOfCampaignMissions() - 1) then
--- local label = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
--- label:setProperty("Visible","True")
--- end
end
+
function P.updateButton(index, button)
local lastMission = orxonox.LevelManager:getInstance():getLastWonMission()
if (lastMission == "") then
@@ -46,15 +41,6 @@
end
end
---function P.shouldDisplayButton(index)
--- local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
--- return index < size
---end
-
---function P.shouldActivateButton(index) --checks if button should be activated or not
--- return index <= P.getIndexOfLastFinishedMission() + 1
---end
-
function P.getIndexOfLastFinishedMission()
local lastMission = orxonox.LevelManager:getInstance():getLastWonMission()
if (lastMission and lastMission ~= "") then
Modified: code/branches/bindermFS16/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/bindermFS16/src/orxonox/CMakeLists.txt 2016-05-19 15:34:38 UTC (rev 11190)
+++ code/branches/bindermFS16/src/orxonox/CMakeLists.txt 2016-05-19 15:37:05 UTC (rev 11191)
@@ -61,7 +61,6 @@
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-19 15:34:38 UTC (rev 11190)
+++ code/branches/bindermFS16/src/orxonox/LevelManager.cc 2016-05-19 15:37:05 UTC (rev 11191)
@@ -98,15 +98,16 @@
*/
void LevelManager::setConfigValues()
{
+
SetConfigValue(defaultLevelName_, "missionOne.oxw")
.description("Sets the pre selection of the level in the main menu.");
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");
-
+ //std::vector<int> v (allLevelStatus_.size(),0);
+ //SetConfigValue(allLevelWon_, v)
+ // .description("The list of all won missions");
}
/**
@@ -184,6 +185,7 @@
*/
void LevelManager::activateNextLevel()
{
+
if (this->levels_.size() > 0)
{
// Activate the level that is the first in the list of levels whose activity has been requested.
@@ -357,7 +359,7 @@
{
allLevelStatus_[i].activated=1;
std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
- for(unsigned int j=i+1;j<allLevelStatus_.size();j++)
+ for(unsigned int j=0;j<allLevelStatus_.size();j++)
{
allLevelStatus_[j].activated=nextLevels[j];
}
@@ -365,51 +367,68 @@
}
}
- //updates the won variable of the corresponding LevelStatus in allLevelStatus_
+
void LevelManager::setLevelStatus(const std::string& LevelWon)
{
- ModifyConfigValue(lastWonMission_, set, LevelWon);
+
+
+ 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]);
+ }
+
}
- //build up allLevelStatus
+ //build up allLevelStatus_
//has to be done once per game (not per level)
- //all connections between the levels are saved in here
+ //all connections between the levels are saved in the allLevelStatus_
+ //also the won variable of the LevelStatus is set to the corresponding allLevelWon_ value
void LevelManager::buildallLevelStatus()
{
- LevelStatus* level = new LevelStatus(this->getContext());
-
- /*LevelStatus level;
- allLevelStatus_.assign (campaignMissions_.size(),level);
+ LevelStatus* level=new LevelStatus(this->getContext());
+ 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);
+ std::vector<int> v={1,1,1,0,0,0,0,0,0};
+ allLevelStatus_[0].nextLevels=v;
- allLevelStatus_[1].nextLevels.push_back(1);
- allLevelStatus_[1].nextLevels.push_back(2);
- allLevelStatus_[1].nextLevels.push_back(1);
- allLevelStatus_[1].nextLevels.push_back(0);
- allLevelStatus_[1].nextLevels.push_back(0);
- allLevelStatus_[1].nextLevels.push_back(0);
- allLevelStatus_[1].nextLevels.push_back(0);
+ v={1,1,2,1,0,0,0,0,0};
+ allLevelStatus_[1].nextLevels=v;
- 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);*/
+ v={1,2,1,0,1,0,0,0,0};
+ allLevelStatus_[2].nextLevels=v;
+ v={1,1,2,1,0,1,1,0,0};
+ allLevelStatus_[3].nextLevels=v;
+ v={1,2,1,0,1,0,0,1,1};
+ allLevelStatus_[4].nextLevels=v;
+ v={1,1,2,1,0,1,2,0,0};
+ allLevelStatus_[5].nextLevels=v;
+
+ v={1,1,2,1,0,2,1,0,0};
+ allLevelStatus_[6].nextLevels=v;
+
+ v={1,2,1,0,1,0,0,1,2};
+ allLevelStatus_[7].nextLevels=v;
+
+ v={1,2,1,0,1,0,0,2,1};
+ allLevelStatus_[8].nextLevels=v;
+
}
}
Modified: code/branches/bindermFS16/src/orxonox/LevelManager.h
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelManager.h 2016-05-19 15:34:38 UTC (rev 11190)
+++ code/branches/bindermFS16/src/orxonox/LevelManager.h 2016-05-19 15:37:05 UTC (rev 11191)
@@ -23,6 +23,7 @@
* Fabian 'x3n' Landau
* Co-authors:
* Damian 'Mozork' Frick
+ * Matthias Binder
*
*/
@@ -146,7 +147,7 @@
std::string defaultLevelName_;
std::string lastWonMission_;
std::vector<std::string> campaignMissions_;
- std::vector<int> test_;
+ std::vector<int> allLevelWon_;
std::vector<LevelStatus> allLevelStatus_;
Modified: code/branches/bindermFS16/src/orxonox/LevelStatus.h
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelStatus.h 2016-05-19 15:34:38 UTC (rev 11190)
+++ code/branches/bindermFS16/src/orxonox/LevelStatus.h 2016-05-19 15:37:05 UTC (rev 11191)
@@ -20,17 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * Damian 'Mozork' Frick
+ * Matthias Binder
*
*/
-/**
- @file LevelManager.h
- @brief Definition of the LevelManager singleton.
- @ingroup Orxonox
-*/
+
#ifndef _LevelStatus_H__
#define _LevelStatus_H__
@@ -51,7 +45,15 @@
namespace orxonox
{
+ /**
+ @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.
+
+ */
+
class _OrxonoxExport LevelStatus : public BaseObject
{
public:
@@ -59,7 +61,7 @@
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
+ std::vector<int> nextLevels; //if this Level is won, the ith element of this vector shows, what to do with the other leves
int activated; //0 not activated, 1 activated, 2 visible
};
}
Modified: code/branches/bindermFS16/src/orxonox/gametypes/Mission.h
===================================================================
--- code/branches/bindermFS16/src/orxonox/gametypes/Mission.h 2016-05-19 15:34:38 UTC (rev 11190)
+++ code/branches/bindermFS16/src/orxonox/gametypes/Mission.h 2016-05-19 15:37:05 UTC (rev 11191)
@@ -44,7 +44,7 @@
virtual void tick(float dt) override;
virtual void start() override;
- virtual void end() override;
+ virtual void end() override; //checks if the mission was accomplished and sends the name of the won mission to the LevelManager
virtual void setTeams();
virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
inline void setLives(unsigned int amount)
More information about the Orxonox-commit
mailing list