[Orxonox-commit 6539] r11180 - in code/branches/bindermFS16: data/gui/layouts data/gui/scripts src/orxonox src/orxonox/gametypes
binderm at orxonox.net
binderm at orxonox.net
Tue May 10 12:09:10 CEST 2016
Author: binderm
Date: 2016-05-10 12:09:09 +0200 (Tue, 10 May 2016)
New Revision: 11180
Modified:
code/branches/bindermFS16/data/gui/layouts/CampaignMenu.layout
code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua
code/branches/bindermFS16/src/orxonox/LevelManager.cc
code/branches/bindermFS16/src/orxonox/LevelManager.h
code/branches/bindermFS16/src/orxonox/gametypes/Mission.cc
Log:
logic to show only certain levels and not all together, also not all shown levels have to be activated
Modified: code/branches/bindermFS16/data/gui/layouts/CampaignMenu.layout
===================================================================
--- code/branches/bindermFS16/data/gui/layouts/CampaignMenu.layout 2016-04-28 14:09:08 UTC (rev 11179)
+++ code/branches/bindermFS16/data/gui/layouts/CampaignMenu.layout 2016-05-10 10:09:09 UTC (rev 11180)
@@ -12,8 +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.35,0},{0.1,0},{0.65,0},{0.15,0}}" />
- <Property Name="Disabled" Value="False" />
+ <Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.01,0},{0.3,0},{0.06,0}}" />
<Event Name="Clicked" Function="CampaignMenu.Mission1Button_clicked"/>
</Window>
Modified: code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua
===================================================================
--- code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua 2016-04-28 14:09:08 UTC (rev 11179)
+++ code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua 2016-05-10 10:09:09 UTC (rev 11180)
@@ -25,10 +25,15 @@
end
function P.updateButton(index, button)
- if (orxonox.LevelManager:getInstance():missionactivate(index)) then
+ local test =orxonox.LevelManager:getInstance():missionactivate(index)
+ if (test==1) then
button:setProperty("Visible", "True")
button:setProperty("Disabled", "False")
+ elseif (test==2) then
+ button:setProperty("Visible", "True")
+ button:setProperty("Disabled", "True")
else
+ button:setProperty("Visible", "False")
button:setProperty("Disabled", "True")
end
end
Modified: code/branches/bindermFS16/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelManager.cc 2016-04-28 14:09:08 UTC (rev 11179)
+++ code/branches/bindermFS16/src/orxonox/LevelManager.cc 2016-05-10 10:09:09 UTC (rev 11180)
@@ -51,24 +51,62 @@
LevelStatus::LevelStatus()
{
- this->won = true;
+ this->won = false;
+ this->nextLevels.insert(this->nextLevels.begin(),-1);
}
LevelStatus::~LevelStatus()
{}
- bool LevelManager::missionactivate(int index)
+
+ //check if index level is activated...
+ int LevelManager::missionactivate(int index)
{
- //check for index level activate...
- return index-5;
+ return index+1;
+
+
+ if (allLevelStatus_[index].won)
+ return 1;
+
+ //check if level is activated
+ for(unsigned int i=1;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=1;i<allLevelStatus_.size();i++)
+ {
+ std::vector<int> nextLevels=allLevelStatus_[i].nextLevels;
+ bool won=allLevelStatus_[i].won;
+ if(nextLevels[index]==2&&won)
+ return 2;
+ };
+ return false;
}
- void LevelManager::setLevelStatus(int completedLevel)
+ //updates the won variable of the corresponding LevelStatus in allLevelStatus_
+ void LevelManager::setLevelStatus(const int completedLevel)
{
-// allLevelStatus_[completedLevel]=new LevelStatus;
+ allLevelStatus_[completedLevel].won=true;
}
+ //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_[1].won=true;
+ }
+
+
+
SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)");
ManageScopedSingleton(LevelManager, ScopeID::ROOT, false);
@@ -96,7 +134,7 @@
this->nextIndex_ = 0;
this->nextLevel_ = this->availableLevels_.begin();
- allLevelStatus_.reserve(1);
+ buildallLevelStatus();
}
Modified: code/branches/bindermFS16/src/orxonox/LevelManager.h
===================================================================
--- code/branches/bindermFS16/src/orxonox/LevelManager.h 2016-04-28 14:09:08 UTC (rev 11179)
+++ code/branches/bindermFS16/src/orxonox/LevelManager.h 2016-05-10 10:09:09 UTC (rev 11180)
@@ -57,8 +57,6 @@
LevelStatus();
virtual ~LevelStatus();
-
- private:
bool won;
std::vector<int> nextLevels;
@@ -96,7 +94,8 @@
LevelManager();
virtual ~LevelManager();
- void setLevelStatus(int integer);
+ void setLevelStatus(const int integer);
+ void buildallLevelStatus();
void setConfigValues(); //!< Set the config values for this object.
@@ -107,7 +106,7 @@
Level* getActiveLevel(); //!< Get the currently active Level.
// tolua_begin
- bool missionactivate(int index);
+ int missionactivate(int index);
void setDefaultLevel(const std::string& levelName); //!< Set the default Level.
/**
@brief Get the default level.
@@ -158,6 +157,7 @@
std::string defaultLevelName_;
std::string lastFinishedCampaignMission_;
std::vector<std::string> campaignMissions_;
+
std::vector<LevelStatus> allLevelStatus_;
Modified: code/branches/bindermFS16/src/orxonox/gametypes/Mission.cc
===================================================================
--- code/branches/bindermFS16/src/orxonox/gametypes/Mission.cc 2016-04-28 14:09:08 UTC (rev 11179)
+++ code/branches/bindermFS16/src/orxonox/gametypes/Mission.cc 2016-05-10 10:09:09 UTC (rev 11180)
@@ -91,7 +91,9 @@
this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
LevelManager::getInstance().setLastFinishedCampaignMission(this->getFilename());
- //LevelManager::getInstance().setLevelStatus(7);
+
+ //gibt index von bestandenem level weiter
+ LevelManager::getInstance().setLevelStatus(7);
}
else if (!this->gtinfo_->hasEnded())
this->gtinfo_->sendAnnounceMessage("Mission failed!");
More information about the Orxonox-commit
mailing list