Index: /code/trunk/src/modules/questsystem/CMakeLists.txt
===================================================================
--- /code/trunk/src/modules/questsystem/CMakeLists.txt	(revision 5744)
+++ /code/trunk/src/modules/questsystem/CMakeLists.txt	(revision 5745)
@@ -12,4 +12,6 @@
   QuestEffect.cc
   QuestEffectBeacon.cc
+  QuestGUINode.cc
+  QuestGUI.cc
   QuestHint.cc
   QuestItem.cc
Index: /code/trunk/src/modules/questsystem/QuestManager.cc
===================================================================
--- /code/trunk/src/modules/questsystem/QuestManager.cc	(revision 5744)
+++ /code/trunk/src/modules/questsystem/QuestManager.cc	(revision 5745)
@@ -37,9 +37,13 @@
 #include "core/CoreIncludes.h"
 #include "core/GUIManager.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h" //TDO: Necessary?
+#include <CEGUIWindow.h>
+#include "overlays/GUIOverlay.h"
 
 #include "infos/PlayerInfo.h"
 #include "Quest.h"
 #include "QuestHint.h"
-#include "QuestItem.h"
+#include "QuestItem.h" //TDO: Necessary?
 
 namespace orxonox
@@ -65,4 +69,20 @@
     QuestManager::~QuestManager()
     {
+        for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++)
+        {
+            delete (*it).second;
+        }
+        this->questGUIs_.clear();
+    }
+
+    /**
+    @brief
+        Retreive all Quests.
+    @return
+        Returns a map with all Quests indexed by their id's.
+    */
+    std::map<std::string, Quest*> & QuestManager::getQuests(void)
+    {
+        return this->questMap_;
     }
 
@@ -201,167 +221,42 @@
     /**
     @brief
-
-    @param name
-    @return
-    */
-    QuestContainer* QuestManager::getQuestTree(std::string & name)
-    {
-        PlayerInfo* player = GUIManager::getInstance().getPlayer(name);
+        Retreive the main window for the GUI.
+        This is for the use in the lua script tu start the QuestGUI.
+    @param guiName
+        The name of the GUI.
+    @return
+        Returns a CEGUI Window.
+    */
+    CEGUI::Window* QuestManager::getQuestGUI(const std::string & guiName)
+    {
+        PlayerInfo* player = this->retreivePlayer(guiName);
+
+        if(this->questGUIs_.find(player) == this->questGUIs_.end()) //!< Create a new GUI, if there is none, yet.
+            this->questGUIs_[player] = new QuestGUI(player);
+
+        return this->questGUIs_[player]->getGUI();
+    }
+
+    /**
+    @brief
+        Retrieve the player for a certain GUI.
+    @param guiName
+        The name of the GUI the player is retrieved for.
+    @return
+        Returns the player.
+    @todo
+        This very well might be outdated. So: Check if still needed, and update if necessary.
+    */
+    PlayerInfo* QuestManager::retreivePlayer(const std::string & guiName)
+    {
+        PlayerInfo* player = GUIManager::getInstance().getPlayer(guiName);
         if(player == NULL)
         {
-            COUT(1) << "Error: GUIOverlay with name '" << name << "' has no player." << std::endl;
+            COUT(1) << "Error: GUIOverlay with name '" << guiName << "' has no player." << std::endl;
             return NULL;
         }
 
-        QuestContainer* root = NULL;
-        QuestContainer* current = NULL;
-
-        std::list<Quest*>* rootQuests = new std::list<Quest*>();
-        getRootQuests(player, *rootQuests);
-
-        for(std::list<Quest*>::iterator it = rootQuests->begin(); it != rootQuests->end(); it++)
-        {
-            QuestContainer* container = addSubQuest(*it, player);
-
-            if(root == NULL)
-            {
-                root = container;
-            }
-            else
-            {
-                current->next = container;
-            }
-
-            current = container;
-
-        }
-        if(current != NULL)
-            current->next = NULL;
-
-        delete rootQuests;
-
-        return root;
-    }
-
-    /**
-    @brief
-
-    @param player
-    @param list
-    @return
-    */
-    void QuestManager::getRootQuests(const PlayerInfo* player, std::list<Quest*> & list)
-    {
-        for(std::map<std::string, Quest*>::iterator it=this->questMap_.begin(); it!=this->questMap_.end(); it++)
-        {
-            Quest* quest = (*it).second;
-            if(quest->getParentQuest() == NULL && !quest->isInactive(player))
-            {
-                list.push_back(quest);
-            }
-        }
-    }
-
-    /**
-    @brief
-
-    @param quest
-    @param player
-    @return
-    */
-    QuestContainer* QuestManager::addSubQuest(Quest* quest, const PlayerInfo* player)
-    {
-        if(quest == NULL)
-            return NULL;
-
-        QuestContainer* container = new QuestContainer;
-        container->description = quest->getDescription();
-        container->hint = addHints(quest, player);
-
-        if(quest->isActive(player))
-        {
-            container->status = "active";
-        }
-        else if(quest->isCompleted(player))
-        {
-            container->status = "completed";
-        }
-        else if(quest->isFailed(player))
-        {
-            container->status = "failed";
-        }
-        else
-        {
-            container->status = "";
-            COUT(1) << "An error occurred. A Quest of un-specified status wanted to be displayed." << std::endl;
-        }
-
-        std::list<Quest*> quests = quest->getSubQuestList();
-        QuestContainer* current = NULL;
-        QuestContainer* first = NULL;
-        for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
-        {
-            Quest* subQuest = *it;
-            if(!subQuest->isInactive(player))
-            {
-                QuestContainer* subContainer = addSubQuest(subQuest, player);
-
-                if(first == NULL)
-                {
-                    first = subContainer;
-                }
-                else
-                {
-                    current->next = subContainer;
-                }
-
-                current = subContainer;
-            }
-        }
-        if(current != NULL)
-            current->next = NULL;
-        container->subQuests = first;
-
-        return container;
-    }
-
-    /**
-    @brief
-
-    @param quest
-    @param player
-    @return
-    */
-    HintContainer* QuestManager::addHints(Quest* quest, const PlayerInfo* player)
-    {
-        HintContainer* current = NULL;
-        HintContainer* first = NULL;
-
-        std::list<QuestHint*> hints = quest->getHintsList();
-        for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
-        {
-            if((*it)->isActive(player))
-            {
-                HintContainer* hint = new HintContainer;
-                hint->description = (*it)->getDescription();
-
-                if(first == NULL)
-                {
-                    first = hint;
-                }
-                else
-                {
-                    current->next = hint;
-                }
-
-                current = hint;
-            }
-        }
-
-        if(current != NULL)
-            current->next = NULL;
-        return first;
-    }
-
+        return player;
+    }
 
 }
Index: /code/trunk/src/modules/questsystem/QuestManager.h
===================================================================
--- /code/trunk/src/modules/questsystem/QuestManager.h	(revision 5744)
+++ /code/trunk/src/modules/questsystem/QuestManager.h	(revision 5745)
@@ -36,4 +36,5 @@
 
 #include "questsystem/QuestsystemPrereqs.h"
+#include <CEGUIForwardRefs.h>
 
 #include <list>
@@ -44,25 +45,9 @@
 #include "core/OrxonoxClass.h"
 
+#include "QuestGUI.h"
+
 // tolua_begin
 namespace orxonox
 {
-
-    struct QuestContainer;
-    struct HintContainer;
-
-    struct QuestContainer
-    {
-        const QuestDescription* description;
-        std::string status;
-        HintContainer* hint;
-        QuestContainer* subQuests;
-        QuestContainer* next;
-    };
-
-    struct HintContainer
-    {
-        const QuestDescription* description;
-        HintContainer* next;
-    };
 
     typedef ScopedSingleton<QuestManager, ScopeID::GSLevel> ScopedSingletonQuestManagerGSLevel; // workaround for tolua
@@ -78,5 +63,9 @@
     {
 // tolua_end
+
             friend class ScopedSingleton<QuestManager, ScopeID::GSLevel>;
+            friend class QuestGUI; //TDO: better solution.
+            //friend std::map<std::string, Quest*> & QuestGUI::getQuests(void);
+
         public:
             QuestManager();
@@ -86,4 +75,7 @@
             static QuestManager& getInstance() { return ScopedSingleton<QuestManager, ScopeID::GSLevel>::getInstance(); } // tolua_export
 
+            //! Retreive the main window for the GUI. 
+            CEGUI::Window* getQuestGUI(const std::string & guiName); // tolua_export
+
             bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager.
             bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager.
@@ -92,15 +84,16 @@
             QuestHint* findHint(const std::string & hintId); //!< Returns the QuestHint with the input id.
 
-            QuestContainer* getQuestTree(std::string & name); // tolua_export
+        protected:
+            std::map<std::string, Quest*> & getQuests(void); //!< Retreive all Quests.
 
         private:
             static QuestManager* singletonPtr_s;
+            PlayerInfo* retreivePlayer(const std::string & guiName); //!< Retrieve the player for a certain GUI.
 
             std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's.
             std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's.
 
-            void getRootQuests(const PlayerInfo* player, std::list<Quest*> & list);
-            HintContainer* addHints(Quest* quest, const PlayerInfo* player);
-            QuestContainer* addSubQuest(Quest* quest, const PlayerInfo* player);
+            //TDO: Call destructor of QuestGUI's on destruction of QuestManager?
+            std::map<PlayerInfo*, QuestGUI*> questGUIs_; //!< All GUI's registered by the players.
 
     }; // tolua_export
Index: /code/trunk/src/modules/questsystem/QuestsystemPrereqs.h
===================================================================
--- /code/trunk/src/modules/questsystem/QuestsystemPrereqs.h	(revision 5744)
+++ /code/trunk/src/modules/questsystem/QuestsystemPrereqs.h	(revision 5745)
@@ -76,4 +76,6 @@
     class QuestEffect;
     class QuestEffectBeacon;
+    class QuestGUINode;
+    class QuestGUI;
     class QuestHint;
     class QuestItem;
