[Orxonox-commit 80] r2779 - in branches/questsystem5/src/orxonox: . objects/quest overlays overlays/notifications

dafrick at orxonox.net dafrick at orxonox.net
Thu Mar 12 17:13:35 CET 2009


Author: dafrick
Date: 2009-03-12 16:13:34 +0000 (Thu, 12 Mar 2009)
New Revision: 2779

Added:
   branches/questsystem5/src/orxonox/objects/quest/QuestNotification.cc
   branches/questsystem5/src/orxonox/objects/quest/QuestNotification.h
   branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.cc
   branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.h
Modified:
   branches/questsystem5/src/orxonox/OrxonoxPrereqs.h
   branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc
   branches/questsystem5/src/orxonox/objects/quest/AddQuest.h
   branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.cc
   branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.h
   branches/questsystem5/src/orxonox/objects/quest/AddReward.cc
   branches/questsystem5/src/orxonox/objects/quest/AddReward.h
   branches/questsystem5/src/orxonox/objects/quest/CMakeLists.txt
   branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.cc
   branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.h
   branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.cc
   branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.h
   branches/questsystem5/src/orxonox/objects/quest/FailQuest.cc
   branches/questsystem5/src/orxonox/objects/quest/FailQuest.h
   branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.cc
   branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.h
   branches/questsystem5/src/orxonox/objects/quest/LocalQuest.cc
   branches/questsystem5/src/orxonox/objects/quest/LocalQuest.h
   branches/questsystem5/src/orxonox/objects/quest/Quest.cc
   branches/questsystem5/src/orxonox/objects/quest/Quest.h
   branches/questsystem5/src/orxonox/objects/quest/QuestDescription.cc
   branches/questsystem5/src/orxonox/objects/quest/QuestDescription.h
   branches/questsystem5/src/orxonox/objects/quest/QuestEffect.cc
   branches/questsystem5/src/orxonox/objects/quest/QuestEffect.h
   branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.cc
   branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.h
   branches/questsystem5/src/orxonox/objects/quest/QuestHint.cc
   branches/questsystem5/src/orxonox/objects/quest/QuestHint.h
   branches/questsystem5/src/orxonox/objects/quest/QuestItem.cc
   branches/questsystem5/src/orxonox/objects/quest/QuestItem.h
   branches/questsystem5/src/orxonox/objects/quest/QuestListener.cc
   branches/questsystem5/src/orxonox/objects/quest/QuestListener.h
   branches/questsystem5/src/orxonox/objects/quest/QuestManager.cc
   branches/questsystem5/src/orxonox/objects/quest/QuestManager.h
   branches/questsystem5/src/orxonox/objects/quest/Rewardable.cc
   branches/questsystem5/src/orxonox/objects/quest/Rewardable.h
   branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc
   branches/questsystem5/src/orxonox/overlays/OverlayGroup.h
   branches/questsystem5/src/orxonox/overlays/notifications/CMakeLists.txt
   branches/questsystem5/src/orxonox/overlays/notifications/Notification.cc
   branches/questsystem5/src/orxonox/overlays/notifications/Notification.h
   branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.cc
   branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.h
   branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc
   branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.h
Log:
Updated questsystem to current trunk. Synchronized it with my local state of things. The Notifications are not yet working, though.

Modified: branches/questsystem5/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- branches/questsystem5/src/orxonox/OrxonoxPrereqs.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/OrxonoxPrereqs.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -128,6 +128,7 @@
     class QuestItem;
     class QuestListener;
     class QuestManager;
+    class QuestNotification;
     class Rewardable;
 
     class WorldEntity;
@@ -226,6 +227,7 @@
     class InGameConsole;
     class Notification;
     class NotificationManager;
+    class NotificationOverlay;
     class NotificationQueue;
     class OrxonoxOverlay;
     class OverlayGroup;

Modified: branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file AddQuest.cc
     @brief Implementation of the AddQuest class.
 */
 
@@ -41,6 +41,7 @@
 
 #include "orxonox/objects/infos/PlayerInfo.h"
 #include "QuestManager.h"
+#include "QuestDescription.h";
 #include "Quest.h"
 
 namespace orxonox

Modified: branches/questsystem5/src/orxonox/objects/quest/AddQuest.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/AddQuest.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/AddQuest.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file AddQuest.h
     @brief Definition of the AddQuest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file AddQuestHint.cc
     @brief Implementation of the AddQuestHint class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file AddQuestHint.h
     @brief Definition of the AddQuestHint class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/AddReward.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/AddReward.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/AddReward.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file AddReward.cc
     @brief Implementation of the AddReward class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/AddReward.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/AddReward.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/AddReward.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file AddReward.h
     @brief Definition of the AddReward class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/CMakeLists.txt
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/CMakeLists.txt	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/CMakeLists.txt	2009-03-12 16:13:34 UTC (rev 2779)
@@ -15,5 +15,6 @@
   QuestItem.cc
   QuestListener.cc
   QuestManager.cc
+  QuestNotification.cc
   Rewardable.cc
 )

Modified: branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file ChangeQuestStatus.cc
     @brief Implementation of the ChangeQuestStatus class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file ChangeQuestStatus.h
     @brief Definition of the ChangeQuestStatus class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file CompleteQuest.cc
     @brief Implementation of the CompleteQuest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file CompleteQuest.h
     @brief Definition of the CompleteQuest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/FailQuest.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/FailQuest.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/FailQuest.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file FailQuest.cc
     @brief Implementation of the FailQuest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/FailQuest.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/FailQuest.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/FailQuest.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file FailQuest.h
     @brief Definition of the FailQuest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file GlobalQuest.cc
     @brief Implementation of the GlobalQuest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file GlobalQuest.h
     @brief Definition of the GlobalQuest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/LocalQuest.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/LocalQuest.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/LocalQuest.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file LocalQuest.cc
     @brief Implementation of the LocalQuest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/LocalQuest.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/LocalQuest.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/LocalQuest.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file LocalQuest.h
     @brief Definition of the LocalQuest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/Quest.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/Quest.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/Quest.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file Quest.cc
     @brief Implementation of the Quest class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/Quest.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/Quest.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/Quest.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file Quest.h
     @brief Definition of the Quest class.
         The Quest is the parent class of LocalQuest and GlobalQuest.
 */

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestDescription.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestDescription.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestDescription.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file QuestDescription.cc
     @brief Implementation of the QuestDescription class.
 */
 
@@ -36,7 +36,7 @@
 #include "QuestDescription.h"
 
 #include "core/CoreIncludes.h"
-#include "orxonox/overlays/notifications/Notification.h"
+#include "QuestNotification.h"
 
 namespace orxonox
 {
@@ -88,32 +88,29 @@
         The status the QuestDescription us for.
     @return
         Returns true if successful.
+    @todo
+        Make sure the messages meet the conditions.
     */
     bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const
     {
         std::string message = "";
-        std::string title = "";
         if(item == "hint")
         {
-            title = "You received a hint: '" + this->title_ + "'";
-            message = this->description_;
+            message = "You received a hint: '" + this->title_ + "'";
         }
         else if(item == "quest")
         {
             if(status == "start")
             {
-                title = "You received a new quest: '" + this->title_ + "'";
-                message = this->description_;
+                message = "You received a new quest: '" + this->title_ + "'";
             }
             else if(status == "fail")
             {
-                title = "You failed the quest: '" + this->title_ + "'";
-                message = this->failMessage_;
+                message = "You failed the quest: '" + this->title_ + "'";
             }
             else if(status == "complete")
             {
-                title = "You successfully completed the quest: '" + this->title_ + "'";
-                message = this->completeMessage_;
+                message = "You successfully completed the quest: '" + this->title_ + "'";
             }
             else
             {
@@ -127,7 +124,7 @@
             return false;
         }
         
-        Notification* notification = new Notification(0, message, title, 30);
+        QuestNotification* notification = new QuestNotification(message);
         notification->send();
         return true;
     }

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestDescription.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestDescription.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestDescription.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file QuestDescription.h
     @brief Definition of the QuestDescription class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestEffect.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestEffect.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestEffect.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file QuestEffect.cc
     @brief Implementation of the QuestEffect class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestEffect.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestEffect.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestEffect.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file QuestEffect.h
     @brief Definition of the QuestEffect class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file QuestEffectBeacon.cc
     @brief Implementation of the QuestEffectBeacon class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file QuestEffectBeacon.h
     @brief Definition of the QuestEffectBeacon class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestHint.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestHint.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestHint.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file QuestHint.cc
     @brief Implementation of the QuestHint class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestHint.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestHint.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestHint.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file QuestHint.h
     @brief Definition of the QuestHint class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestItem.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestItem.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestItem.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file QuestItem.cc
     @brief Implementation of the QuestItem class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestItem.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestItem.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestItem.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
  
 /**
-    @file
+    @file QuestItem.h
     @brief Definition of the QuestItem class.
         The QuestItem is the parent class of Quest and QuestHint.
 */

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestListener.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestListener.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestListener.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file QuestListener.cc
     @brief Implementation of the QuestListener class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestListener.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestListener.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestListener.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file QuestListener.h
     @brief Definition of the QuestListener class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestManager.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestManager.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestManager.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file QuestManager.cc
     @brief Implementation of the QuestManager class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/QuestManager.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestManager.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestManager.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file QuestManager.h
     @brief Definition of the QuestManager class.
 */
 

Added: branches/questsystem5/src/orxonox/objects/quest/QuestNotification.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestNotification.cc	                        (rev 0)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestNotification.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -0,0 +1,66 @@
+/*
+ *   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 thes
+ *   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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "QuestNotification.h"
+
+#include "core/CoreIncludes.h"
+
+#include "orxonox/overlays/notifications/Notification.h"
+
+namespace orxonox {
+
+    const std::string QuestNotification::SENDER = "questsystem";
+
+    QuestNotification::QuestNotification(BaseObject* creator) : Notification(creator)
+    {
+        this->initialize();
+    }
+    
+    QuestNotification::QuestNotification(const std::string & message) : Notification(message)
+    {
+        this->initialize();
+    }
+    
+    QuestNotification::~QuestNotification()
+    {
+        
+    }
+
+    bool QuestNotification::send(void)
+    {
+        return this->Notification::send(QuestNotification::SENDER);
+    }
+
+    void QuestNotification::initialize(void)
+    {
+        RegisterObject(QuestNotification);
+    }
+
+
+}


Property changes on: branches/questsystem5/src/orxonox/objects/quest/QuestNotification.cc
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/questsystem5/src/orxonox/objects/quest/QuestNotification.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/QuestNotification.h	                        (rev 0)
+++ branches/questsystem5/src/orxonox/objects/quest/QuestNotification.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -0,0 +1,64 @@
+/*
+ *   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 thes
+ *   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:
+ *      ...
+ *
+ */
+ 
+#ifndef _QuestNotification_H__
+#define _QuestNotification_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include "orxonox/overlays/notifications/Notification.h"
+
+namespace orxonox {
+
+    /**
+    @brief
+        
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport QuestNotification : public Notification
+    {
+        public:
+            QuestNotification(BaseObject* creator);
+            QuestNotification(const std::string & message);
+            virtual ~QuestNotification();
+            
+            bool send(void);
+     
+        private:
+            static const std::string SENDER;
+            
+            void initialize(void);
+ 
+    };
+
+}
+
+#endif /* _QuestNotification_H__ */


Property changes on: branches/questsystem5/src/orxonox/objects/quest/QuestNotification.h
___________________________________________________________________
Added: svn:executable
   + *

Modified: branches/questsystem5/src/orxonox/objects/quest/Rewardable.cc
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/Rewardable.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/Rewardable.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file Rewardable.cc
     @brief Implementation of the Rewardable class.
 */
 

Modified: branches/questsystem5/src/orxonox/objects/quest/Rewardable.h
===================================================================
--- branches/questsystem5/src/orxonox/objects/quest/Rewardable.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/objects/quest/Rewardable.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -27,7 +27,7 @@
  */
 
 /**
-    @file
+    @file Rewardable.h
     @brief Definition of the Rewardable class.
 */
 

Modified: branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -106,19 +106,50 @@
     */
     void OverlayGroup::addElement(OrxonoxOverlay* element)
     {
-        if (hudElements_.find(element->getName()) != hudElements_.end())
+        this->insertElement(element, element->getName());
+    }
+
+	/**
+    @brief
+        Adds an element to the map.
+    @param element
+        The element to be added.
+    @param name
+        The name of the element.
+    @remarks
+        The names of the OrxonoxOverlays have to be unique!
+    */
+    void OverlayGroup::insertElement(OrxonoxOverlay* element, const std::string & name)
+    {
+        element->setName(name);
+        if (hudElements_.find(name) != hudElements_.end())
         {
             COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl;
         }
         else
         {
-            hudElements_[element->getName()] = element;
+            hudElements_[name] = element;
             element->setVisible(this->isVisible());
-            if (this->owner_)
+			if (this->owner_)
                 element->setOwner(this->owner_);
         }
     }
 
+	/**
+    @brief
+        Removes an element from the map.
+    @param name
+        The name of the element that is removed.
+    @return
+        Returns true if there was such an element to remove, false if not.
+    */
+    bool OverlayGroup::removeElement(const std::string & name)
+    {
+        if(this->hudElements_.erase(name) == 0)
+            return false;
+        return true;
+    }
+
     //! Returns a different element as long as index < hudElements_.size().
     OrxonoxOverlay* OverlayGroup::getElement(unsigned int index)
     {

Modified: branches/questsystem5/src/orxonox/overlays/OverlayGroup.h
===================================================================
--- branches/questsystem5/src/orxonox/overlays/OverlayGroup.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/overlays/OverlayGroup.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -85,6 +85,8 @@
         Vector2 getScroll() const { return this->scale_; }
 
         void addElement(OrxonoxOverlay* element);
+		void insertElement(OrxonoxOverlay* element, const std::string & name);
+        bool removeElement(const std::string & name);
         OrxonoxOverlay* getElement(unsigned int index);
 
     private:

Modified: branches/questsystem5/src/orxonox/overlays/notifications/CMakeLists.txt
===================================================================
--- branches/questsystem5/src/orxonox/overlays/notifications/CMakeLists.txt	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/overlays/notifications/CMakeLists.txt	2009-03-12 16:13:34 UTC (rev 2779)
@@ -1,5 +1,6 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Notification.cc
   NotificationManager.cc
+  NotificationOverlay.cc
   NotificationQueue.cc
 )

Modified: branches/questsystem5/src/orxonox/overlays/notifications/Notification.cc
===================================================================
--- branches/questsystem5/src/orxonox/overlays/notifications/Notification.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/overlays/notifications/Notification.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -26,77 +26,109 @@
  *
  */
 
+/**
+    @file Notification.cc
+    @brief Implementation of the Notification class.
+*/
+
 #include "OrxonoxStableHeaders.h"
 #include "Notification.h"
 
 #include "core/CoreIncludes.h"
+#include "util/Exception.h"
 
 #include "NotificationManager.h"
 
 namespace orxonox
 {
+
+    /**
+    @brief
+        Default constructor. Initializes the object.
+    */
     Notification::Notification(BaseObject* creator) : BaseObject(creator)
     {
-        RegisterObject(Notification);
+        this->initialize();
     }
     
-    Notification::Notification(BaseObject* creator, const std::string & message, const std::string & title, float time) : BaseObject(creator)
+    /**
+    @brief
+        Constructor. Creates a Notification with the input message.
+    @param message
+        The message of the Notification.
+    */
+    Notification::Notification(const std::string & message) : BaseObject(this)
     {
-        this->title_ = title;
         this->message_ = message;
-        if(time > 0)
-            this->displayTime_ = time;
     }
     
+    /**
+    @brief
+        Destructor.
+    */
     Notification::~Notification()
     {
     }
     
+    /**
+    @brief
+        Registers the object and sets some default values.
+    */
     void Notification::initialize(void)
     {
         RegisterObject(Notification);
         
-        this->title_ = "";
         this->message_ = "";
-        this->displayTime_ = NOTIFICATION_DISPLAY_TIME;
+        this->sender_ = NotificationManager::NONE;
         this->sent_ = false;
     }
     
+    /**
+    @brief
+        Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
+    @return
+        Returns true if successful.
+    */
     bool Notification::send(void)
     {
-        bool successful = NotificationManager::insertNotification(this);
-        if(successful)
-            this->sent_ = true;
-        return successful;
+        return this->send(NotificationManager::NONE);
     }
     
-    bool Notification::setTitle(const std::string & title)
+    /**
+    @brief
+        Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues.
+    @param sender
+        The sender the Notification was sent by. Used by the NotificationManager to distributes the notification to the correct NotificationQueues.
+    @return
+        Returns true if successful.
+    */
+    bool Notification::send(const std::string & sender)
     {
-        if(this->isSent())
+        this->sender_ = sender;
+        bool successful = NotificationManager::registerNotification(this);
+        if(!successful)
             return false;
-        this->title_ = title;
+        this->sent_ = true;
+        
+        COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
+        
         return true;
     }
     
+    /**
+    @brief
+        Sets the message of the notification.
+    @param message
+        The message to be set.
+    @return
+        Returns true if successful.
+    */
     bool Notification::setMessage(const std::string & message)
     {
-        if(this->isSent())
+        if(this->isSent()) //!< The message cannot be changed if the message has already been sent.
             return false;
         this->message_ = message;
         return true;
     }
-    
-    bool Notification::setDisplayTime(float time)
-    {
-        if(this->isSent())
-        {
-            return false;
-        }
-        if(time > 0)
-        {
-            this->displayTime_ = time;
-            return true;
-        }
-        return false;
-    }
+
 }

Modified: branches/questsystem5/src/orxonox/overlays/notifications/Notification.h
===================================================================
--- branches/questsystem5/src/orxonox/overlays/notifications/Notification.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/overlays/notifications/Notification.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -26,6 +26,11 @@
  *
  */
 
+/**
+    @file Notification.h
+    @brief Definition of the Notification class.
+*/
+
 #ifndef _Notification_H__
 #define _Notification_H__
 
@@ -37,44 +42,50 @@
 
 namespace orxonox
 {
-    static const float NOTIFICATION_DISPLAY_TIME = 4.0;
 
     /**
     @brief
-        This is rather temporary, so don't start relying on it, some better version will come soon but the Interface will not likely be the same.
+        A Notification is a short message used to inform the player about something that just happened. A Notification can be sent from any part of orxonox and is then displayed in the proper NotificationQueue (depending on which senders the specific NotificationQueue accepts).
     @author
         Damian 'Mozork' Frick
     */
     class _OrxonoxExport Notification : public BaseObject
     {
-    public:
-        Notification(BaseObject* creator);
-        Notification(BaseObject* creator, const std::string & message, const std::string & title = "", float time = NOTIFICATION_DISPLAY_TIME);
-        virtual ~Notification();
-        
-        bool send(void);
-        
-        inline bool isSent(void) const
-            { return this->sent_; }
-        inline const std::string & getTitle(void) const
-            { return this->title_; }
-        inline const std::string & getMessage(void) const
-            { return this->message_; }
-        inline const float getDisplayTime(void) const
-            { return displayTime_; }
-        
-        bool setTitle(const std::string & title);
-        bool setMessage(const std::string & message);
-        bool setDisplayTime(float time);
-        
-    private:
-        std::string title_; //!< The title of the Notification.
-        std::string message_; //!< The Notification message.
-        float displayTime_; //!< The time duration the Notification is displayed in seconds.
-        bool sent_; //!< Whether Notification has been sent, if so it cannot be changed.
-        
-        void initialize(void);
+        public:
+            Notification(BaseObject* creator);
+            Notification(const std::string & message);
+            virtual ~Notification();
+            
+            bool send(void); //!< Sends the Notification to the Notificationmanager, with sender NotificationManager::NONE;
+            bool send(const std::string & sender); //!< Sends the Notification to the Notificationmanager.
+            
+            /**
+            @brief Checks whether the Notification was sent.
+            @return Returns true if the Notification was sent already.
+            */
+            inline bool isSent(void) const
+                { return this->sent_; }
+            /**
+            @brief Returns the message of the Notification.
+            @return Returns the message of the Notification.
+            */
+            inline const std::string & getMessage(void) const
+                { return this->message_; }
+                
+            inline const std::string & getSender(void) const
+                { return this->sender_; }
+            
+            bool setMessage(const std::string & message); //!< Sets the message of the notification.
+	    
+        private:
+            std::string message_; //!< The Notification message.
+            std::string sender_; //!< The sender of the notification.
+            bool sent_; //!< Whether Notification has been sent, if so it cannot be changed.
+            
+            void initialize(void);
+	
     };
+
 }
 
 #endif /* _Notification_H__ */

Modified: branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.cc
===================================================================
--- branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -26,149 +26,175 @@
  *
  */
 
+/**
+    @file NotificationManager.cc
+    @brief Implementation of the NotificationManager class.
+*/
+
 #include "OrxonoxStableHeaders.h"
 #include "NotificationManager.h"
 
 #include "core/CoreIncludes.h"
 
+#include <set>
+
 #include "Notification.h"
-
 #include "NotificationQueue.h"
 
 namespace orxonox
 {
-    std::list<NotificationContainer*> NotificationManager::notifications_s;
 
+    const std::string NotificationManager::ALL = "all";
+    const std::string NotificationManager::NONE = "none";
+
+    std::multimap<std::time_t,Notification*> NotificationManager::allNotificationsList_s;
+    std::map<int,std::multimap<std::time_t,Notification*>*> NotificationManager::notificationLists_s;
+    std::map<NotificationQueue*,int> NotificationManager::queueList_s;
+    
+    int NotificationManager::highestIndex_s = 0;
+
+    /**
+    @brief
+        Constructor. Registers the Object.
+    */
     NotificationManager::NotificationManager(BaseObject* creator) : BaseObject(creator)
     {
         RegisterObject(NotificationManager);
     }
 
+    /**
+    @brief
+        Destructor.
+    */
     NotificationManager::~NotificationManager()
     {
-        //TDO: Destroy the containers
     }
-
-    void NotificationManager::tick(float dt)
+    
+    /**
+    @brief
+        Registers a Notification within the NotificationManager and makes sure that the Notification is displayed in all the NotificationQueues associated with its sender.
+    @param notification
+        The Notification to be registered.
+    @return
+        Returns true if successful.
+    */
+    /*static*/ bool NotificationManager::registerNotification(Notification* notification)
     {
-        bool update = false;
-
-        for (std::list<NotificationContainer*>::iterator notification = notifications_s.begin(); notification != notifications_s.end(); ++notification)
+    
+        if(notification == NULL) //!< A NULL-Notification cannot be registered.
+            return false;
+        
+        std::time_t time = std::time(0); //TDO: Doesn't this expire? //!< Get current time.
+        
+        allNotificationsList_s.insert(std::pair<std::time_t,Notification*>(time,notification));
+        
+        if(notification->getSender() == NONE) //!< If the sender has no specific name, then the Notification is only added to the list of all Notifications.
+            return true;
+        
+        bool all = false;
+        if(notification->getSender() == ALL) //!< If all are the sender, then the Notifications is added to every NotificationQueue.
+            all = true;
+        
+        //!< Insert the notification in all queues that have its sender as target.
+        for(std::map<NotificationQueue*,int>::iterator it = queueList_s.begin(); it != queueList_s.end(); it++)
         {
-            NotificationContainer* container = *notification;
-            if(container->remainingTime == 0)
+            std::set<std::string> set = it->first->getTargetsSet();
+            if(all || set.find(notification->getSender()) != set.end() || set.find(ALL) != set.end()) //TDO: Make sure this works.
             {
-                continue;
+                notificationLists_s[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationQueue.
+                it->first->update(notification, time); //!< Update the queue.
             }
-            else if(container->remainingTime - dt <= 0)
-            {
-                container->remainingTime = 0;
-                update = true;
-            }
-            else
-            {
-                container->remainingTime = container->remainingTime -dt;
-            }
         }
-
-        if(update)
-            updateQueue();
-    }
-
-    bool NotificationManager::insertNotification(Notification* notification)
-    {
-        if(notification == NULL)
-            return false;
-
-        NotificationContainer* container = new NotificationContainer;
-        container->notification = notification;
-        container->remainingTime = notification->getDisplayTime();
-        notifications_s.push_front(container);
-
-        updateQueue();
-
-        COUT(4) << "Notification inserted. Title: " << notification->getTitle() << std::endl;
-
+        
+        COUT(3) << "NotificationQueue registered with the NotificationManager." << std::endl;
+        
         return true;
     }
-
-    void NotificationManager::updateQueue(void)
+    
+    /**
+    @brief
+        Registers a NotificationQueue within the NotificationManager.
+    @param queue
+        The NotificationQueue to be registered.
+    @return
+        Returns true if successful.
+    */
+    /*static*/ bool NotificationManager::registerQueue(NotificationQueue* queue)
     {
-        std::string text = "";
-
-        if (!NotificationQueue::queue_s)
-            return;
-
-        int i = NotificationQueue::queue_s->getLength();
-        for (std::list<NotificationContainer*>::iterator notification = notifications_s.begin(); notification != notifications_s.end() && i > 0; ++notification)
+        NotificationManager::highestIndex_s += 1;
+        int index = NotificationManager::highestIndex_s;
+        
+        queueList_s[queue] = index; //!< Add the NotificationQueue to the list of queues.
+        
+        std::set<std::string> set = queue->getTargetsSet(); //TDO: Works this?
+        
+        //! If all senders are the target of the queue, then the list of notification for that specific queue is te same as the list of all Notifications.
+        if(set.find(ALL) != set.end())
         {
-            i--;
-            NotificationContainer* container = *notification;
-            if(container->remainingTime == 0.0)
-                continue;
-
-            text = text + "\n\n\n------------\n\n" + clipMessage(container->notification->getTitle()) + "\n\n" + clipMessage(container->notification->getMessage());
+            notificationLists_s[index] = &allNotificationsList_s;
+            return true;
         }
-
-        NotificationQueue::queue_s->setQueueText(text);
+        
+        notificationLists_s[index] = new std::multimap<std::time_t,Notification*>;
+        std::multimap<std::time_t,Notification*> map = *notificationLists_s[index];
+        
+        //! Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue.
+        for(std::multimap<std::time_t,Notification*>::iterator it = allNotificationsList_s.begin(); it != allNotificationsList_s.end(); it++)
+        {
+            if(set.find(it->second->getSender()) != set.end()) //!< Checks whether the overlay has the sender of the current notification as target.
+            {
+                map.insert(std::pair<std::time_t,Notification*>(it->first, it->second));
+            }
+        }
+        
+        COUT(3) << "Notification registered with the NotificationManager." << std::endl;
+        
+        queue->update(); //!< Update the queue.
+        
+        return true;
     }
-
-    const std::string NotificationManager::clipMessage(const std::string & str)
+    
+    /**
+    @brief
+        Fetches the Notifications for a specific NotificationQueue in a specified timeframe.
+    @param queue
+        The NotificationQueue the Notifications are fetched for.
+    @param timeFrameStart
+        The start time of the timeframe.
+    @param timeFrameEnd
+        The end time of the timeframe.
+    @return
+        Returns a time-ordered list of Notifications.
+    @todo
+        Make sure the map is deleted.
+    */
+    /*static*/ std::multimap<std::time_t,Notification*>* NotificationManager::getNotifications(NotificationQueue* queue, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
     {
-
-        std::string message = str;
-        unsigned int i = 0;
-
-        unsigned int found = message.find("\\n", i);
-        while(found != std::string::npos)
+        COUT(1) << "Queue: " << queue << ", timeFrameStart: " << timeFrameStart << ", timeFrameEnd: " << timeFrameEnd << std::endl;
+    
+        std::multimap<std::time_t,Notification*>* notifications = NotificationManager::notificationLists_s[NotificationManager::queueList_s[queue]];
+        
+        if(notifications == NULL)
+            return NULL;
+    
+        std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
+        itLowest = notifications->lower_bound(timeFrameStart);
+        itHighest = notifications->upper_bound(timeFrameStart);
+        
+        std::multimap<std::time_t,Notification*>* map = new std::multimap<std::time_t,Notification*>();
+        
+        for(it = itLowest; it != itHighest; it++)
         {
-            message.replace(found, 2, "\n");
-            i = found+2;
-            found = message.find("\\n", i);
+            map->insert(std::pair<std::time_t,Notification*>(it->first,it->second));
         }
-
-        std::string clippedMessage = "";
-        int wordLength = 0;
-        i = 0;
-        int widthLeft = NotificationQueue::queue_s->getWidth();
-        while(i < message.length())
+        
+        if(map->size() == 0)
         {
-            while(i < message.length() && message[i] != ' ' && message[i] != '\n')
-            {
-                i++;
-                wordLength++;
-            }
-
-            if(wordLength <= widthLeft)
-            {
-                clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength);
-                if(i < message.length())
-                {
-                    clippedMessage = clippedMessage + message.substr(i,1);
-                }
-                widthLeft -= (wordLength+1);
-                if(message[i] == '\n')
-                {
-                    widthLeft = NotificationQueue::queue_s->getWidth() - (wordLength+1);
-                }
-                wordLength = 0;
-                i++;
-            }
-            else
-            {
-                clippedMessage.push_back('\n');
-                clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength);
-                if(i < message.length())
-                {
-                    clippedMessage = clippedMessage + message.substr(i,1);
-                }
-                widthLeft = NotificationQueue::queue_s->getWidth() - (wordLength+1);
-                i++;
-                wordLength = 0;
-            }
+            delete map;
+            return NULL;
         }
-
-        return clippedMessage;
+        
+        return map;
     }
 
 }

Modified: branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.h
===================================================================
--- branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -26,6 +26,11 @@
  *
  */
 
+/**
+    @file NotificationManager.h
+    @brief Definition of the NotificationManager class.
+*/
+
 #ifndef _NotificationManager_H__
 #define _NotificationManager_H__
 
@@ -33,39 +38,61 @@
 
 #include "core/BaseObject.h"
 
-#include <list>
+#include <map>
 #include <string>
+#include <ctime>
 
+#include "NotificationOverlay.h"
+
 namespace orxonox
 {
-    struct NotificationContainer
-    {
-        Notification* notification;
-        float remainingTime;
-    };
 
     /**
     @brief
-        
+        The NotificationManager functions as a gateway between Notifications and NotificationQueues.
+        It receives, organizes Notifications and the redistributes them to the specific NotificationQueues.
     @author
         Damian 'Mozork' Frick
     */
     class _OrxonoxExport NotificationManager : public BaseObject
     {
-    
-    public:
-        NotificationManager(BaseObject* creator);
-        virtual ~NotificationManager();
+        public:
+            NotificationManager(BaseObject* creator);
+            virtual ~NotificationManager();
+	        
+            static const std::string ALL;
+            static const std::string NONE;
+         
+            //TDO: Visibility?
+            static bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
+            static bool registerQueue(NotificationQueue* queue); //!< Registers a NotificationQueue within the NotificationManager.
+            
+            static std::multimap<std::time_t,Notification*>* getNotifications(NotificationQueue* queue, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationQueue in a specified timeframe.
+            
+            /**
+            @brief Fetches the Notifications for a specific NotificationQueue starting at a specified time.
+            @param queue The NotificationQueue the Notifications are fetched for.
+            @param timeFrameStart The start time the Notifications are fetched from.
+            @return Returns a time-ordered list of Notifications.
+            */
+            static std::multimap<std::time_t,Notification*>* getNotifications(NotificationQueue* queue, const std::time_t & timeFrameStart)
+                { return NotificationManager::getNotifications(queue, timeFrameStart, std::time(0)); }
+            /**
+            @brief Fetches the Notifications for a specific NotificationQueue starting at a specified timespan before now.
+            @param queue The NotificationQueue the Notifications are fetched for.
+            @param timeDelay The timespan.
+            @return Returns a time-ordered list of Notifications.
+            */
+            static std::multimap<std::time_t,Notification*>* getNotifications(NotificationQueue* queue, int timeDelay)
+                { return NotificationManager::getNotifications(queue, std::time(0)-timeDelay, std::time(0)); }
+     
+	       private:
+            static int highestIndex_s; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that  no key appears twice.
         
-        static bool insertNotification(Notification* notification);
-        
-        static void tick(float dt);
-        
-    private:
-        static std::list<NotificationContainer*> notifications_s;
-        
-        static void updateQueue(void);
-        static const std::string clipMessage(const std::string & message);
+            static std::multimap<std::time_t,Notification*> allNotificationsList_s; //!< Container where all notifications are stored (together with their respecive timestamps).
+            static std::map<NotificationQueue*,int> queueList_s; //!< Container where all NotificationQueues are stored with a number as identifier.
+            static std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_s; //!< Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored.
+            
 
     };
 

Added: branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.cc
===================================================================
--- branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.cc	                        (rev 0)
+++ branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -0,0 +1,238 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "NotificationOverlay.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "core/CoreIncludes.h"
+#include "util/Exception.h"
+
+#include "Notification.h"
+#include "NotificationQueue.h"
+
+namespace orxonox
+{
+
+    NotificationOverlay::NotificationOverlay(BaseObject* creator) : OrxonoxOverlay(creator)
+    {
+        this->initialize();
+    }
+    
+    NotificationOverlay::NotificationOverlay(NotificationQueue* queue, Notification* notification) : OrxonoxOverlay(this)
+    {
+        this->initialize();
+        
+        if(notification == NULL || queue == NULL)
+        {
+            ThrowException(Argument, "There were NULL-Pointer arguments in NotificationOverlay creation.");
+        }
+
+        this->queue_ = queue;
+        this->defineOverlay();
+        
+        this->processNotification(notification);
+
+        COUT(3) << getCaption() << std::endl;
+        COUT(3) << getFontSize() << std::endl;
+        //COUT(3) << getFont() << std::endl;
+        COUT(3) << getWidth() << std::endl;
+        COUT(3) << getAlignmentString() << std::endl;
+        COUT(3) << getTextSize() << std::endl;
+    }
+    
+    void NotificationOverlay::initialize(void)
+    {
+        RegisterObject(NotificationOverlay);
+        
+        this->queue_ = NULL;
+        this->notificationText_ = NULL;
+        this->width_ = 0;
+    }
+    
+    void NotificationOverlay::defineOverlay(void)
+    {
+        this->setFont(this->queue_->getFont());
+        this->setFontSize(this->queue_->getFontSize());
+        
+        this->notificationText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", "NotificationOverlay_notificationText_" + getUniqueNumberString()));
+        this->notificationText_->setCharHeight(1.0);
+        this->notificationText_->setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
+        this->notificationText_->setAlignment(Ogre::TextAreaOverlayElement::Center);
+        this->notificationText_->setCaption("");
+        
+        this->background_->addChild(this->notificationText_);
+        COUT(3) << this->queue_->getFont() << std::endl;
+    }
+    
+    NotificationOverlay::~NotificationOverlay()
+    {
+    
+    }
+    
+    void NotificationOverlay::setFont(const std::string & font)
+    {
+        if (this->notificationText_ && font != "")
+            this->notificationText_->setFontName(font);
+    }
+
+    void NotificationOverlay::setFontSize(float size)
+    {
+        if (this->notificationText_ && size >= 0)
+            this->notificationText_->setCharHeight(size);
+    }
+    
+    void NotificationOverlay::setWidth(int width)
+    {
+        this->width_ = width;
+        this->notificationText_->setCaption(clipMessage(this->notification_->getMessage()));
+    }
+
+    float NotificationOverlay::getFontSize(void) const
+    {
+        if (this->notificationText_)
+            return this->notificationText_->getCharHeight();
+        else
+            return 0;
+    }
+    
+    bool NotificationOverlay::processNotification(Notification* notification)
+    {
+        this->notificationText_->setCaption(clipMessage(notification->getMessage()));
+        this->notification_ = notification;
+        return true;
+    }
+
+    const std::string NotificationOverlay::clipMessage(const std::string & str)
+    {
+        if(str.length() <= (unsigned int)this->queue_->getNotificationLength())
+            return str;
+        return str.substr(0, this->queue_->getNotificationLength());
+    }
+
+    const std::string NotificationOverlay::clipMessage2(const std::string & str)
+    {
+    
+        std::string message = str;
+        unsigned int i = 0;
+        
+        unsigned int found = message.find("\\n", i);
+        while(found != std::string::npos)
+        {
+            message.replace(found, 2, "\n");
+            i = found+2;
+            found = message.find("\\n", i);
+        }
+    
+        std::string clippedMessage = "";
+        int wordLength = 0;
+        i = 0;
+        int widthLeft = this->getWidth();
+        while(i < message.length())
+        {
+            while(i < message.length() && message[i] != ' ' && message[i] != '\n')
+            {
+                i++;
+                wordLength++;
+            }
+            
+            if(wordLength <= widthLeft)
+            {
+                clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength);
+                if(i < message.length())
+                {
+                    clippedMessage = clippedMessage + message.substr(i,1);
+                }
+                widthLeft -= (wordLength+1);
+                if(message[i] == '\n')
+                {
+                    widthLeft = this->getWidth() - (wordLength+1);
+                }
+                wordLength = 0;
+                i++;
+            }
+            else
+            {
+                clippedMessage.push_back('\n');
+                clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength);
+                if(i < message.length())
+                {
+                    clippedMessage = clippedMessage + message.substr(i,1);
+                }
+                widthLeft = this->getWidth() - (wordLength+1);
+                i++;
+                wordLength = 0;
+            }
+        }
+        
+        return clippedMessage;
+    }
+
+    void NotificationOverlay::sizeChanged()
+    {
+        if (this->rotState_ == Horizontal)
+            this->overlay_->setScale(size_.y * sizeCorrection_.y, size_.y * sizeCorrection_.y);
+        else if (this->rotState_ == Vertical)
+            this->overlay_->setScale(size_.y / (sizeCorrection_.y * sizeCorrection_.y), size_.y * sizeCorrection_.y);
+        else
+            this->overlay_->setScale(size_.y, size_.y);
+
+        positionChanged();
+    }
+
+    void NotificationOverlay::setAlignmentString(const std::string& alignment)
+    {
+        if (alignment == "right")
+            this->setAlignment(Ogre::TextAreaOverlayElement::Right);
+        else if (alignment == "center")
+            this->setAlignment(Ogre::TextAreaOverlayElement::Center);
+        else // "left" and default
+            this->setAlignment(Ogre::TextAreaOverlayElement::Left);
+    }
+
+    std::string NotificationOverlay::getAlignmentString() const
+    {
+        Ogre::TextAreaOverlayElement::Alignment alignment = this->notificationText_->getAlignment();
+
+        switch (alignment)
+        {
+            case Ogre::TextAreaOverlayElement::Right:
+                return "right";
+            case Ogre::TextAreaOverlayElement::Center:
+                return "center";
+            case Ogre::TextAreaOverlayElement::Left:
+                return "left";
+            default:
+                assert(false); return "";
+        }
+    }
+
+}


Property changes on: branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.cc
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.h
===================================================================
--- branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.h	                        (rev 0)
+++ branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -0,0 +1,111 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _NotificationOverlay_H__
+#define _NotificationOverlay_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "orxonox/overlays/OrxonoxOverlay.h"
+
+#include <string>
+#include <set>
+#include <OgrePrerequisites.h>
+#include <OgreTextAreaOverlayElement.h>
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        
+    @author
+        Damian 'Mozork' Frick
+    */
+    class _OrxonoxExport NotificationOverlay : public OrxonoxOverlay
+    {
+    
+        friend class NotificationQueue; //TDO: Best solution?
+    
+        public:
+            NotificationOverlay(BaseObject* creator);
+            NotificationOverlay(NotificationQueue* queue, Notification* notification);
+            virtual ~NotificationOverlay();
+            
+            bool processNotification(Notification* notification);
+        
+        protected:
+            const std::string clipMessage(const std::string & message);
+            const std::string clipMessage2(const std::string & message); //Outdated
+        
+        private:
+            NotificationQueue* queue_;
+            Notification* notification_;
+            
+            int width_;
+            
+            Ogre::TextAreaOverlayElement* notificationText_;
+            
+            void initialize(void);
+            void defineOverlay(void);
+
+            virtual void sizeChanged();
+
+            void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment)
+                { this->notificationText_->setAlignment(alignment); }
+            void setCaption(const std::string& caption)
+                { this->notificationText_->setCaption(caption); }
+            void setColour(const ColourValue& colour)
+                { this->notificationText_->setColour(colour); }
+            void setFont(const std::string & font);
+            void setFontSize(float size);
+            void setWidth(int width);
+            void setAlignmentString(const std::string& alignment);
+            void setTextSize(float size)
+                { this->setSize(Vector2(size, size)); }
+            
+            Ogre::TextAreaOverlayElement::Alignment getAlignment() const
+                { return this->notificationText_->getAlignment(); }
+            std::string getCaption() const
+                { return this->notificationText_->getCaption(); }
+            float getFontSize(void) const;
+            const std::string & getFont(void) const
+                { return this->notificationText_->getFontName(); }
+            int getWidth(void) const
+                { return this->width_; }
+            const ColourValue& getColour() const
+                { return this->notificationText_->getColour(); }
+            std::string getAlignmentString() const;
+            float getTextSize() const
+                { return this->getSize().y; }
+
+    };
+
+}
+
+#endif /* _NotificationOverlay_H__ */


Property changes on: branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.h
___________________________________________________________________
Added: svn:executable
   + *

Modified: branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc
===================================================================
--- branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc	2009-03-12 16:13:34 UTC (rev 2779)
@@ -29,81 +29,371 @@
 #include "OrxonoxStableHeaders.h"
 #include "NotificationQueue.h"
 
+#include <OgreOverlayManager.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <list>
+
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 
-#include "NotificationManager.h"
+#include "Notification.h"
+#include "NotificationOverlay.h"
 
 namespace orxonox
 {
-    NotificationQueue* NotificationQueue::queue_s = 0;
-
+    
     CreateFactory(NotificationQueue);
+    
+    const std::string NotificationQueue::DEFAULT_FONT = "VeraMono";
 
-    NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayText(creator)
+    /**
+    @brief
+        Constructor. Creates and initializes the object.
+    */
+    NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayGroup(creator)
     {
+        this->initialize();
+    }
+    
+    /**
+    @brief
+        Destructor.
+    @todo
+        I'm pretty sure that there are some thing that have to be distroyed.
+    */
+    NotificationQueue::~NotificationQueue()
+    {
+        
+    }
+    
+    /**
+    @brief
+        Initializes the object.
+        Registers the object, initializes variables, sets default values and registers the queue with the NotificationManager.
+    */
+    void NotificationQueue::initialize(void)
+    {
         RegisterObject(NotificationQueue);
-        //TDO: Does this work?
-        if(queue_s != NULL)
+        
+        this->setDefaults();
+        this->size_ = 0;
+        this->tickTime_ = 0.0;
+        
+        NotificationManager::registerQueue(this);
+    }
+    
+    /**
+    @brief
+        Sets the defaults.
+    */
+    void NotificationQueue::setDefaults(void)
+    {
+        this->setMaxSize(DEFAULT_SIZE);
+        this->setNotificationLength(DEFAULT_LENGTH);
+        this->setDisplayTime(DEFAULT_DISPLAY_TIME);
+        
+        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);
+        
+        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);
+        
+        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.
         {
-                COUT(2) << "There is now more than one NotificationQueue, this shouldn't happen, since only the first NotificationQueue will be targeted by the NotificationManager." << std::endl;
+            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);
+                it = this->containers_.begin(); //TDO: Needed?
+            }
+            
+            this->tickTime_ = 0.0; //!< Reset time counter.
         }
-        else
+    }
+    
+    /**
+    @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 = NotificationManager::getNotifications(this, this->displayTime_);
+        
+        if(notifications == NULL)
+            return;
+        
+        for(std::multimap<std::time_t,Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++)
         {
-                queue_s = this;
+            this->addNotification(it->second, it->first);
         }
-
-        this->length_ = 3;
-        this->width_ = 50;
+        
+        COUT(3) << "NotificationQueue updated." << std::endl;
     }
-
-    NotificationQueue::~NotificationQueue()
+    
+    /**
+    @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);
+        
+        //TDO: Position!
+        
+        std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it;
+        while(this->getSize() > this->getMaxSize())
+        {
+            it = this->containers_.begin();
+            this->removeContainer(*it);
+        }
+        
+        COUT(3) << "NotificationQueue updated. A new Notifications has been added." << std::endl;
     }
-
-    void NotificationQueue::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    
+    /**
+    @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)
     {
-        SUPER(NotificationQueue, XMLPort, xmlElement, mode);
-
-        XMLPortParam(NotificationQueue, "length", setLength, getLength, xmlElement, mode);
-        XMLPortParam(NotificationQueue, "width", setWidth, getWidth, xmlElement, mode);
+        if(size < 0)
+            return false;
+        this->maxSize_ = size;
+        this->update();
+        return true;
     }
-
-    void NotificationQueue::tick(float dt)
+    
+    /**
+    @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)
     {
-        NotificationManager::tick(dt);
-
-        update();
+        if(length < 0)
+            return false;
+        this->notificationLength_ = length;
+        this->update();
+        return true;
     }
-
-    bool NotificationQueue::setLength(int length)
+    
+    /**
+    @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(length > 0)
+        if(time < 0)
+            return false;
+        this->displayTime_ = time;
+        this->update();
+        return true;
+    }
+    
+    /**
+    @brief
+        Returns all targets concatinated as string, with kommas (',') as seperators.
+    @return
+        Returns all targets concatinated as string, with kommas (',') as seperators.
+    @todo
+        Where is the string deleted?
+    */
+    const std::string & NotificationQueue::getTargets() const
+    {
+        std::string* pTemp = new std::string("");
+        bool first = true;
+        for(std::set<std::string>::iterator it = this->targets_.begin(); it != this->targets_.end(); it++) //!< Iterate through the set of targets.
         {
-            this->length_ = length;
-            return true;
+            if(!first)
+            {
+                *pTemp += ",";
+            }
+            else
+            {
+                first = false;
+            }
+            *pTemp += *it;
         }
-        return false;
+        
+        return *pTemp;
     }
-
-    bool NotificationQueue::setWidth(int width)
+    
+    /**
+    @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)
     {
-        if(width > 0)
+        std::string* pTemp;
+        unsigned int index = 0;
+        while( index < targets.size() ) //!< Go through the string, character by character until the end is reached.
         {
-            this->width_ = width;
-            return true;
+            pTemp = new std::string("");
+            while(targets[index] != ',' && targets[index] != ' ' && index < targets.size())
+            {
+                *pTemp += targets[index];
+                index++;
+            }
+            this->targets_.insert(*pTemp);
         }
-        return false;
+        
+        return true;
     }
-
-    void NotificationQueue::setQueueText(const std::string & text)
+    
+    /**
+    @brief
+        Sets the font size.
+    @param size
+        The font size.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::setFontSize(float size)
     {
-        this->queueText_ = text;
+        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;
     }
-
-    void NotificationQueue::update(void)
+    
+    /**
+    @brief
+        Sets the font.
+    @param font
+        The font.
+    @return
+        Returns true if successful.
+    */
+    bool NotificationQueue::setFont(const std::string & font)
     {
-        this->text_->setCaption(queueText_);
+        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
+        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);
+        char buffer[64]; //TDO: Very un-nice.
+        std::sprintf(buffer,"%x",(unsigned long)notification); //TDO: Use other conversion to avoid 64bit problems.
+        std::string addressString = buffer;
+        container->name = "NotificationOverlay(" + timeString + ")&" + addressString;
+        
+        this->containers_.insert(container);
+        this->overlays_[notification] = container;
+        this->insertElement(container->overlay, container->name);
+        this->size_= this->size_+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->name);
+        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?
+        }
+    }
+
 }

Modified: branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.h
===================================================================
--- branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.h	2009-03-12 16:05:18 UTC (rev 2778)
+++ branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.h	2009-03-12 16:13:34 UTC (rev 2779)
@@ -26,53 +26,154 @@
  *
  */
 
+/**
+    @file NotificationQueue.h
+    @brief Definition of the NotificationQueue class.
+*/
+
 #ifndef _NotificationOueue_H__
 #define _NotificationOueue_H__
 
 #include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <set>
+#include <OgreOverlayManager.h>
 #include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+#include <map>
+#include <ctime>
 
-#include "orxonox/overlays/OverlayText.h"
+#include "orxonox/overlays/OverlayGroup.h"
 #include "orxonox/objects/Tickable.h"
 
-#include <string>
+#include "NotificationManager.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.
     @author
         Damian 'Mozork' Frick
     */
-    class _OrxonoxExport NotificationQueue : public OverlayText, public Tickable
+
+    class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable
     {
-    public:
-        NotificationQueue(BaseObject* creator);
-        virtual ~NotificationQueue();
-
-        static NotificationQueue* queue_s; //TDO Singleton? oder im level.
-
-        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
-
-        virtual void tick(float dt);
-
-        void update(void);
-
-        int getLength(void) const
-                { return this->length_; }
-        int getWidth(void) const
-                { return this->width_; }
-
-        void setQueueText(const std::string & text);
-        bool setLength(int length);
-        bool setWidth(int width);
-
-    private:
-        Ogre::UTFString queueText_;
-        int length_;
-        int width_;
-
+    
+        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 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_; }
+            const std::string & getTargets() const; //!< Returns a string consisting of teh concatination of the targets.
+            
+            /**
+            @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_; }
+            
+        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 = 0.02; //!< The default font size.
+            static const std::string DEFAULT_FONT; //!< The default font.
+        
+            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.
+            
+            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 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.
+    
     };
 
 }




More information about the Orxonox-commit mailing list