Index: code/branches/libraries/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/CMakeLists.txt	(revision 5643)
+++ code/branches/libraries/src/orxonox/CMakeLists.txt	(revision 5648)
@@ -47,6 +47,4 @@
     objects/pickup/BaseItem.h
     objects/pickup/PickupInventory.h
-    objects/quest/QuestDescription.h
-    objects/quest/QuestManager.h
   DEFINE_SYMBOL
     "ORXONOX_SHARED_BUILD"
Index: code/branches/libraries/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/libraries/src/orxonox/OrxonoxPrereqs.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/OrxonoxPrereqs.h	(revision 5648)
@@ -80,23 +80,4 @@
     class Tickable;
 
-    class AddQuest;
-    class AddQuestHint;
-    class AddReward;
-    class ChangeQuestStatus;
-    class CompleteQuest;
-    class FailQuest;
-    class GlobalQuest;
-    class LocalQuest;
-    class Quest;
-    class QuestDescription;
-    class QuestEffect;
-    class QuestEffectBeacon;
-    class QuestHint;
-    class QuestItem;
-    class QuestListener;
-    class QuestManager;
-    class QuestNotification;
-    class Rewardable;
-
     class WorldEntity;
     class StaticEntity;
Index: code/branches/libraries/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/libraries/src/orxonox/gamestates/GSLevel.cc	(revision 5643)
+++ code/branches/libraries/src/orxonox/gamestates/GSLevel.cc	(revision 5648)
@@ -47,6 +47,4 @@
 #include "tools/interfaces/Tickable.h"
 #include "objects/Radar.h"
-#include "objects/quest/QuestManager.h"
-#include "objects/quest/notifications/NotificationManager.h"
 #include "CameraManager.h"
 #include "LevelManager.h"
@@ -110,7 +108,5 @@
         this->playerManager_ = new PlayerManager();
 
-        this->questManager_ = new QuestManager();
-
-        this->notificationManager_ = new NotificationManager();
+        this->scope_GSLevel_ = new Scope<ScopeID::GSLevel>();
 
         if (GameMode::isMaster())
@@ -201,14 +197,8 @@
         }
 
-        if (this->questManager_)
-        {
-            delete this->questManager_;
-            this->questManager_ = NULL;
-        }
-
-        if (this->notificationManager_)
-        {
-            delete this->notificationManager_;
-            this->notificationManager_ = NULL;
+        if (this->scope_GSLevel_)
+        {
+            delete this->scope_GSLevel_;
+            this->scope_GSLevel_ = NULL;
         }
 
Index: code/branches/libraries/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/branches/libraries/src/orxonox/gamestates/GSLevel.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/gamestates/GSLevel.h	(revision 5648)
@@ -33,4 +33,5 @@
 
 #include <string>
+#include "util/Scope.h"
 #include "core/OrxonoxClass.h"
 #include "core/GameState.h"
@@ -62,13 +63,12 @@
         void keybindInternal(const std::string& command, bool bTemporary);
 
-        KeyBinder*            keyBinder_;               //!< tool that loads and manages the input bindings
-        InputState*           gameInputState_;          //!< input state for normal ingame playing
-        InputState*           guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
-        InputState*           guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
-        Radar*                radar_;                   //!< represents the Radar (not the HUD part)
-        CameraManager*        cameraManager_;           //!< camera manager for this level
-        PlayerManager*        playerManager_;           //!< player manager for this level
-        QuestManager*         questManager_;
-        NotificationManager*  notificationManager_;
+        KeyBinder*               keyBinder_;               //!< tool that loads and manages the input bindings
+        InputState*              gameInputState_;          //!< input state for normal ingame playing
+        InputState*              guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
+        InputState*              guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
+        Radar*                   radar_;                   //!< represents the Radar (not the HUD part)
+        CameraManager*           cameraManager_;           //!< camera manager for this level
+        PlayerManager*           playerManager_;           //!< player manager for this level
+        Scope<ScopeID::GSLevel>* scope_GSLevel_;
 
         //##### ConfigValues #####
Index: code/branches/libraries/src/orxonox/objects/quest/AddQuest.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/AddQuest.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/AddQuest.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _AddQuest_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 #include "ChangeQuestStatus.h"
 
@@ -43,19 +43,19 @@
     @brief
         Adds a Quest, resp. changes the quests status to active for the player invoking the Quest.
-        
+
         Creating a AddQuest through XML goes as follows:
-        
+
         <AddQuest questId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be added.
     @author
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport AddQuest : public ChangeQuestStatus
+    class _QuestExport AddQuest : public ChangeQuestStatus
     {
         public:
         AddQuest(BaseObject* creator);
         virtual ~AddQuest();
-    
+
         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML.
-    
+
         virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
 
Index: code/branches/libraries/src/orxonox/objects/quest/AddQuestHint.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/AddQuestHint.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/AddQuestHint.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _AddQuestHint_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <string>
@@ -45,12 +45,12 @@
     @brief
         Adds a QuestHint, resp. activates the QuestHint of the given id for the player the QuestEffect is invoked on.
-        
+
     Creating a AddQuestHint through XML goes as follows:
-        
+
         <AddQuestHint hintId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the QuestHint that should be added.
     @author
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport AddQuestHint : public QuestEffect
+    class _QuestExport AddQuestHint : public QuestEffect
     {
         public:
@@ -71,5 +71,5 @@
             inline const std::string & getHintId(void) const
                 { return this->hintId_; }
-            
+
             bool setHintId(const std::string & id); //!< Sets the id of the QuestHint.
 
Index: code/branches/libraries/src/orxonox/objects/quest/AddReward.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/AddReward.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/AddReward.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _AddReward_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <list>
@@ -45,7 +45,7 @@
     @brief
         Adds a list of Rewardables to a player.
-        
+
         Creating a AddReward through XML goes as follows:
-        
+
         <AddReward>
             <Rewardable /> //A list of Rewardable objects to be rewarded the player, see the specific Rewardables for their respective XML representations.
@@ -56,5 +56,5 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport AddReward : public QuestEffect
+    class _QuestExport AddReward : public QuestEffect
     {
         public:
@@ -75,5 +75,5 @@
             inline void addRewardable(Rewardable* reward)
                 { this->rewards_.push_back(reward); }
-        
+
             const Rewardable* getRewardables(unsigned int index) const; //!< Returns the Rewardable object at the given index.
 
Index: code/branches/libraries/src/orxonox/objects/quest/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/CMakeLists.txt	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/CMakeLists.txt	(revision 5648)
@@ -1,3 +1,3 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+SET_SOURCE_FILES(QUEST_SRC_FILES
   AddQuest.cc
   AddQuestHint.cc
@@ -20,2 +20,18 @@
 
 ADD_SUBDIRECTORY(notifications)
+
+# add the parent directory for tolua (TODO: remove this if the quest plugin is moved somewhere else)
+INCLUDE_DIRECTORIES(..)
+
+ORXONOX_ADD_LIBRARY(quest
+  PLUGIN
+  TOLUA_FILES
+    QuestDescription.h
+    QuestManager.h
+  DEFINE_SYMBOL
+    "QUEST_SHARED_BUILD"
+  LINK_LIBRARIES
+    orxonox
+    overlays
+  SOURCE_FILES ${QUEST_SRC_FILES}
+)
Index: code/branches/libraries/src/orxonox/objects/quest/ChangeQuestStatus.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/ChangeQuestStatus.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/ChangeQuestStatus.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _ChangeQuestStatus_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <string>
@@ -48,5 +48,5 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport ChangeQuestStatus : public QuestEffect
+    class _QuestExport ChangeQuestStatus : public QuestEffect
     {
         public:
@@ -68,5 +68,5 @@
         private:
             std::string questId_; //!< The id of the Quest the status should be changed of.
-            
+
             bool setQuestId(const std::string & id); //!< Sets the id of the Quest.
 
Index: code/branches/libraries/src/orxonox/objects/quest/CompleteQuest.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/CompleteQuest.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/CompleteQuest.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _CompleteQuest_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 #include "ChangeQuestStatus.h"
 
@@ -43,12 +43,12 @@
     @brief
         Completes a Quest (with a specified id) for the player invoking the QuestEffect.
-        
+
         Creating a CompleteQuest through XML goes as follows:
-        
+
         <CompleteQuest questId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be completed.
     @author
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport CompleteQuest : public ChangeQuestStatus
+    class _QuestExport CompleteQuest : public ChangeQuestStatus
     {
         public:
Index: code/branches/libraries/src/orxonox/objects/quest/FailQuest.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/FailQuest.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/FailQuest.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _FailQuest_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 #include "ChangeQuestStatus.h"
 
@@ -43,12 +43,12 @@
     @brief
         Fails a quest (with a specified id) for the player invoking the QuestEffect.
-        
+
         Creating a FailQuest through XML goes as follows:
-        
+
         <FailQuest questId="id" />  //Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be failed.
     @author
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport FailQuest : public ChangeQuestStatus
+    class _QuestExport FailQuest : public ChangeQuestStatus
     {
         public:
Index: code/branches/libraries/src/orxonox/objects/quest/GlobalQuest.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/GlobalQuest.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/GlobalQuest.h	(revision 5648)
@@ -26,5 +26,5 @@
  *
  */
- 
+
 /**
     @file
@@ -35,5 +35,5 @@
 #define _GlobalQuest_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <list>
@@ -47,7 +47,7 @@
         GlobalQuests are Quests, that have the same status for all players.
         This means, that when a player successfully completes a GlobalQuest, it is completed for all players that have it.
-        
+
         Creating a GlobalQuest through XML goes as follows:
-        
+
         <GlobalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
             <QuestDescription title="Title" description="Description." /> //The description of the quest.
@@ -81,5 +81,5 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport GlobalQuest : public Quest
+    class _QuestExport GlobalQuest : public Quest
     {
         public:
@@ -88,5 +88,5 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a GlobalQuest object through XML.
-            
+
             virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
             virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
@@ -98,5 +98,5 @@
 
             virtual QuestStatus::Value getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
-            
+
             virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status); //!< Sets the status for a specific player.
 
@@ -105,5 +105,5 @@
             QuestStatus::Value status_; //!< The status of this Quest.
             std::list<QuestEffect*> rewards_; //!< Reward QuestEffects only invoked on the player completing the Quest.
-            
+
             bool addRewardEffect(QuestEffect* effect); //!< Adds a reward QuestEffect to the list of reward QuestEffects.
             const QuestEffect* getRewardEffects(unsigned int index) const; //!< Returns the reward QuestEffect at the given index.
Index: code/branches/libraries/src/orxonox/objects/quest/LocalQuest.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/LocalQuest.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/LocalQuest.h	(revision 5648)
@@ -26,5 +26,5 @@
  *
  */
- 
+
 /**
     @file
@@ -35,5 +35,5 @@
 #define _LocalQuest_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <map>
@@ -46,7 +46,7 @@
         Handles Quests which have different states for different players.
         LocalQuests have (as opposed to GlobalQuests) a different state for each player, that means if for one player the status of the Quest changes it does not for all the other players which also possess this quest.
-        
+
         Creating a LocalQuest through XML goes as follows:
-        
+
         <LocalQuest id="questId"> //Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
             <QuestDescription title="Title" description="Description." /> //The description of the quest.
@@ -75,5 +75,5 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport LocalQuest : public Quest
+    class _QuestExport LocalQuest : public Quest
     {
         public:
@@ -82,5 +82,5 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a LocalQuest object through XML.
-            
+
             virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
             virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
Index: code/branches/libraries/src/orxonox/objects/quest/Quest.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/Quest.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/Quest.h	(revision 5648)
@@ -26,5 +26,5 @@
  *
  */
- 
+
 /**
     @file
@@ -32,9 +32,9 @@
         The Quest is the parent class of LocalQuest and GlobalQuest.
 */
- 
+
 #ifndef _Quest_H__
 #define _Quest_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <list>
@@ -62,10 +62,10 @@
         A Quest has several hints (QuestHint) that can be unlocked through QuestEffects and then display aid in solving the Quest.
         A Quest has a list of QuestEffects that are invoked when the quest is failed and also a list of QuestEffects that are invoked, when the Quest is completed.
-        
+
         Quest itself should not be instantiated, if you want to create a quest either go for LocalQuest or GlobalQuest, whichever suits you needs better.
     @author
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport Quest : public QuestItem
+    class _QuestExport Quest : public QuestItem
     {
         public:
@@ -81,5 +81,5 @@
             inline Quest* getParentQuest(void) const
                 { return this->parentQuest_; }
-                
+
             /**
             @brief Returns the list of subquests.
@@ -95,14 +95,14 @@
             inline const std::list<QuestHint*> & getHintsList(void) const
                 { return this->hints_; }
-        
+
             bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
             bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'.
             bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
             bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
-        
+
             bool start(PlayerInfo* player); //!< Sets a Quest to active.
             virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
             virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
-        
+
             bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest.
 
@@ -116,5 +116,5 @@
             const QuestEffect* getFailEffect(unsigned int index) const; //!< Returns the fail QuestEffect at the given index.
             const QuestEffect* getCompleteEffect(unsigned int index) const; //!< Returns the complete QuestEffect at the given index.
-            
+
             /**
             @brief Returns the list of fail QuestEffects.
@@ -123,5 +123,5 @@
             inline std::list<QuestEffect*> & getFailEffectList(void)
                 { return this->failEffects_; }
-                
+
             /**
             @brief Returns the list of complete QuestEffects.
@@ -133,5 +133,5 @@
             virtual QuestStatus::Value getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
             virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) = 0; //!< Changes the status for a specific player.
-            
+
         private:
             Quest* parentQuest_; //!< Pointer to the parentquest.
@@ -142,7 +142,7 @@
             std::list<QuestEffect*> failEffects_; //!< A list of all QuestEffects to be invoked, when the Quest has been failed.
             std::list<QuestEffect*> completeEffects_; //!< A list of QuestEffects to be invoked, when the Quest has been completed.
-            
+
             std::list<QuestListener*> listeners_; //!< A list of QuestListeners, that listen to what exactly happens with this Quest.
-            
+
             bool setParentQuest(Quest* quest); //!< Sets the parentquest of the Quest.
             bool addSubQuest(Quest* quest); //!< Adds a subquest to the Quest.
Index: code/branches/libraries/src/orxonox/objects/quest/QuestDescription.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestDescription.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestDescription.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _QuestDescription_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <string>
@@ -47,12 +47,12 @@
         This class is a description of a QuestItem.
         It holds a title and a description.
-        
+
         Creating a QuestDescription through XML goes as follows:
-        
+
         <QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" />
     @author
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport QuestDescription : public BaseObject
+    class _QuestExport QuestDescription : public BaseObject
     {
 // tolua_end
@@ -70,5 +70,5 @@
             inline const std::string & getTitle(void) const
                 { return this->title_; }
-        
+
             /**
             @brief Returns the description text.
@@ -78,5 +78,5 @@
                 { return this->description_; }
 // tolua_end
-        
+
             /**
             @brief Returns the fail message.
@@ -85,5 +85,5 @@
             inline const std::string & getFailMessage(void) const
                 { return this->failMessage_; }
-        
+
             /**
             @brief Returns the complete message.
@@ -92,5 +92,5 @@
             inline const std::string & getCompleteMessage(void) const
                 { return this->completeMessage_; }
-        
+
             /**
             @brief Sends a Notification displaying that a QuestHint was added.
@@ -99,5 +99,5 @@
             inline bool sendAddHintNotification(void) const
                 { return notificationHelper("hint", ""); }
-        
+
             /**
             @brief Sends a Notification displaying that a Quest was added.
@@ -106,5 +106,5 @@
             inline bool sendAddQuestNotification(void) const
                 { return notificationHelper("quest", "start"); }
-        
+
             /**
             @brief Sends a Notification displaying that a Quest was failed.
@@ -113,5 +113,5 @@
             inline bool sendFailQuestNotification(void) const
                 { return notificationHelper("quest", "fail"); }
-        
+
             /**
             @brief Sends a Notification displaying that a Quest was completed.
@@ -135,5 +135,5 @@
             inline void setTitle(const std::string & title)
                 { this->title_ = title; }
-                
+
             /**
             @brief Sets the description text.
@@ -149,5 +149,5 @@
             inline void setFailMessage(const std::string & message)
                 { this->failMessage_ = message; }
-                
+
             /**
             @brief Sets the complete message.
Index: code/branches/libraries/src/orxonox/objects/quest/QuestEffect.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestEffect.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestEffect.h	(revision 5648)
@@ -26,5 +26,5 @@
  *
  */
- 
+
 /**
     @file
@@ -35,5 +35,5 @@
 #define _QuestEffect_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <list>
@@ -49,5 +49,5 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport QuestEffect : public BaseObject
+    class _QuestExport QuestEffect : public BaseObject
     {
         public:
Index: code/branches/libraries/src/orxonox/objects/quest/QuestEffectBeacon.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestEffectBeacon.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestEffectBeacon.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _QuestEffectBeacon_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <list>
@@ -58,7 +58,7 @@
         A QuestEffectBeacon can be executed a defined number of times.
         A QuestEffectBeacon can be inactive or active.
-        
+
         Creating a QuestEffectBeacon through XML goes as follows:
-        
+
         <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.
             <effects>
@@ -79,16 +79,16 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport QuestEffectBeacon : public StaticEntity
+    class _QuestExport QuestEffectBeacon : public StaticEntity
     {
         public:
             QuestEffectBeacon(BaseObject* creator);
             virtual ~QuestEffectBeacon();
-            
+
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
-            
+
             virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
-            
+
             bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
-            
+
             /**
             @brief Tests whether the QuestEffectBeacon is active.
@@ -97,10 +97,10 @@
             inline bool isActive(void)
             { return this->status_ == QuestEffectBeaconStatus::Active; }
-            
+
             bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
-            
+
         protected:
             bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
-            
+
             /**
             @brief Returns the number of times the QUestEffectBeacon can still be executed.
@@ -109,17 +109,17 @@
             inline const int & getTimes(void) const
                 { return this->times_; }
-    
+
         private:
             static const int INFINITE_TIME = -1; //!< Constant to avoid using magic numbers.
-            
+
             std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
             int times_; //!< Number of times the beacon can be exectued.
             QuestEffectBeaconStatus::Value status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
-            
+
             bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
             bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
-            
+
             const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index.
-    
+
     };
 
Index: code/branches/libraries/src/orxonox/objects/quest/QuestHint.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestHint.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestHint.h	(revision 5648)
@@ -26,5 +26,5 @@
  *
  */
- 
+
 /**
     @file
@@ -35,5 +35,5 @@
 #define _QuestHint_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <map>
@@ -57,7 +57,7 @@
         Consists of title and description (which is stored in a QuestDescription object) in textual form and must belong to a quest.
         A QuestHint has a defined status (inactive or active, where inactive is default) for each player, which means each a QuestHint exists only once for all players, it doesn't belong to a player, it just has different states for each of them.
-        
+
         Creating a QuestHint through XML goes as follows:
-        
+
         <QuestHint id="hintId">  //Where hintId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
             <QuestDesctription title="" description="" />
@@ -66,5 +66,5 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport QuestHint : public QuestItem
+    class _QuestExport QuestHint : public QuestItem
     {
 
Index: code/branches/libraries/src/orxonox/objects/quest/QuestItem.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestItem.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestItem.h	(revision 5648)
@@ -26,5 +26,5 @@
  *
  */
- 
+
 /**
     @file
@@ -37,5 +37,5 @@
 #define _QuestItem_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <string>
@@ -51,5 +51,5 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport QuestItem : public BaseObject
+    class _QuestExport QuestItem : public BaseObject
     {
 
@@ -66,5 +66,5 @@
             inline const std::string & getId(void) const
                 { return this->id_; }
-            
+
             /**
             @brief Returns the QuestDescription of the QuestItem.
@@ -78,5 +78,5 @@
         protected:
             void setId(const std::string & id); //!< Sets the id of the QuestItem.
-            
+
             /**
             @brief Sets the description of the QuestItem.
Index: code/branches/libraries/src/orxonox/objects/quest/QuestListener.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestListener.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestListener.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _QuestListener_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <string>
@@ -58,8 +58,8 @@
     @brief
         Provides a way to react to the starting, completing and failing of Quests.
-        
+
         The XML representation goes as follows:
         You can use the QuestListener as if it were a Trigger or EventListener, that fires an Event when the status (depending on the set mode) of the given Quest changes.
-        
+
         <BaseObject> // The object that should react to the status change of a Quest.
             <events>
@@ -72,26 +72,26 @@
     Damian 'Mozork' Frick
     */
-    class _OrxonoxExport QuestListener : public BaseObject
+    class _QuestExport QuestListener : public BaseObject
     {
     public:
         QuestListener(BaseObject* creator);
         virtual ~QuestListener();
-        
+
         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestListener object through XML.
-        
+
         static void advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status); //!< Makes all QuestListener in the list aware that a certain status change has occured.
-        
+
         bool setQuestId(const std::string & id); //!< Sets the questId of the Quest the QuestListener reacts to.
         bool setMode(const std::string & mode); //!< Sets the mode of the QuestListener.
-        
+
         std::string getMode(void); //!< Get the mode of the QuestListener.
-        
-        const std::string & getQuestId(void);        
+
+        const std::string & getQuestId(void);
         bool execute(void); //!< Executes the QuestListener, resp. fires an Event.
-        
+
     private:
         QuestListenerMode::Value mode_; //!< The mode of the QuestListener.
         Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to.
-    
+
     };
 
Index: code/branches/libraries/src/orxonox/objects/quest/QuestManager.cc
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestManager.cc	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestManager.cc	(revision 5648)
@@ -36,4 +36,5 @@
 #include "util/Exception.h"
 #include "core/CoreIncludes.h"
+#include "core/GUIManager.h"
 
 #include "objects/infos/PlayerInfo.h"
@@ -64,5 +65,4 @@
     QuestManager::~QuestManager()
     {
-
     }
 
@@ -207,5 +207,5 @@
     QuestContainer* QuestManager::getQuestTree(std::string & name)
     {
-        PlayerInfo* player = this->players_[name];
+        PlayerInfo* player = GUIManager::getInstance().getPlayer(name);
         if(player == NULL)
         {
Index: code/branches/libraries/src/orxonox/objects/quest/QuestManager.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestManager.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestManager.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _QuestManager_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <list>
@@ -41,5 +41,5 @@
 #include <string>
 
-#include "util/Singleton.h"
+#include "util/ScopedSingleton.h"
 #include "core/OrxonoxClass.h"
 
@@ -66,4 +66,6 @@
     };
 
+    typedef ScopedSingleton<QuestManager, ScopeID::GSLevel> ScopedSingletonQuestManagerGSLevel; // workaround for tolua
+
     /**
     @brief
@@ -73,8 +75,8 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport QuestManager : public Singleton<QuestManager>, public orxonox::OrxonoxClass
+    class _QuestExport QuestManager : public ScopedSingletonQuestManagerGSLevel, public orxonox::OrxonoxClass
     {
 // tolua_end
-            friend class Singleton<QuestManager>;
+            friend class ScopedSingleton<QuestManager, ScopeID::GSLevel>;
         public:
             QuestManager();
@@ -82,5 +84,5 @@
 
             //! Returns a reference to the single instance of the Quest Manager.
-            static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
+            static QuestManager& getInstance() { return ScopedSingleton<QuestManager, ScopeID::GSLevel>::getInstance(); } // tolua_export
 
             bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager.
@@ -92,9 +94,4 @@
             QuestContainer* getQuestTree(std::string & name); // tolua_export
 
-            inline void setPlayer(const std::string& guiname, PlayerInfo* player)
-                { this->players_[guiname] = player; }
-            inline PlayerInfo* getPlayer(const std::string& guiname) const
-                { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; }
-
         private:
             static QuestManager* singletonPtr_s;
@@ -102,5 +99,4 @@
             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.
-            std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each gui
 
             void getRootQuests(const PlayerInfo* player, std::list<Quest*> & list);
Index: code/branches/libraries/src/orxonox/objects/quest/QuestNotification.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestNotification.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestNotification.h	(revision 5648)
@@ -30,5 +30,5 @@
 #define _QuestNotification_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <string>
@@ -43,5 +43,5 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport QuestNotification : public Notification
+    class _QuestExport QuestNotification : public Notification
     {
         public:
Index: code/branches/libraries/src/orxonox/objects/quest/QuestPrereqs.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestPrereqs.h	(revision 5648)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestPrereqs.h	(revision 5648)
@@ -0,0 +1,92 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _QuestsystemPrereqs_H__
+#define _QuestsystemPrereqs_H__
+
+#include "OrxonoxConfig.h"
+
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
+#  ifdef QUEST_SHARED_BUILD
+#    define _QuestExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _QuestExport
+#    else
+#      define _QuestExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _QuestExport  __attribute__ ((visibility("default")))
+#else
+#  define _QuestExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+    class AddQuest;
+    class AddQuestHint;
+    class AddReward;
+    class ChangeQuestStatus;
+    class CompleteQuest;
+    class FailQuest;
+    class GlobalQuest;
+    class LocalQuest;
+    class Quest;
+    class QuestDescription;
+    class QuestEffect;
+    class QuestEffectBeacon;
+    class QuestHint;
+    class QuestItem;
+    class QuestListener;
+    class QuestManager;
+    class QuestNotification;
+    class Rewardable;
+
+    class Notification;
+    class NotificationListener;
+    class NotificationManager;
+    class NotificationOverlay;
+    class NotificationQueue;
+}
+
+#endif /* _QuestsystemPrereqs_H__ */
Index: code/branches/libraries/src/orxonox/objects/quest/notifications/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/CMakeLists.txt	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/CMakeLists.txt	(revision 5648)
@@ -1,4 +1,6 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ADD_SOURCE_FILES(QUEST_SRC_FILES
   Notification.cc
   NotificationManager.cc
+  NotificationOverlay.cc
+  NotificationQueue.cc
 )
Index: code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _Notification_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <string>
@@ -49,5 +49,5 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport Notification : public BaseObject
+    class _QuestExport Notification : public BaseObject
     {
         public:
Index: code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h	(revision 5648)
@@ -35,5 +35,5 @@
 #define _NotificationManager_H__
 
-#include "OrxonoxPrereqs.h"
+#include "objects/quest/QuestPrereqs.h"
 
 #include <ctime>
@@ -41,5 +41,5 @@
 #include <string>
 
-#include "util/Singleton.h"
+#include "util/ScopedSingleton.h"
 #include "core/OrxonoxClass.h"
 
@@ -54,7 +54,7 @@
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
+    class _QuestExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID::GSLevel>, public OrxonoxClass
     {
-            friend class Singleton<NotificationManager>;
+            friend class ScopedSingleton<NotificationManager, ScopeID::GSLevel>;
         public:
             NotificationManager();
Index: code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.cc
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.cc	(revision 5648)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.cc	(revision 5648)
@@ -0,0 +1,136 @@
+/*
+ *   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:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of the NotificationOverlay class.
+*/
+
+#include "NotificationOverlay.h"
+
+#include "util/Exception.h"
+#include "core/CoreIncludes.h"
+#include "objects/quest/notifications/Notification.h"
+#include "NotificationQueue.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        Constructor. Intializes the class.
+    */
+    NotificationOverlay::NotificationOverlay(BaseObject* creator) : OverlayText(creator)
+    {
+        RegisterObject(NotificationOverlay);
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Constructor. Initializes the class creates a graphical representation of the input Notification for the input Queue.
+    @param queue
+        A pointer to the queue the NotificatonOverlay belongs to.
+    @param notification
+        A pointer to the Notification represented by this overlay.
+    @throws Argument
+        Throws an Argument-Exception if either no Notification or no NotificationQueue were input.
+    */
+    NotificationOverlay::NotificationOverlay(NotificationQueue* queue, Notification* notification) : OverlayText(NULL)
+    {
+        this->initialize();
+
+        if(notification == NULL || queue == NULL) //!> If either notification or queue are not given an Exception is thrown.
+        {
+            ThrowException(Argument, "There were NULL-Pointer arguments in NotificationOverlay creation.");
+        }
+
+        this->queue_ = queue;
+        this->defineOverlay();
+
+        this->processNotification(notification);
+    }
+
+    /**
+    @brief
+        Initializes and Registers the object.
+    */
+    void NotificationOverlay::initialize(void)
+    {
+        this->queue_ = NULL;
+    }
+
+    /**
+    @brief
+        Set some Overlay-specific values.
+    */
+    void NotificationOverlay::defineOverlay(void)
+    {
+        this->setFont(this->queue_->getFont());
+        this->setTextSize(this->queue_->getFontSize());
+
+        this->setPosition(this->queue_->getPosition());
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    NotificationOverlay::~NotificationOverlay()
+    {
+    }
+
+    /**
+    @brief
+        Processes the input notification, resp. sees to it. that the NotificationOverlay displays the Notification message.
+    @param notification
+        A pointer to the notification that should be processed.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationOverlay::processNotification(Notification* notification)
+    {
+        if(notification == NULL)
+            return false;
+        this->setCaption(clipMessage(notification->getMessage()));
+        this->notification_ = notification;
+        return true;
+    }
+
+    /**
+    @brief
+        Clips the input message so that it meets the requirements for the maximal length of Notifications given by the NotificationQueue.
+    */
+    std::string NotificationOverlay::clipMessage(const std::string & message)
+    {
+        if(message.length() <= static_cast<unsigned int>(this->queue_->getNotificationLength())) //!< If the message is not too long.
+            return message;
+        return message.substr(0, this->queue_->getNotificationLength());
+    }
+
+}
Index: code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.h	(revision 5648)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationOverlay.h	(revision 5648)
@@ -0,0 +1,83 @@
+/*
+ *   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:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Definition of the NotificationOverlay class.
+*/
+
+
+#ifndef _NotificationOverlay_H__
+#define _NotificationOverlay_H__
+
+#include "objects/quest/QuestPrereqs.h"
+
+#include <string>
+#include "orxonox/overlays/OverlayText.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        The NotificationOverlay is used to display single Notifications, then bundled in a NotificationQUeue.
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _QuestExport NotificationOverlay : public OverlayText
+    {
+
+        public:
+            NotificationOverlay(BaseObject* creator);
+            NotificationOverlay(NotificationQueue* queue, Notification* notification);
+            virtual ~NotificationOverlay();
+
+            bool processNotification(Notification* notification); //!< Processes the input Notification.
+
+            /**
+            @brief Sets the font size of this overlay's text.
+            @param size The font size.
+            */
+            inline void setFontSize(float size)
+                { this->setTextSize(size); }
+
+        protected:
+            std::string clipMessage(const std::string & message); //!< Clips the input message if too long.
+
+        private:
+            NotificationQueue* queue_; //!< The NotificationQeue this overlay belongs to.
+            Notification* notification_; //!< The Notification this overlay displays.
+
+            void initialize(void); //!< Initializes the object.
+            void defineOverlay(void); //!< Sets some overlay-specific values.
+
+    };
+
+}
+
+#endif /* _NotificationOverlay_H__ */
Index: code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.cc
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.cc	(revision 5648)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.cc	(revision 5648)
@@ -0,0 +1,449 @@
+/*
+ *   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:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of the NotificationQueue class.
+*/
+
+#include "NotificationQueue.h"
+
+#include <sstream>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "NotificationOverlay.h"
+#include "objects/quest/notifications/NotificationManager.h"
+
+namespace orxonox
+{
+
+    CreateFactory(NotificationQueue);
+
+    const std::string NotificationQueue::DEFAULT_FONT = "VeraMono";
+    const Vector2 NotificationQueue::DEFAULT_POSITION = Vector2(0.0,0.0);
+    const float NotificationQueue::DEFAULT_FONT_SIZE  = 0.025f;
+
+    /**
+    @brief
+        Constructor. Creates and initializes the object.
+    */
+    NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayGroup(creator)
+    {
+        RegisterObject(NotificationQueue);
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    NotificationQueue::~NotificationQueue()
+    {
+        this->targets_.clear();
+        this->clear();
+    }
+
+    /**
+    @brief
+        Initializes the object.
+        Registers the object, initializes variables, sets default values and registers the queue with the NotificationManager.
+    */
+    void NotificationQueue::initialize(void)
+    {
+        this->size_ = 0;
+        this->tickTime_ = 0.0;
+
+        NotificationManager::getInstance().registerListener(this);
+    }
+
+    /**
+    @brief
+        Sets the defaults.
+    */
+    void NotificationQueue::setDefaults(void)
+    {
+        this->setMaxSize(DEFAULT_SIZE);
+        this->setNotificationLength(DEFAULT_LENGTH);
+        this->setDisplayTime(DEFAULT_DISPLAY_TIME);
+        this->setPosition(DEFAULT_POSITION);
+
+        this->setTargets(NotificationManager::ALL);
+
+        this->setFontSize(DEFAULT_FONT_SIZE);
+        this->setFont(DEFAULT_FONT);
+    }
+
+    /**
+    @brief
+        Method for creating a NotificationQueue object through XML.
+    */
+    void NotificationQueue::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(NotificationQueue, XMLPort, xmlElement, mode);
+
+        this->setDefaults();
+
+        XMLPortParam(NotificationQueue, "maxSize", setMaxSize, getMaxSize, xmlElement, mode);
+        XMLPortParam(NotificationQueue, "notificationLength", setNotificationLength, getNotificationLength, xmlElement, mode);
+        XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlElement, mode);
+        XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlElement, mode);
+        XMLPortParam(NotificationQueue, "font", setFont, getFont, xmlElement, mode);
+        XMLPortParam(NotificationQueue, "fontSize", setFontSize, getFontSize, xmlElement, mode);
+        XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode);
+
+        COUT(3) << "NotificationQueue created." << std::endl;
+    }
+
+    /**
+    @brief
+        Updates the queue from time to time.
+    @param dt
+        The time interval that has passed since the last tick.
+    */
+    void NotificationQueue::tick(float dt)
+    {
+        this->tickTime_ += dt; //!< Add the time interval that has passed to the time counter.
+        if(this->tickTime_ >= 1.0) //!< If the time counter is greater than 1s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
+        {
+            this->timeLimit_.time = std::time(0)-this->displayTime_; //!< Container containig the current time.
+
+            std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it;
+            it = this->containers_.begin();
+            while(it != this->containers_.upper_bound(&this->timeLimit_)) //!< Iterate through all elements whose creation time is smaller than the current time minus the display time.
+            {
+                this->removeContainer(*it);
+                this->scroll(Vector2(0.0,-(1.1*this->getFontSize())));
+                it = this->containers_.begin(); //TDO: Needed?
+            }
+
+            this->tickTime_ = 0.0; //!< Reset time counter.
+        }
+    }
+
+    /**
+    @brief
+        Updates the NotificationQueue.
+        Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting the in the queue.
+    */
+    void NotificationQueue::update(void)
+    {
+        this->clear();
+
+        std::multimap<std::time_t,Notification*>* notifications = new std::multimap<std::time_t,Notification*>;
+        if(!NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_)) //!< Get the Notifications sent in the interval form now to minus the display time.
+        {
+            COUT(1) << "NotificationQueue update failed due to undetermined cause." << std::endl;
+            return;
+        }
+
+        if(notifications->empty())
+            return;
+
+        for(std::multimap<std::time_t,Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) //!> Add all Notifications.
+        {
+            this->addNotification(it->second, it->first);
+        }
+
+        delete notifications;
+
+        COUT(3) << "NotificationQueue updated." << std::endl;
+    }
+
+    /**
+    @brief
+        Updates the NotificationQueue by adding an new Notification.
+    @param notification
+        Pointer to the Notification.
+    @param time
+        The time the Notification was sent.
+    */
+    void NotificationQueue::update(Notification* notification, const std::time_t & time)
+    {
+        this->addNotification(notification, time);
+
+        std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it;
+        while(this->getSize() > this->getMaxSize())
+        {
+            it = this->containers_.begin();
+            this->removeContainer(*it);
+            this->scroll(Vector2(0.0,-(1.1*this->getFontSize())));
+        }
+
+        COUT(3) << "NotificationQueue updated. A new Notifications has been added." << std::endl;
+    }
+
+    /**
+    @brief
+        Sets the maximum number of displayed Notifications.
+    @param size
+        The size to be set.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::setMaxSize(int size)
+    {
+        if(size < 0)
+            return false;
+        this->maxSize_ = size;
+        this->update();
+        return true;
+    }
+
+    /**
+    @brief
+        Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
+    @param length
+        The length to be set.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::setNotificationLength(int length)
+    {
+        if(length < 0)
+            return false;
+        this->notificationLength_ = length;
+        this->update();
+        return true;
+    }
+
+    /**
+    @brief
+        Sets the maximum number of seconds a Notification is displayed.
+    @param time
+        The number of seconds the Notifications is displayed.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::setDisplayTime(int time)
+    {
+        if(time < 0)
+            return false;
+        this->displayTime_ = time;
+        this->update();
+        return true;
+    }
+
+    /**
+    @brief
+        Produces all targets concatinated as string, with kommas (',') as seperators.
+    @param string
+        Pointer to a string which will be used by the method to fill with the concatination of the targets.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::getTargets(std::string* string) const
+    {
+        if(string == NULL)
+        {
+            COUT(4) << "Input string must have memory allocated." << std::endl;
+            return false;
+        }
+        string->clear();
+        bool first = true;
+        for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) //!< Iterate through the set of targets.
+        {
+            if(!first)
+            {
+                *string += ",";
+            }
+            else
+            {
+                first = false;
+            }
+            *string += *it;
+        }
+
+        return true;
+    }
+
+    /**
+    @brief
+        Sets the targets of the queue.
+        The targets are the senders whose Notifications are displayed in this queue.
+    @param targets
+        Accepts a string of targets, each seperated by commas (','), spaces are ignored.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::setTargets(const std::string & targets)
+    {
+        this->targets_.clear();
+
+        std::string* pTemp;
+        unsigned int index = 0;
+        while( index < targets.size() ) //!< Go through the string, character by character until the end is reached.
+        {
+            pTemp = new std::string("");
+            while(index < targets.size() && targets[index] != ',' && targets[index] != ' ')
+            {
+                *pTemp += targets[index];
+                index++;
+            }
+            index++;
+            this->targets_.insert(*pTemp);
+        }
+
+        return true;
+    }
+
+    /**
+    @brief
+        Sets the font size.
+    @param size
+        The font size.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::setFontSize(float size)
+    {
+        if(size <= 0)
+            return false;
+        this->fontSize_ = size;
+        for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); it++) //!< Set the font size for each overlay.
+        {
+            it->second->overlay->setFontSize(size);
+        }
+        return true;
+    }
+
+    /**
+    @brief
+        Sets the font.
+    @param font
+        The font.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::setFont(const std::string & font)
+    {
+        this->font_ = font;
+        for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); it++) //!< Set the font for each overlay.
+        {
+            it->second->overlay->setFont(font);
+        }
+        return true;
+    }
+
+    /**
+    @brief
+        Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
+    @param pos
+        The vector the NotificationQueue is scrolled.
+    */
+    void NotificationQueue::scroll(const Vector2 pos)
+    {
+        for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); ++it) //!< Scroll each overlay.
+        {
+            it->second->overlay->scroll(pos);
+        }
+    }
+
+    /**
+    @brief
+        Aligns all the Notifications to the position of the NotificationQueue.
+    */
+    void NotificationQueue::positionChanged(void)
+    {
+        int counter = 0;
+        for (std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it = this->containers_.begin(); it != this->containers_.end(); it++) //!< Set the position for each overlay.
+        {
+            (*it)->overlay->setPosition(this->getPosition());
+            (*it)->overlay->scroll(Vector2(0.0,(1.1*this->getFontSize())*counter));
+            counter++;
+        }
+    }
+
+    /**
+    @brief
+        Adds a Notification, to the queue.
+        It inserts it into the storage containers, creates an corresponding overlay and a container.
+    @param notification
+        The Notification.
+    @param time
+        The time.
+    */
+    void NotificationQueue::addNotification(Notification* notification, const std::time_t & time)
+    {
+        NotificationOverlayContainer* container = new NotificationOverlayContainer;
+        container->overlay = new NotificationOverlay(this, notification);
+        container->notification = notification;
+        container->time = time;
+        std::string timeString = std::ctime(&time);
+        timeString.erase(timeString.length()-1);
+        std::ostringstream stream;
+        stream << reinterpret_cast<unsigned long>(notification);
+        std::string addressString = stream.str() ;
+        container->name = "NotificationOverlay(" + timeString + ")&" + addressString;
+
+        this->containers_.insert(container);
+        this->overlays_[notification] = container;
+        this->addElement(container->overlay);
+        this->size_= this->size_+1;
+
+        container->overlay->scroll(Vector2(0.0,(1.1*this->getFontSize())*(this->getSize()-1)));
+    }
+
+    /**
+    @brief
+        Removes a container from the queue.
+    @param container
+        A pointer to the container.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::removeContainer(NotificationOverlayContainer* container)
+    {
+        if(this->size_ == 0) //!< You cannot remove anything if the queue is empty.
+            return false;
+
+        this->removeElement(container->overlay);
+        this->containers_.erase(container);
+        this->overlays_.erase(container->notification);
+        delete container->overlay;
+        delete container;
+        this->size_= this->size_-1;
+
+        return true;
+    }
+
+    /**
+    @brief
+        Clears the queue by removing all containers.
+    */
+    void NotificationQueue::clear(void)
+    {
+        std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it = this->containers_.begin();
+        while(it != this->containers_.end())
+        {
+            this->removeContainer(*it);
+            it = this->containers_.begin(); //TDO: Needed?
+        }
+    }
+
+}
Index: code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.h	(revision 5648)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationQueue.h	(revision 5648)
@@ -0,0 +1,210 @@
+/*
+ *   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:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Definition of the NotificationQueue class.
+*/
+
+#ifndef _NotificationOueue_H__
+#define _NotificationOueue_H__
+
+#include "objects/quest/QuestPrereqs.h"
+
+#include <ctime>
+#include <map>
+#include <set>
+#include <string>
+
+#include "util/Math.h"
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayGroup.h"
+#include "interfaces/NotificationListener.h"
+
+namespace orxonox
+{
+
+    //! Container to allow easy handling.
+    struct NotificationOverlayContainer
+    {
+        NotificationOverlay* overlay; //!< Pointer to the NotificationOverlay, everything is about.
+        Notification* notification; //!< The Notification displayed by the overlay.
+        time_t time; //!< The time the Notification was sent and thus first displayed.
+        std::string name; //!< The name of the overlay.
+    };
+
+    //! Struct to allow ordering of NotificationOverlayContainers.
+    struct NotificationOverlayContainerCompare {
+        bool operator() (const NotificationOverlayContainer* const & a, const NotificationOverlayContainer* const & b) const
+            { return a->time < b->time; } //!< Ordered by time.
+    };
+
+    /**
+    @brief
+        Displays Notifications from specific senders.
+        Beware! The NotificationQueue is an OverlayGruop and thus cannot be be a sub-element of an OverlayGroup (at least no for now.)
+
+        Creating a NotificationQueue through XML goes as follows:
+        <NotificationQueue
+            name = "SuperQueue" //Name of your OverlayQueue.
+            maxSize = "5" //The maximum size of Notifications displayed.
+            notificationLength = "64" //The maximum number of characters of a Notification, that are displayed. (Default is 5)
+            displayTime = "30" //The time a Notification is displayed in seconds. (Default is 30)
+            targets = "target1, target2" //The senders this NotificationQueue displays Notifications from. (all, if all Notifications should be displayed.)
+            font = "VeraMono" //The font (Default is VeraMono)
+            fontSize = '0.4' //The font size. (Default is 0.025)
+            position = "0.0, .0.0" //The position of the NotificationQueue. (Default is 0.0,0.0)
+        />
+    @author
+        Damian 'Mozork' Frick
+    */
+
+    class _QuestExport NotificationQueue : public OverlayGroup, public Tickable, public NotificationListener
+    {
+
+        public:
+            NotificationQueue(BaseObject* creator);
+            virtual ~NotificationQueue();
+
+            virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML.
+
+            virtual void tick(float dt); //!< To update from time to time.
+
+            void update(void); //!< Updates the queue.
+            void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue.
+
+            /**
+            @brief Returns the maximum number of Notifications displayed.
+            @return Returns maximum size.
+            */
+            inline int getMaxSize() const
+                { return this->maxSize_; }
+            /**
+            @brief Returns the current number of Notifications displayed.
+            @return Returns the size of the queue.
+            */
+            inline int getSize() const
+                { return this->size_; }
+            /**
+            @brief Returns the maximum length in characters a Notification message is allowed to have.
+            @return Returns the maximum Notification length.
+            */
+            inline int getNotificationLength() const
+                { return this->notificationLength_; }
+            /**
+            @brief Returns the time interval the Notification is displayed.
+            @return Returns the display time.
+            */
+            inline int getDisplayTime() const
+                { return this->displayTime_; }
+            /**
+            @brief Returns the position of the NotificationQueue.
+            @return Returns the position.
+            */
+            inline const Vector2 & getPosition() const
+                { return this->position_; }
+            /**
+            @brief Returns the font size used to display the Notifications.
+            @return  Returns the font size.
+            */
+            inline float getFontSize() const
+                { return this->fontSize_; }
+            /**
+            @brief Returns the font used to display the Notifications.
+            @return Returns the font.
+            */
+            inline const std::string & getFont() const
+                { return this->font_; }
+
+            /**
+            @brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.
+            @return Retuns a set of string holding the different targets.
+            */
+            inline const std::set<std::string> & getTargetsSet()
+                { return this->targets_; }
+            bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
+
+            /**
+            @brief Sets the position of the NotificationQueue.
+            @param pos The position.
+            */
+            inline void setPosition(Vector2 pos)
+                { this->position_ = pos; this->positionChanged(); }
+
+            void scroll(const Vector2 pos); //!< Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
+
+        private:
+            static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
+            static const int DEFAULT_LENGTH = 64; //!< The default maximum number of Notifications displayed.
+            static const int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
+            static const float DEFAULT_FONT_SIZE; //!< The default font size.
+
+            static const std::string DEFAULT_FONT; //!< The default font.
+            static const Vector2 DEFAULT_POSITION; //!< the default position.
+
+            int maxSize_; //!< The maximal number of Notifications displayed.
+            int size_; //!< The number of Notifications displayed.
+            int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.
+            int displayTime_; //!< The time a Notification is displayed.
+            Vector2 position_; //!< The position of the NotificationQueue.
+
+            std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
+
+            float fontSize_; //!< The font size.
+            std::string font_; //!< The font.
+
+            std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps.
+            std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding.
+
+            float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick.
+            NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
+
+            void initialize(void); //!< Initializes the object.
+            void setDefaults(void); //!< Helper method to set the default values.
+
+            bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications.
+            bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
+            bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
+
+            bool setTargets(const std::string & targets); //!< Set the targets of this queue.
+
+            bool setFontSize(float size); //!< Set the font size.
+            bool setFont(const std::string & font); //!< Set the font.
+
+            void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
+
+            void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.
+            bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue.
+
+            void clear(void); //!< Clear the queue.
+
+    };
+
+}
+
+#endif /* _NotificationOverlay_H__ */
Index: code/branches/libraries/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/overlays/CMakeLists.txt	(revision 5643)
+++ code/branches/libraries/src/orxonox/overlays/CMakeLists.txt	(revision 5648)
@@ -12,5 +12,4 @@
 ADD_SUBDIRECTORY(debug)
 ADD_SUBDIRECTORY(hud)
-ADD_SUBDIRECTORY(notifications)
 ADD_SUBDIRECTORY(stats)
 
Index: code/branches/libraries/src/orxonox/overlays/GUIOverlay.cc
===================================================================
--- code/branches/libraries/src/orxonox/overlays/GUIOverlay.cc	(revision 5643)
+++ code/branches/libraries/src/orxonox/overlays/GUIOverlay.cc	(revision 5648)
@@ -36,5 +36,4 @@
 #include "core/GUIManager.h"
 #include "core/XMLPort.h"
-#include "objects/quest/QuestManager.h"
 #include "objects/infos/PlayerInfo.h"
 
@@ -84,5 +83,5 @@
     {
         this->guiName_ = name;
-        QuestManager::getInstance().setPlayer(name, orxonox_cast<PlayerInfo*>(this->getOwner()));
+        GUIManager::getInstance().setPlayer(name, orxonox_cast<PlayerInfo*>(this->getOwner()));
     }
 }
Index: code/branches/libraries/src/orxonox/overlays/OverlaysPrereqs.h
===================================================================
--- code/branches/libraries/src/orxonox/overlays/OverlaysPrereqs.h	(revision 5643)
+++ code/branches/libraries/src/orxonox/overlays/OverlaysPrereqs.h	(revision 5648)
@@ -72,9 +72,4 @@
     class HUDHealthBar;
     class HUDTimer;
-    class Notification;
-    class NotificationListener;
-    class NotificationManager;
-    class NotificationOverlay;
-    class NotificationQueue;
     class OrxonoxOverlay;
     class OverlayGroup;
