Changeset 2779 for code/branches/questsystem5
- Timestamp:
- Mar 12, 2009, 5:13:34 PM (16 years ago)
- Location:
- code/branches/questsystem5/src/orxonox
- Files:
-
- 4 added
- 45 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5/src/orxonox/OrxonoxPrereqs.h
r2710 r2779 129 129 class QuestListener; 130 130 class QuestManager; 131 class QuestNotification; 131 132 class Rewardable; 132 133 … … 227 228 class Notification; 228 229 class NotificationManager; 230 class NotificationOverlay; 229 231 class NotificationQueue; 230 232 class OrxonoxOverlay; -
code/branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file AddQuest.cc 31 31 @brief Implementation of the AddQuest class. 32 32 */ … … 42 42 #include "orxonox/objects/infos/PlayerInfo.h" 43 43 #include "QuestManager.h" 44 #include "QuestDescription.h"; 44 45 #include "Quest.h" 45 46 -
code/branches/questsystem5/src/orxonox/objects/quest/AddQuest.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file AddQuest.h 31 31 @brief Definition of the AddQuest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file AddQuestHint.cc 31 31 @brief Implementation of the AddQuestHint class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/AddQuestHint.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file AddQuestHint.h 31 31 @brief Definition of the AddQuestHint class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/AddReward.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file AddReward.cc 31 31 @brief Implementation of the AddReward class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/AddReward.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file AddReward.h 31 31 @brief Definition of the AddReward class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/CMakeLists.txt
r2710 r2779 16 16 QuestListener.cc 17 17 QuestManager.cc 18 QuestNotification.cc 18 19 Rewardable.cc 19 20 ) -
code/branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file ChangeQuestStatus.cc 31 31 @brief Implementation of the ChangeQuestStatus class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/ChangeQuestStatus.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file ChangeQuestStatus.h 31 31 @brief Definition of the ChangeQuestStatus class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file CompleteQuest.cc 31 31 @brief Implementation of the CompleteQuest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/CompleteQuest.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file CompleteQuest.h 31 31 @brief Definition of the CompleteQuest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/FailQuest.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file FailQuest.cc 31 31 @brief Implementation of the FailQuest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/FailQuest.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file FailQuest.h 31 31 @brief Definition of the FailQuest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file GlobalQuest.cc 31 31 @brief Implementation of the GlobalQuest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/GlobalQuest.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file GlobalQuest.h 31 31 @brief Definition of the GlobalQuest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/LocalQuest.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file LocalQuest.cc 31 31 @brief Implementation of the LocalQuest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/LocalQuest.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file LocalQuest.h 31 31 @brief Definition of the LocalQuest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/Quest.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file Quest.cc 31 31 @brief Implementation of the Quest class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/Quest.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file Quest.h 31 31 @brief Definition of the Quest class. 32 32 The Quest is the parent class of LocalQuest and GlobalQuest. -
code/branches/questsystem5/src/orxonox/objects/quest/QuestDescription.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestDescription.cc 31 31 @brief Implementation of the QuestDescription class. 32 32 */ … … 37 37 38 38 #include "core/CoreIncludes.h" 39 #include " orxonox/overlays/notifications/Notification.h"39 #include "QuestNotification.h" 40 40 41 41 namespace orxonox … … 89 89 @return 90 90 Returns true if successful. 91 @todo 92 Make sure the messages meet the conditions. 91 93 */ 92 94 bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const 93 95 { 94 96 std::string message = ""; 95 std::string title = "";96 97 if(item == "hint") 97 98 { 98 title = "You received a hint: '" + this->title_ + "'"; 99 message = this->description_; 99 message = "You received a hint: '" + this->title_ + "'"; 100 100 } 101 101 else if(item == "quest") … … 103 103 if(status == "start") 104 104 { 105 title = "You received a new quest: '" + this->title_ + "'"; 106 message = this->description_; 105 message = "You received a new quest: '" + this->title_ + "'"; 107 106 } 108 107 else if(status == "fail") 109 108 { 110 title = "You failed the quest: '" + this->title_ + "'"; 111 message = this->failMessage_; 109 message = "You failed the quest: '" + this->title_ + "'"; 112 110 } 113 111 else if(status == "complete") 114 112 { 115 title = "You successfully completed the quest: '" + this->title_ + "'"; 116 message = this->completeMessage_; 113 message = "You successfully completed the quest: '" + this->title_ + "'"; 117 114 } 118 115 else … … 128 125 } 129 126 130 Notification* notification = new Notification(0, message, title, 30);127 QuestNotification* notification = new QuestNotification(message); 131 128 notification->send(); 132 129 return true; -
code/branches/questsystem5/src/orxonox/objects/quest/QuestDescription.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestDescription.h 31 31 @brief Definition of the QuestDescription class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestEffect.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestEffect.cc 31 31 @brief Implementation of the QuestEffect class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestEffect.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestEffect.h 31 31 @brief Definition of the QuestEffect class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.cc
r2662 r2779 28 28 29 29 /** 30 @file 30 @file QuestEffectBeacon.cc 31 31 @brief Implementation of the QuestEffectBeacon class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestEffectBeacon.h
r2662 r2779 28 28 29 29 /** 30 @file 30 @file QuestEffectBeacon.h 31 31 @brief Definition of the QuestEffectBeacon class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestHint.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestHint.cc 31 31 @brief Implementation of the QuestHint class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestHint.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestHint.h 31 31 @brief Definition of the QuestHint class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestItem.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestItem.cc 31 31 @brief Implementation of the QuestItem class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestItem.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestItem.h 31 31 @brief Definition of the QuestItem class. 32 32 The QuestItem is the parent class of Quest and QuestHint. -
code/branches/questsystem5/src/orxonox/objects/quest/QuestListener.cc
r2662 r2779 28 28 29 29 /** 30 @file 30 @file QuestListener.cc 31 31 @brief Implementation of the QuestListener class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestListener.h
r2662 r2779 28 28 29 29 /** 30 @file 30 @file QuestListener.h 31 31 @brief Definition of the QuestListener class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestManager.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestManager.cc 31 31 @brief Implementation of the QuestManager class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/QuestManager.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file QuestManager.h 31 31 @brief Definition of the QuestManager class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/Rewardable.cc
r2710 r2779 28 28 29 29 /** 30 @file 30 @file Rewardable.cc 31 31 @brief Implementation of the Rewardable class. 32 32 */ -
code/branches/questsystem5/src/orxonox/objects/quest/Rewardable.h
r2710 r2779 28 28 29 29 /** 30 @file 30 @file Rewardable.h 31 31 @brief Definition of the Rewardable class. 32 32 */ -
code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc
r2662 r2779 107 107 void OverlayGroup::addElement(OrxonoxOverlay* element) 108 108 { 109 if (hudElements_.find(element->getName()) != hudElements_.end()) 109 this->insertElement(element, element->getName()); 110 } 111 112 /** 113 @brief 114 Adds an element to the map. 115 @param element 116 The element to be added. 117 @param name 118 The name of the element. 119 @remarks 120 The names of the OrxonoxOverlays have to be unique! 121 */ 122 void OverlayGroup::insertElement(OrxonoxOverlay* element, const std::string & name) 123 { 124 element->setName(name); 125 if (hudElements_.find(name) != hudElements_.end()) 110 126 { 111 127 COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl; … … 113 129 else 114 130 { 115 hudElements_[ element->getName()] = element;131 hudElements_[name] = element; 116 132 element->setVisible(this->isVisible()); 117 133 if (this->owner_) 118 134 element->setOwner(this->owner_); 119 135 } 136 } 137 138 /** 139 @brief 140 Removes an element from the map. 141 @param name 142 The name of the element that is removed. 143 @return 144 Returns true if there was such an element to remove, false if not. 145 */ 146 bool OverlayGroup::removeElement(const std::string & name) 147 { 148 if(this->hudElements_.erase(name) == 0) 149 return false; 150 return true; 120 151 } 121 152 -
code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.h
r2662 r2779 86 86 87 87 void addElement(OrxonoxOverlay* element); 88 void insertElement(OrxonoxOverlay* element, const std::string & name); 89 bool removeElement(const std::string & name); 88 90 OrxonoxOverlay* getElement(unsigned int index); 89 91 -
code/branches/questsystem5/src/orxonox/overlays/notifications/CMakeLists.txt
r2710 r2779 2 2 Notification.cc 3 3 NotificationManager.cc 4 NotificationOverlay.cc 4 5 NotificationQueue.cc 5 6 ) -
code/branches/questsystem5/src/orxonox/overlays/notifications/Notification.cc
r2662 r2779 27 27 */ 28 28 29 /** 30 @file Notification.cc 31 @brief Implementation of the Notification class. 32 */ 33 29 34 #include "OrxonoxStableHeaders.h" 30 35 #include "Notification.h" 31 36 32 37 #include "core/CoreIncludes.h" 38 #include "util/Exception.h" 33 39 34 40 #include "NotificationManager.h" … … 36 42 namespace orxonox 37 43 { 44 45 /** 46 @brief 47 Default constructor. Initializes the object. 48 */ 38 49 Notification::Notification(BaseObject* creator) : BaseObject(creator) 39 50 { 40 RegisterObject(Notification);51 this->initialize(); 41 52 } 42 53 43 Notification::Notification(BaseObject* creator, const std::string & message, const std::string & title, float time) : BaseObject(creator) 54 /** 55 @brief 56 Constructor. Creates a Notification with the input message. 57 @param message 58 The message of the Notification. 59 */ 60 Notification::Notification(const std::string & message) : BaseObject(this) 44 61 { 45 this->title_ = title;46 62 this->message_ = message; 47 if(time > 0)48 this->displayTime_ = time;49 63 } 50 64 65 /** 66 @brief 67 Destructor. 68 */ 51 69 Notification::~Notification() 52 70 { 53 71 } 54 72 73 /** 74 @brief 75 Registers the object and sets some default values. 76 */ 55 77 void Notification::initialize(void) 56 78 { 57 79 RegisterObject(Notification); 58 80 59 this->title_ = "";60 81 this->message_ = ""; 61 this-> displayTime_ = NOTIFICATION_DISPLAY_TIME;82 this->sender_ = NotificationManager::NONE; 62 83 this->sent_ = false; 63 84 } 64 85 86 /** 87 @brief 88 Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE. 89 @return 90 Returns true if successful. 91 */ 65 92 bool Notification::send(void) 66 93 { 67 bool successful = NotificationManager::insertNotification(this); 68 if(successful) 69 this->sent_ = true; 70 return successful; 94 return this->send(NotificationManager::NONE); 71 95 } 72 96 73 bool Notification::setTitle(const std::string & title) 97 /** 98 @brief 99 Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues. 100 @param sender 101 The sender the Notification was sent by. Used by the NotificationManager to distributes the notification to the correct NotificationQueues. 102 @return 103 Returns true if successful. 104 */ 105 bool Notification::send(const std::string & sender) 74 106 { 75 if(this->isSent()) 107 this->sender_ = sender; 108 bool successful = NotificationManager::registerNotification(this); 109 if(!successful) 76 110 return false; 77 this->title_ = title; 111 this->sent_ = true; 112 113 COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl; 114 78 115 return true; 79 116 } 80 117 118 /** 119 @brief 120 Sets the message of the notification. 121 @param message 122 The message to be set. 123 @return 124 Returns true if successful. 125 */ 81 126 bool Notification::setMessage(const std::string & message) 82 127 { 83 if(this->isSent()) 128 if(this->isSent()) //!< The message cannot be changed if the message has already been sent. 84 129 return false; 85 130 this->message_ = message; 86 131 return true; 87 132 } 88 89 bool Notification::setDisplayTime(float time) 90 { 91 if(this->isSent()) 92 { 93 return false; 94 } 95 if(time > 0) 96 { 97 this->displayTime_ = time; 98 return true; 99 } 100 return false; 101 } 133 102 134 } -
code/branches/questsystem5/src/orxonox/overlays/notifications/Notification.h
r2662 r2779 27 27 */ 28 28 29 /** 30 @file Notification.h 31 @brief Definition of the Notification class. 32 */ 33 29 34 #ifndef _Notification_H__ 30 35 #define _Notification_H__ … … 38 43 namespace orxonox 39 44 { 40 static const float NOTIFICATION_DISPLAY_TIME = 4.0;41 45 42 46 /** 43 47 @brief 44 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.48 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). 45 49 @author 46 50 Damian 'Mozork' Frick … … 48 52 class _OrxonoxExport Notification : public BaseObject 49 53 { 50 public: 51 Notification(BaseObject* creator); 52 Notification(BaseObject* creator, const std::string & message, const std::string & title = "", float time = NOTIFICATION_DISPLAY_TIME); 53 virtual ~Notification(); 54 55 bool send(void); 56 57 inline bool isSent(void) const 58 { return this->sent_; } 59 inline const std::string & getTitle(void) const 60 { return this->title_; } 61 inline const std::string & getMessage(void) const 62 { return this->message_; } 63 inline const float getDisplayTime(void) const 64 { return displayTime_; } 65 66 bool setTitle(const std::string & title); 67 bool setMessage(const std::string & message); 68 bool setDisplayTime(float time); 69 70 private: 71 std::string title_; //!< The title of the Notification. 72 std::string message_; //!< The Notification message. 73 float displayTime_; //!< The time duration the Notification is displayed in seconds. 74 bool sent_; //!< Whether Notification has been sent, if so it cannot be changed. 75 76 void initialize(void); 54 public: 55 Notification(BaseObject* creator); 56 Notification(const std::string & message); 57 virtual ~Notification(); 58 59 bool send(void); //!< Sends the Notification to the Notificationmanager, with sender NotificationManager::NONE; 60 bool send(const std::string & sender); //!< Sends the Notification to the Notificationmanager. 61 62 /** 63 @brief Checks whether the Notification was sent. 64 @return Returns true if the Notification was sent already. 65 */ 66 inline bool isSent(void) const 67 { return this->sent_; } 68 /** 69 @brief Returns the message of the Notification. 70 @return Returns the message of the Notification. 71 */ 72 inline const std::string & getMessage(void) const 73 { return this->message_; } 74 75 inline const std::string & getSender(void) const 76 { return this->sender_; } 77 78 bool setMessage(const std::string & message); //!< Sets the message of the notification. 79 80 private: 81 std::string message_; //!< The Notification message. 82 std::string sender_; //!< The sender of the notification. 83 bool sent_; //!< Whether Notification has been sent, if so it cannot be changed. 84 85 void initialize(void); 86 77 87 }; 88 78 89 } 79 90 -
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.cc
r2662 r2779 27 27 */ 28 28 29 /** 30 @file NotificationManager.cc 31 @brief Implementation of the NotificationManager class. 32 */ 33 29 34 #include "OrxonoxStableHeaders.h" 30 35 #include "NotificationManager.h" … … 32 37 #include "core/CoreIncludes.h" 33 38 39 #include <set> 40 34 41 #include "Notification.h" 35 36 42 #include "NotificationQueue.h" 37 43 38 44 namespace orxonox 39 45 { 40 std::list<NotificationContainer*> NotificationManager::notifications_s; 41 46 47 const std::string NotificationManager::ALL = "all"; 48 const std::string NotificationManager::NONE = "none"; 49 50 std::multimap<std::time_t,Notification*> NotificationManager::allNotificationsList_s; 51 std::map<int,std::multimap<std::time_t,Notification*>*> NotificationManager::notificationLists_s; 52 std::map<NotificationQueue*,int> NotificationManager::queueList_s; 53 54 int NotificationManager::highestIndex_s = 0; 55 56 /** 57 @brief 58 Constructor. Registers the Object. 59 */ 42 60 NotificationManager::NotificationManager(BaseObject* creator) : BaseObject(creator) 43 61 { … … 45 63 } 46 64 65 /** 66 @brief 67 Destructor. 68 */ 47 69 NotificationManager::~NotificationManager() 48 70 { 49 //TDO: Destroy the containers 50 } 51 52 void NotificationManager::tick(float dt) 53 { 54 bool update = false; 55 56 for (std::list<NotificationContainer*>::iterator notification = notifications_s.begin(); notification != notifications_s.end(); ++notification) 57 { 58 NotificationContainer* container = *notification; 59 if(container->remainingTime == 0) 71 } 72 73 /** 74 @brief 75 Registers a Notification within the NotificationManager and makes sure that the Notification is displayed in all the NotificationQueues associated with its sender. 76 @param notification 77 The Notification to be registered. 78 @return 79 Returns true if successful. 80 */ 81 /*static*/ bool NotificationManager::registerNotification(Notification* notification) 82 { 83 84 if(notification == NULL) //!< A NULL-Notification cannot be registered. 85 return false; 86 87 std::time_t time = std::time(0); //TDO: Doesn't this expire? //!< Get current time. 88 89 allNotificationsList_s.insert(std::pair<std::time_t,Notification*>(time,notification)); 90 91 if(notification->getSender() == NONE) //!< If the sender has no specific name, then the Notification is only added to the list of all Notifications. 92 return true; 93 94 bool all = false; 95 if(notification->getSender() == ALL) //!< If all are the sender, then the Notifications is added to every NotificationQueue. 96 all = true; 97 98 //!< Insert the notification in all queues that have its sender as target. 99 for(std::map<NotificationQueue*,int>::iterator it = queueList_s.begin(); it != queueList_s.end(); it++) 100 { 101 std::set<std::string> set = it->first->getTargetsSet(); 102 if(all || set.find(notification->getSender()) != set.end() || set.find(ALL) != set.end()) //TDO: Make sure this works. 60 103 { 61 continue; 104 notificationLists_s[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationQueue. 105 it->first->update(notification, time); //!< Update the queue. 62 106 } 63 else if(container->remainingTime - dt <= 0) 107 } 108 109 COUT(3) << "NotificationQueue registered with the NotificationManager." << std::endl; 110 111 return true; 112 } 113 114 /** 115 @brief 116 Registers a NotificationQueue within the NotificationManager. 117 @param queue 118 The NotificationQueue to be registered. 119 @return 120 Returns true if successful. 121 */ 122 /*static*/ bool NotificationManager::registerQueue(NotificationQueue* queue) 123 { 124 NotificationManager::highestIndex_s += 1; 125 int index = NotificationManager::highestIndex_s; 126 127 queueList_s[queue] = index; //!< Add the NotificationQueue to the list of queues. 128 129 std::set<std::string> set = queue->getTargetsSet(); //TDO: Works this? 130 131 //! 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. 132 if(set.find(ALL) != set.end()) 133 { 134 notificationLists_s[index] = &allNotificationsList_s; 135 return true; 136 } 137 138 notificationLists_s[index] = new std::multimap<std::time_t,Notification*>; 139 std::multimap<std::time_t,Notification*> map = *notificationLists_s[index]; 140 141 //! Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue. 142 for(std::multimap<std::time_t,Notification*>::iterator it = allNotificationsList_s.begin(); it != allNotificationsList_s.end(); it++) 143 { 144 if(set.find(it->second->getSender()) != set.end()) //!< Checks whether the overlay has the sender of the current notification as target. 64 145 { 65 container->remainingTime = 0; 66 update = true; 146 map.insert(std::pair<std::time_t,Notification*>(it->first, it->second)); 67 147 } 68 else 69 { 70 container->remainingTime = container->remainingTime -dt; 71 } 72 } 73 74 if(update) 75 updateQueue(); 76 } 77 78 bool NotificationManager::insertNotification(Notification* notification) 79 { 80 if(notification == NULL) 81 return false; 82 83 NotificationContainer* container = new NotificationContainer; 84 container->notification = notification; 85 container->remainingTime = notification->getDisplayTime(); 86 notifications_s.push_front(container); 87 88 updateQueue(); 89 90 COUT(4) << "Notification inserted. Title: " << notification->getTitle() << std::endl; 91 148 } 149 150 COUT(3) << "Notification registered with the NotificationManager." << std::endl; 151 152 queue->update(); //!< Update the queue. 153 92 154 return true; 93 155 } 94 95 void NotificationManager::updateQueue(void) 96 { 97 std::string text = ""; 98 99 if (!NotificationQueue::queue_s) 100 return; 101 102 int i = NotificationQueue::queue_s->getLength(); 103 for (std::list<NotificationContainer*>::iterator notification = notifications_s.begin(); notification != notifications_s.end() && i > 0; ++notification) 104 { 105 i--; 106 NotificationContainer* container = *notification; 107 if(container->remainingTime == 0.0) 108 continue; 109 110 text = text + "\n\n\n------------\n\n" + clipMessage(container->notification->getTitle()) + "\n\n" + clipMessage(container->notification->getMessage()); 111 } 112 113 NotificationQueue::queue_s->setQueueText(text); 114 } 115 116 const std::string NotificationManager::clipMessage(const std::string & str) 117 { 118 119 std::string message = str; 120 unsigned int i = 0; 121 122 unsigned int found = message.find("\\n", i); 123 while(found != std::string::npos) 124 { 125 message.replace(found, 2, "\n"); 126 i = found+2; 127 found = message.find("\\n", i); 128 } 129 130 std::string clippedMessage = ""; 131 int wordLength = 0; 132 i = 0; 133 int widthLeft = NotificationQueue::queue_s->getWidth(); 134 while(i < message.length()) 135 { 136 while(i < message.length() && message[i] != ' ' && message[i] != '\n') 137 { 138 i++; 139 wordLength++; 140 } 141 142 if(wordLength <= widthLeft) 143 { 144 clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength); 145 if(i < message.length()) 146 { 147 clippedMessage = clippedMessage + message.substr(i,1); 148 } 149 widthLeft -= (wordLength+1); 150 if(message[i] == '\n') 151 { 152 widthLeft = NotificationQueue::queue_s->getWidth() - (wordLength+1); 153 } 154 wordLength = 0; 155 i++; 156 } 157 else 158 { 159 clippedMessage.push_back('\n'); 160 clippedMessage = clippedMessage + message.substr(i-wordLength, wordLength); 161 if(i < message.length()) 162 { 163 clippedMessage = clippedMessage + message.substr(i,1); 164 } 165 widthLeft = NotificationQueue::queue_s->getWidth() - (wordLength+1); 166 i++; 167 wordLength = 0; 168 } 169 } 170 171 return clippedMessage; 156 157 /** 158 @brief 159 Fetches the Notifications for a specific NotificationQueue in a specified timeframe. 160 @param queue 161 The NotificationQueue the Notifications are fetched for. 162 @param timeFrameStart 163 The start time of the timeframe. 164 @param timeFrameEnd 165 The end time of the timeframe. 166 @return 167 Returns a time-ordered list of Notifications. 168 @todo 169 Make sure the map is deleted. 170 */ 171 /*static*/ std::multimap<std::time_t,Notification*>* NotificationManager::getNotifications(NotificationQueue* queue, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd) 172 { 173 COUT(1) << "Queue: " << queue << ", timeFrameStart: " << timeFrameStart << ", timeFrameEnd: " << timeFrameEnd << std::endl; 174 175 std::multimap<std::time_t,Notification*>* notifications = NotificationManager::notificationLists_s[NotificationManager::queueList_s[queue]]; 176 177 if(notifications == NULL) 178 return NULL; 179 180 std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest; 181 itLowest = notifications->lower_bound(timeFrameStart); 182 itHighest = notifications->upper_bound(timeFrameStart); 183 184 std::multimap<std::time_t,Notification*>* map = new std::multimap<std::time_t,Notification*>(); 185 186 for(it = itLowest; it != itHighest; it++) 187 { 188 map->insert(std::pair<std::time_t,Notification*>(it->first,it->second)); 189 } 190 191 if(map->size() == 0) 192 { 193 delete map; 194 return NULL; 195 } 196 197 return map; 172 198 } 173 199 -
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.h
r2662 r2779 27 27 */ 28 28 29 /** 30 @file NotificationManager.h 31 @brief Definition of the NotificationManager class. 32 */ 33 29 34 #ifndef _NotificationManager_H__ 30 35 #define _NotificationManager_H__ … … 34 39 #include "core/BaseObject.h" 35 40 36 #include < list>41 #include <map> 37 42 #include <string> 43 #include <ctime> 44 45 #include "NotificationOverlay.h" 38 46 39 47 namespace orxonox 40 48 { 41 struct NotificationContainer42 {43 Notification* notification;44 float remainingTime;45 };46 49 47 50 /** 48 51 @brief 49 52 The NotificationManager functions as a gateway between Notifications and NotificationQueues. 53 It receives, organizes Notifications and the redistributes them to the specific NotificationQueues. 50 54 @author 51 55 Damian 'Mozork' Frick … … 53 57 class _OrxonoxExport NotificationManager : public BaseObject 54 58 { 55 56 public: 57 NotificationManager(BaseObject* creator); 58 virtual ~NotificationManager(); 59 public: 60 NotificationManager(BaseObject* creator); 61 virtual ~NotificationManager(); 62 63 static const std::string ALL; 64 static const std::string NONE; 65 66 //TDO: Visibility? 67 static bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. 68 static bool registerQueue(NotificationQueue* queue); //!< Registers a NotificationQueue within the NotificationManager. 69 70 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. 71 72 /** 73 @brief Fetches the Notifications for a specific NotificationQueue starting at a specified time. 74 @param queue The NotificationQueue the Notifications are fetched for. 75 @param timeFrameStart The start time the Notifications are fetched from. 76 @return Returns a time-ordered list of Notifications. 77 */ 78 static std::multimap<std::time_t,Notification*>* getNotifications(NotificationQueue* queue, const std::time_t & timeFrameStart) 79 { return NotificationManager::getNotifications(queue, timeFrameStart, std::time(0)); } 80 /** 81 @brief Fetches the Notifications for a specific NotificationQueue starting at a specified timespan before now. 82 @param queue The NotificationQueue the Notifications are fetched for. 83 @param timeDelay The timespan. 84 @return Returns a time-ordered list of Notifications. 85 */ 86 static std::multimap<std::time_t,Notification*>* getNotifications(NotificationQueue* queue, int timeDelay) 87 { return NotificationManager::getNotifications(queue, std::time(0)-timeDelay, std::time(0)); } 88 89 private: 90 static int highestIndex_s; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice. 59 91 60 static bool insertNotification(Notification* notification); 61 62 static void tick(float dt); 63 64 private: 65 static std::list<NotificationContainer*> notifications_s; 66 67 static void updateQueue(void); 68 static const std::string clipMessage(const std::string & message); 92 static std::multimap<std::time_t,Notification*> allNotificationsList_s; //!< Container where all notifications are stored (together with their respecive timestamps). 93 static std::map<NotificationQueue*,int> queueList_s; //!< Container where all NotificationQueues are stored with a number as identifier. 94 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. 95 69 96 70 97 }; -
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc
r2662 r2779 30 30 #include "NotificationQueue.h" 31 31 32 #include <OgreOverlayManager.h> 33 #include <OgreTextAreaOverlayElement.h> 34 #include <list> 35 32 36 #include "core/CoreIncludes.h" 33 37 #include "core/XMLPort.h" 34 38 35 #include "NotificationManager.h" 39 #include "Notification.h" 40 #include "NotificationOverlay.h" 36 41 37 42 namespace orxonox 38 43 { 39 NotificationQueue* NotificationQueue::queue_s = 0; 40 44 41 45 CreateFactory(NotificationQueue); 42 43 NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayText(creator) 46 47 const std::string NotificationQueue::DEFAULT_FONT = "VeraMono"; 48 49 /** 50 @brief 51 Constructor. Creates and initializes the object. 52 */ 53 NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayGroup(creator) 54 { 55 this->initialize(); 56 } 57 58 /** 59 @brief 60 Destructor. 61 @todo 62 I'm pretty sure that there are some thing that have to be distroyed. 63 */ 64 NotificationQueue::~NotificationQueue() 65 { 66 67 } 68 69 /** 70 @brief 71 Initializes the object. 72 Registers the object, initializes variables, sets default values and registers the queue with the NotificationManager. 73 */ 74 void NotificationQueue::initialize(void) 44 75 { 45 76 RegisterObject(NotificationQueue); 46 //TDO: Does this work? 47 if(queue_s != NULL) 48 { 49 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; 50 } 51 else 52 { 53 queue_s = this; 54 } 55 56 this->length_ = 3; 57 this->width_ = 50; 58 } 59 60 NotificationQueue::~NotificationQueue() 61 { 62 63 } 64 77 78 this->setDefaults(); 79 this->size_ = 0; 80 this->tickTime_ = 0.0; 81 82 NotificationManager::registerQueue(this); 83 } 84 85 /** 86 @brief 87 Sets the defaults. 88 */ 89 void NotificationQueue::setDefaults(void) 90 { 91 this->setMaxSize(DEFAULT_SIZE); 92 this->setNotificationLength(DEFAULT_LENGTH); 93 this->setDisplayTime(DEFAULT_DISPLAY_TIME); 94 95 this->setTargets(NotificationManager::ALL); 96 97 this->setFontSize(DEFAULT_FONT_SIZE); 98 this->setFont(DEFAULT_FONT); 99 } 100 101 /** 102 @brief 103 Method for creating a NotificationQueue object through XML. 104 */ 65 105 void NotificationQueue::XMLPort(Element& xmlElement, XMLPort::Mode mode) 66 106 { 67 107 SUPER(NotificationQueue, XMLPort, xmlElement, mode); 68 69 XMLPortParam(NotificationQueue, "length", setLength, getLength, xmlElement, mode); 70 XMLPortParam(NotificationQueue, "width", setWidth, getWidth, xmlElement, mode); 71 } 72 108 109 XMLPortParam(NotificationQueue, "maxSize", setMaxSize, getMaxSize, xmlElement, mode); 110 XMLPortParam(NotificationQueue, "notificationLength", setNotificationLength, getNotificationLength, xmlElement, mode); 111 XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlElement, mode); 112 XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlElement, mode); 113 XMLPortParam(NotificationQueue, "font", setFont, getFont, xmlElement, mode); 114 XMLPortParam(NotificationQueue, "fontSize", setFontSize, getFontSize, xmlElement, mode); 115 116 COUT(3) << "NotificationQueue created." << std::endl; 117 } 118 119 /** 120 @brief 121 Updates the queue from time to time. 122 @param dt 123 The time interval that has passed since the last tick. 124 */ 73 125 void NotificationQueue::tick(float dt) 74 126 { 75 NotificationManager::tick(dt); 76 77 update(); 78 } 79 80 bool NotificationQueue::setLength(int length) 81 { 82 if(length > 0) 83 { 84 this->length_ = length; 85 return true; 86 } 87 return false; 88 } 89 90 bool NotificationQueue::setWidth(int width) 91 { 92 if(width > 0) 93 { 94 this->width_ = width; 95 return true; 96 } 97 return false; 98 } 99 100 void NotificationQueue::setQueueText(const std::string & text) 101 { 102 this->queueText_ = text; 103 } 104 127 this->tickTime_ += dt; //!< Add the time interval that has passed to the time counter. 128 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. 129 { 130 this->timeLimit_.time = std::time(0)-this->displayTime_; //!< Container containig the current time. 131 132 std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it; 133 it = this->containers_.begin(); 134 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. 135 { 136 this->removeContainer(*it); 137 it = this->containers_.begin(); //TDO: Needed? 138 } 139 140 this->tickTime_ = 0.0; //!< Reset time counter. 141 } 142 } 143 144 /** 145 @brief 146 Updates the NotificationQueue. 147 Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting the in the queue. 148 */ 105 149 void NotificationQueue::update(void) 106 150 { 107 this->text_->setCaption(queueText_); 108 } 151 this->clear(); 152 153 std::multimap<std::time_t,Notification*>* notifications = NotificationManager::getNotifications(this, this->displayTime_); 154 155 if(notifications == NULL) 156 return; 157 158 for(std::multimap<std::time_t,Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) 159 { 160 this->addNotification(it->second, it->first); 161 } 162 163 COUT(3) << "NotificationQueue updated." << std::endl; 164 } 165 166 /** 167 @brief 168 Updates the NotificationQueue by adding an new Notification. 169 @param notification 170 Pointer to the Notification. 171 @param time 172 The time the Notification was sent. 173 */ 174 void NotificationQueue::update(Notification* notification, const std::time_t & time) 175 { 176 this->addNotification(notification, time); 177 178 //TDO: Position! 179 180 std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it; 181 while(this->getSize() > this->getMaxSize()) 182 { 183 it = this->containers_.begin(); 184 this->removeContainer(*it); 185 } 186 187 COUT(3) << "NotificationQueue updated. A new Notifications has been added." << std::endl; 188 } 189 190 /** 191 @brief 192 Sets the maximum number of displayed Notifications. 193 @param size 194 The size to be set. 195 @return 196 Returns true if successful. 197 */ 198 bool NotificationQueue::setMaxSize(int size) 199 { 200 if(size < 0) 201 return false; 202 this->maxSize_ = size; 203 this->update(); 204 return true; 205 } 206 207 /** 208 @brief 209 Sets the maximum number of characters a Notification message displayed by this queue is allowed to have. 210 @param length 211 The length to be set. 212 @return 213 Returns true if successful. 214 */ 215 bool NotificationQueue::setNotificationLength(int length) 216 { 217 if(length < 0) 218 return false; 219 this->notificationLength_ = length; 220 this->update(); 221 return true; 222 } 223 224 /** 225 @brief 226 Sets the maximum number of seconds a Notification is displayed. 227 @param time 228 The number of seconds the Notifications is displayed. 229 @return 230 Returns true if successful. 231 */ 232 bool NotificationQueue::setDisplayTime(int time) 233 { 234 if(time < 0) 235 return false; 236 this->displayTime_ = time; 237 this->update(); 238 return true; 239 } 240 241 /** 242 @brief 243 Returns all targets concatinated as string, with kommas (',') as seperators. 244 @return 245 Returns all targets concatinated as string, with kommas (',') as seperators. 246 @todo 247 Where is the string deleted? 248 */ 249 const std::string & NotificationQueue::getTargets() const 250 { 251 std::string* pTemp = new std::string(""); 252 bool first = true; 253 for(std::set<std::string>::iterator it = this->targets_.begin(); it != this->targets_.end(); it++) //!< Iterate through the set of targets. 254 { 255 if(!first) 256 { 257 *pTemp += ","; 258 } 259 else 260 { 261 first = false; 262 } 263 *pTemp += *it; 264 } 265 266 return *pTemp; 267 } 268 269 /** 270 @brief 271 Sets the targets of the queue. 272 The targets are the senders whose Notifications are displayed in this queue. 273 @param targets 274 Accepts a string of targets, each seperated by commas (','), spaces are ignored. 275 @return 276 Returns true if successful. 277 */ 278 bool NotificationQueue::setTargets(const std::string & targets) 279 { 280 std::string* pTemp; 281 unsigned int index = 0; 282 while( index < targets.size() ) //!< Go through the string, character by character until the end is reached. 283 { 284 pTemp = new std::string(""); 285 while(targets[index] != ',' && targets[index] != ' ' && index < targets.size()) 286 { 287 *pTemp += targets[index]; 288 index++; 289 } 290 this->targets_.insert(*pTemp); 291 } 292 293 return true; 294 } 295 296 /** 297 @brief 298 Sets the font size. 299 @param size 300 The font size. 301 @return 302 Returns true if successful. 303 */ 304 bool NotificationQueue::setFontSize(float size) 305 { 306 if(size <= 0) 307 return false; 308 this->fontSize_ = size; 309 for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); ++it) //!< Set the font size for each overlay. 310 { 311 it->second->overlay->setFontSize(size); 312 } 313 return true; 314 } 315 316 /** 317 @brief 318 Sets the font. 319 @param font 320 The font. 321 @return 322 Returns true if successful. 323 */ 324 bool NotificationQueue::setFont(const std::string & font) 325 { 326 this->font_ = font; 327 for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); ++it) //!< Set the font for each overlay. 328 { 329 it->second->overlay->setFont(font); 330 } 331 return true; 332 } 333 334 /** 335 @brief 336 Adds a Notification, to the queue. 337 It inserts it into the storage containers, creates an corresponding overlay and a container. 338 @param notification 339 The Notification. 340 @param time 341 The time. 342 */ 343 void NotificationQueue::addNotification(Notification* notification, const std::time_t & time) 344 { 345 NotificationOverlayContainer* container = new NotificationOverlayContainer; 346 container->overlay = new NotificationOverlay(this, notification); 347 container->notification = notification; 348 container->time = time; 349 std::string timeString = std::ctime(&time); 350 timeString.erase(timeString.length()-1); 351 char buffer[64]; //TDO: Very un-nice. 352 std::sprintf(buffer,"%x",(unsigned long)notification); //TDO: Use other conversion to avoid 64bit problems. 353 std::string addressString = buffer; 354 container->name = "NotificationOverlay(" + timeString + ")&" + addressString; 355 356 this->containers_.insert(container); 357 this->overlays_[notification] = container; 358 this->insertElement(container->overlay, container->name); 359 this->size_= this->size_+1; 360 } 361 362 /** 363 @brief 364 Removes a container from the queue. 365 @param container 366 A pointer to the container. 367 @return 368 Returns true if successful. 369 */ 370 bool NotificationQueue::removeContainer(NotificationOverlayContainer* container) 371 { 372 if(this->size_ == 0) //!< You cannot remove anything if the queue is empty. 373 return false; 374 375 this->removeElement(container->name); 376 this->containers_.erase(container); 377 this->overlays_.erase(container->notification); 378 delete container->overlay; 379 delete container; 380 this->size_= this->size_-1; 381 382 return true; 383 } 384 385 /** 386 @brief 387 Clears the queue by removing all containers. 388 */ 389 void NotificationQueue::clear(void) 390 { 391 std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it = this->containers_.begin(); 392 while(it != this->containers_.end()) 393 { 394 this->removeContainer(*it); 395 it = this->containers_.begin(); //TDO: Needed? 396 } 397 } 398 109 399 } -
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.h
r2662 r2779 27 27 */ 28 28 29 /** 30 @file NotificationQueue.h 31 @brief Definition of the NotificationQueue class. 32 */ 33 29 34 #ifndef _NotificationOueue_H__ 30 35 #define _NotificationOueue_H__ 31 36 32 37 #include "OrxonoxPrereqs.h" 38 39 #include <string> 40 #include <set> 41 #include <OgreOverlayManager.h> 33 42 #include <OgreTextAreaOverlayElement.h> 43 #include <OgrePanelOverlayElement.h> 44 #include <map> 45 #include <ctime> 34 46 35 #include "orxonox/overlays/Overlay Text.h"47 #include "orxonox/overlays/OverlayGroup.h" 36 48 #include "orxonox/objects/Tickable.h" 37 49 38 #include <string>50 #include "NotificationManager.h" 39 51 40 52 namespace orxonox 41 53 { 54 55 //! Container to allow easy handling. 56 struct NotificationOverlayContainer 57 { 58 NotificationOverlay* overlay; //!< Pointer to the NotificationOverlay, everything is about. 59 Notification* notification; //!< The Notification displayed by the overlay. 60 time_t time; //!< The time the Notification was sent and thus first displayed. 61 std::string name; //!< The name of the overlay. 62 }; 63 64 //! Struct to allow ordering of NotificationOverlayContainers. 65 struct NotificationOverlayContainerCompare { 66 bool operator() (const NotificationOverlayContainer* const & a, const NotificationOverlayContainer* const & b) const 67 { return a->time < b->time; } //!< Ordered by time. 68 }; 69 42 70 /** 43 71 @brief 44 72 Displays Notifications from specific senders. 45 73 @author 46 74 Damian 'Mozork' Frick 47 75 */ 48 class _OrxonoxExport NotificationQueue : public OverlayText, public Tickable 76 77 class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable 49 78 { 50 public: 51 NotificationQueue(BaseObject* creator); 52 virtual ~NotificationQueue(); 53 54 static NotificationQueue* queue_s; //TDO Singleton? oder im level. 55 56 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 57 58 virtual void tick(float dt); 59 60 void update(void); 61 62 int getLength(void) const 63 { return this->length_; } 64 int getWidth(void) const 65 { return this->width_; } 66 67 void setQueueText(const std::string & text); 68 bool setLength(int length); 69 bool setWidth(int width); 70 71 private: 72 Ogre::UTFString queueText_; 73 int length_; 74 int width_; 75 79 80 public: 81 NotificationQueue(BaseObject* creator); 82 virtual ~NotificationQueue(); 83 84 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML. 85 86 virtual void tick(float dt); //!< To update from time to time. 87 88 void update(void); //!< Updates the queue. 89 void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue. 90 91 /** 92 @brief Returns the maximum number of Notifications displayed. 93 @return Returns maximum size. 94 */ 95 inline int getMaxSize() const 96 { return this->maxSize_; } 97 /** 98 @brief Returns the current number of Notifications displayed. 99 @return Returns the size of the queue. 100 */ 101 inline int getSize() const 102 { return this->size_; } 103 /** 104 @brief Returns the maximum length in characters a Notification message is allowed to have. 105 @return Returns the maximum Notification length. 106 */ 107 inline int getNotificationLength() const 108 { return this->notificationLength_; } 109 /** 110 @brief Returns the time interval the Notification is displayed. 111 @return Returns the display time. 112 */ 113 inline int getDisplayTime() const 114 { return this->displayTime_; } 115 116 /** 117 @brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue. 118 @return Retuns a set of string holding the different targets. 119 */ 120 inline const std::set<std::string> & getTargetsSet() 121 { return this->targets_; } 122 const std::string & getTargets() const; //!< Returns a string consisting of teh concatination of the targets. 123 124 /** 125 @brief Returns the font size used to display the Notifications. 126 @return Returns the font size. 127 */ 128 inline float getFontSize() const 129 { return this->fontSize_; } 130 /** 131 @brief Returns the font used to display the Notifications. 132 @return Returns the font. 133 */ 134 inline const std::string & getFont() const 135 { return this->font_; } 136 137 private: 138 static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. 139 static const int DEFAULT_LENGTH = 64; //!< The default maximum number of Notifications displayed. 140 static const int DEFAULT_DISPLAY_TIME = 30; //!< The default display time. 141 static const float DEFAULT_FONT_SIZE = 0.02; //!< The default font size. 142 static const std::string DEFAULT_FONT; //!< The default font. 143 144 int maxSize_; //!< The maximal number of Notifications displayed. 145 int size_; //!< The number of Notifications displayed. 146 int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have. 147 int displayTime_; //!< The time a Notification is displayed. 148 149 std::set<std::string> targets_; //!< The targets the Queue displays Notifications of. 150 151 float fontSize_; //!< The font size. 152 std::string font_; //!< The font. 153 154 std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps. 155 std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding. 156 157 float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick. 158 NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 159 160 void initialize(void); //!< Initializes the object. 161 void setDefaults(void); //!< Helper method to set the default values. 162 163 bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications. 164 bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have. 165 bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed. 166 167 bool setTargets(const std::string & targets); //!< Set the targets of this queue. 168 169 bool setFontSize(float size); //!< Set the font size. 170 bool setFont(const std::string & font); //!< Set the font. 171 172 void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue. 173 bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue. 174 175 void clear(void); //!< Clear the queue. 176 76 177 }; 77 178
Note: See TracChangeset
for help on using the changeset viewer.