Index: code/branches/storymodeHS14/data/defaultConfig/orxonox.ini
===================================================================
--- code/branches/storymodeHS14/data/defaultConfig/orxonox.ini	(revision 10253)
+++ code/branches/storymodeHS14/data/defaultConfig/orxonox.ini	(revision 10253)
@@ -0,0 +1,5 @@
+[LevelManager]
+campaignMissions_[0] = "missionOne.oxw"
+campaignMissions_[1] = "fightInOurBack.oxw"
+campaignMissions_[2] = "pirateAttack.oxw"
+campaignMissions_[3] = "iJohnVane_TriptoArea51.oxw"
Index: code/branches/storymodeHS14/data/gui/layouts/CampaignMenu.layout
===================================================================
--- code/branches/storymodeHS14/data/gui/layouts/CampaignMenu.layout	(revision 10251)
+++ code/branches/storymodeHS14/data/gui/layouts/CampaignMenu.layout	(revision 10253)
@@ -10,4 +10,5 @@
         <Window Type="MenuWidgets/Button" Name="orxonox/MissionOneButton" >
             <Property Name="Text" Value="Mission 1" />
+            <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.2875,0},{0.6,0},{0.3375,0}}" />
@@ -16,4 +17,5 @@
         <Window Type="MenuWidgets/Button" Name="orxonox/MissionTwoButton" >
             <Property Name="Text" Value="Mission 2" />
+            <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.3625,0},{0.6,0},{0.4125,0}}" />
@@ -23,4 +25,5 @@
         <Window Type="MenuWidgets/Button" Name="orxonox/MissionThreeButton" >
             <Property Name="Text" Value="Mission 3" />
+            <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.4375,0},{0.6,0},{0.4875,0}}" />
@@ -30,4 +33,5 @@
         <Window Type="MenuWidgets/Button" Name="orxonox/MissionFourButton" >
             <Property Name="Text" Value="Mission 4" />
+            <Property Name="Visible" Value="False"/>
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5125,0},{0.6,0},{0.5625,0}}" />
@@ -38,16 +42,10 @@
             <Property Name="Text" Value="Back" />
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.7,0},{0.8,0},{0.85,0},{0.85,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.8,0},{0.6,0},{0.85,0}}" />
             <Event Name="Clicked" Function="CampaignMenu.CampaignMenuBackButton_clicked"/> 
         </Window>
-        <Window Type="MenuWidgets/Button" Name="orxonox/CampaignMenuRefreshButton" >
-            <Property Name="Text" Value="Refresh" />
-            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.8,0},{0.3,0},{0.85,0}}" />
-            <Event Name="Clicked" Function="CampaignMenu.CampaignMenuRefreshButton_clicked"/> 
-        </Window>
-         <Window Type="MenuWidgets/StaticText" Name="orxonox/CampaignMenuCongratulation" >
+        <Window Type="MenuWidgets/StaticText" Name="orxonox/CampaignMenuCongratulation" >
             <Property Name="Text" Value="Campaign Completed!!!" />
-            <Property Name="Visible" Value="False"/>      
+            <Property Name="Visible" Value="False"/>
             <Property Name="InheritsAlpha" Value="False" />
             <Property Name="HorzFormatting" Value="HorzCentred" />
@@ -55,5 +53,5 @@
             <Property Name="UnifiedMaxSize" Value="{{2,1},{2,1}}" />
             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.15,0},{0.6,0},{0.2,0}}" />
-		</Window>
+        </Window>
     </Window>
 </GUILayout>
Index: code/branches/storymodeHS14/data/gui/scripts/CampaignMenu.lua
===================================================================
--- code/branches/storymodeHS14/data/gui/scripts/CampaignMenu.lua	(revision 10251)
+++ code/branches/storymodeHS14/data/gui/scripts/CampaignMenu.lua	(revision 10253)
@@ -3,38 +3,78 @@
 local P = createMenuSheet("CampaignMenu")
 
-function P.onLoad()
-    
-    local MissionTwoButton = winMgr:getWindow("orxonox/MissionTwoButton")
-    if (P.CheckLevel("missionOne.oxw")) then
-    MissionTwoButton:setProperty("Disabled", "False")
-    end
-    
-    local MissionThreeButton = winMgr:getWindow("orxonox/MissionThreeButton")
-    if (P.CheckLevel("fightInOurBack.oxw")) then
-    MissionThreeButton:setProperty("Disabled", "False")
-    end
+function P:onShow()
+    P:updateButtons()
+end
 
-    local MissionFourButton = winMgr:getWindow("orxonox/MissionFourButton")
-    if (P.CheckLevel("pirateAttack.oxw")) then
-    MissionFourButton:setProperty("Disabled", "False")
-    end
-    
-    local Completed = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
-    if (P.CheckLevel("iJohnVane_TriptoArea51.oxw")) then
-    Completed:setProperty("Visible","True")
+function P.updateButtons()
+    P.updateButton(0, winMgr:getWindow("orxonox/MissionOneButton"))
+    P.updateButton(1, winMgr:getWindow("orxonox/MissionTwoButton"))
+    P.updateButton(2, winMgr:getWindow("orxonox/MissionThreeButton"))
+    P.updateButton(3, winMgr:getWindow("orxonox/MissionFourButton"))
+
+    if (P.getIndexOfLastFinishedMission() == orxonox.LevelManager:getInstance():getNumberOfCampaignMissions() - 1) then
+        local label = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
+        label:setProperty("Visible","True")
     end
 end
 
-function P.GenerateHelperString(number)
-    local string = ""
-    while number > 1 do
-        string = string.." "
-        number = number-1
+function P.updateButton(index, button)
+    if (P.shouldDisplayButton(index)) then
+        button:setProperty("Visible", "True")
+
+        if (P.shouldEnableButton(index)) then
+            button:setProperty("Disabled", "False")
+        end
     end
-    string = string.."."
-    return string
 end
 
-function P.FindLevel(filename)
+function P.shouldDisplayButton(index)
+    local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
+    return index < size
+end
+
+function P.shouldEnableButton(index)
+    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.MissionOneButton_clicked(e)
+    P.loadLevel(P.FindLevel(0))
+end
+
+function P.MissionTwoButton_clicked(e)
+    P.loadLevel(P.FindLevel(1))
+end
+
+function P.MissionThreeButton_clicked(e)
+    P.loadLevel(P.FindLevel(2))
+end
+
+function P.MissionFourButton_clicked(e)
+    P.loadLevel(P.FindLevel(3))
+end
+
+function P.loadLevel(level)
+    orxonox.execute("startGame " .. level:getXMLFilename())
+    hideAllMenuSheets()
+end
+
+function P.FindLevel(index)
+    local filename = orxonox.LevelManager:getInstance():getCampaignMission(index)
     local level = nil
     local templevel = nil
@@ -50,83 +90,4 @@
     return level
 end
-    
-function P.CheckLevel(filename)
-    local file = io.open("campaign.txt", "r+")
-    local index = 0
-    local returnvalue = false
-    local numberoflines = 58-string.len(filename)
-    local helpstringfalse = filename.." 0"..P.GenerateHelperString(numberoflines) 
-    local helpstringtrue = filename.." 1"..P.GenerateHelperString(numberoflines)
-    while index < 100 do
-        local line = file:read()
-        if(line == helpstringfalse) then
-            returnvalue = false 
-            break
-        end
-        if(line == helpstringtrue) then
-            returnvalue = true
-            break
-        end
-        index=index+1
-    end
-    io.close(file)
-    return returnvalue
-end
-
-function P.MissionOneButton_clicked(e)
-    local level = P.FindLevel("missionOne.oxw")
-        orxonox.execute("startGame " .. level:getXMLFilename())
-        hideAllMenuSheets()
-end
-
-function P.MissionTwoButton_clicked(e)
-    local level = P.FindLevel("fightInOurBack.oxw")
-    if (P.CheckLevel("missionOne.oxw")) then
-        orxonox.execute("startGame " .. level:getXMLFilename())
-        hideAllMenuSheets()
-    end
-end
-
-function P.MissionThreeButton_clicked(e)
-    local level = P.FindLevel("pirateAttack.oxw")
-    if (P.CheckLevel("fightInOurBack.oxw")) then
-        orxonox.execute("startGame " .. level:getXMLFilename())
-        hideAllMenuSheets()
-    else
-         hideMenuSheet(P.name)
-    end
-end
-
-function P.MissionFourButton_clicked(e)
-    local level = P.FindLevel("iJohnVane_TriptoArea51.oxw")
-    if (P.CheckLevel("pirateAttack.oxw")) then
-        orxonox.execute("startGame " .. level:getXMLFilename())
-        hideAllMenuSheets()
-    else
-         hideMenuSheet(P.name)
-    end
-end
-
-function P.CampaignMenuRefreshButton_clicked(e)
-    local MissionTwoButton = winMgr:getWindow("orxonox/MissionTwoButton")
-    if (P.CheckLevel("missionOne.oxw")) then
-    MissionTwoButton:setProperty("Disabled", "False")
-    end
-    
-    local MissionThreeButton = winMgr:getWindow("orxonox/MissionThreeButton")
-    if (P.CheckLevel("fightInOurBack.oxw")) then
-    MissionThreeButton:setProperty("Disabled", "False")
-    end
-
-    local MissionFourButton = winMgr:getWindow("orxonox/MissionFourButton")
-    if (P.CheckLevel("pirateAttack.oxw")) then
-    MissionFourButton:setProperty("Disabled", "False")
-    end
-    
-    local Completed = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
-    if (P.CheckLevel("iJohnVane_TriptoArea51.oxw")) then
-    Completed:setProperty("Visible","True")
-    end
-end
 
 function P.CampaignMenuBackButton_clicked(e)
@@ -134,5 +95,3 @@
 end
 
-
-
 return P
Index: code/branches/storymodeHS14/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/storymodeHS14/src/orxonox/LevelManager.cc	(revision 10251)
+++ code/branches/storymodeHS14/src/orxonox/LevelManager.cc	(revision 10253)
@@ -89,4 +89,16 @@
         SetConfigValue(defaultLevelName_, "missionOne.oxw")
             .description("Sets the pre selection of the level in the main menu.");
+        SetConfigValue(lastFinishedCampaignMission_,  "")
+            .description("The last finished mission of a campaign");
+        SetConfigValue(campaignMissions_,  std::vector<std::string>())
+            .description("The list of missions in the campaign");
+    }
+
+    /**
+     * @brief Stores the argument in the corresponding config value.
+     */
+    void LevelManager::setLastFinishedCampaignMission(const std::string& lastFinishedCampaignMission)
+    {
+        ModifyConfigValue(lastFinishedCampaignMission_, set, lastFinishedCampaignMission);
     }
 
Index: code/branches/storymodeHS14/src/orxonox/LevelManager.h
===================================================================
--- code/branches/storymodeHS14/src/orxonox/LevelManager.h	(revision 10251)
+++ code/branches/storymodeHS14/src/orxonox/LevelManager.h	(revision 10253)
@@ -91,4 +91,13 @@
             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_; }
+
+            inline unsigned int getNumberOfCampaignMissions()
+                { return this->campaignMissions_.size(); }
+            inline const std::string& getCampaignMission(unsigned int index)
+                { return this->campaignMissions_[index]; }
+
             /**
             @brief Get the instance of the LevelManager.
@@ -116,4 +125,6 @@
             // config values
             std::string defaultLevelName_;
+            std::string lastFinishedCampaignMission_;
+            std::vector<std::string> campaignMissions_;
 
             static LevelManager* singletonPtr_s;
Index: code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc
===================================================================
--- code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc	(revision 10251)
+++ code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc	(revision 10253)
@@ -36,11 +36,9 @@
 #include "core/CoreIncludes.h"
 #include "core/command/ConsoleCommand.h"
+#include "core/config/ConfigValueIncludes.h"
 #include "infos/PlayerInfo.h"
 #include "network/Host.h"
 #include "worldentities/pawns/Pawn.h"
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <ios>
+#include "LevelManager.h"
 
 namespace orxonox
@@ -93,16 +91,4 @@
     }
 
-    std::string GenerateHelperString(int number)
-    {
-        std::string helperstring = "";
-        while (number > 1)
-        {
-            helperstring = helperstring + " ";
-            number = number - 1;
-        }
-        helperstring = helperstring + ".";
-        return helperstring;
-    }
-
     void Mission::end()
     {
@@ -112,35 +98,5 @@
             this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
 
-            boost::filesystem::path filepath("campaign.txt");
-            std::fstream myfile;
-            myfile.open(filepath.string().c_str(), std::fstream::out);
-
-            std::string line;
-            std::string mission = this->getFilename();
-            int k = 58 - mission.length();
-            std::string helperstring = "";
-            if (myfile.is_open())
-            {
-                while (k > 1)
-                {
-                    helperstring = helperstring + " ";
-                    k = k - 1;
-                }
-                helperstring = helperstring + ".";
-                while (getline(myfile, line))
-                {
-                    if (line == mission + " 0" + helperstring)
-                    {
-                        long pos = (long) myfile.tellp();
-                        myfile.seekp(pos - 61);
-                        myfile << mission + " 1" + helperstring;
-                    }
-                }
-            } else {
-                orxout(internal_warning) << "failed to open campaign file" << endl;
-            }
-            myfile.flush();
-            myfile.clear();
-            myfile.close();
+            LevelManager::getInstance().setLastFinishedCampaignMission(this->getFilename());
         }
 
