- Timestamp:
- Dec 14, 2008, 1:42:17 AM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/overlays/notifications
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/overlays/notifications/Notification.cc
r2385 r2435 34 34 #include "NotificationManager.h" 35 35 36 namespace orxonox {37 36 namespace orxonox 37 { 38 38 Notification::Notification(BaseObject* creator) : BaseObject(creator) 39 39 { … … 41 41 } 42 42 43 Notification::Notification( const std::string & message, const std::string & title, float time) : BaseObject(this)43 Notification::Notification(BaseObject* creator, const std::string & message, const std::string & title, float time) : BaseObject(creator) 44 44 { 45 45 this->title_ = title; … … 59 59 this->title_ = ""; 60 60 this->message_ = ""; 61 this->displayTime_ = DISPLAY_TIME;61 this->displayTime_ = NOTIFICATION_DISPLAY_TIME; 62 62 this->sent_ = false; 63 63 } … … 68 68 if(successful) 69 69 this->sent_ = true; 70 70 return successful; 71 71 } 72 72 … … 75 75 if(this->isSent()) 76 76 return false; 77 78 77 this->title_ = title; 78 return true; 79 79 } 80 80 … … 83 83 if(this->isSent()) 84 84 return false; 85 86 85 this->message_ = message; 86 return true; 87 87 } 88 88 … … 92 92 { 93 93 return false; 94 95 96 97 98 99 100 94 } 95 if(time > 0) 96 { 97 this->displayTime_ = time; 98 return true; 99 } 100 return false; 101 101 } 102 103 102 } -
code/branches/presentation/src/orxonox/overlays/notifications/Notification.h
r2385 r2435 36 36 #include "core/BaseObject.h" 37 37 38 namespace orxonox { 38 namespace orxonox 39 { 40 static const float NOTIFICATION_DISPLAY_TIME = 4.0; 39 41 40 42 /** 41 43 @brief 42 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. 43 45 @author 44 46 Damian 'Mozork' Frick … … 46 48 class _OrxonoxExport Notification : public BaseObject 47 49 { 48 public: 49 Notification(BaseObject* creator); 50 Notification(const std::string & message, const std::string & title = "", float time = DISPLAY_TIME); 51 virtual ~Notification(); 52 53 bool send(void); 54 55 inline bool isSent(void) const 56 { return this->sent_; } 57 inline const std::string & getTitle(void) const 58 { return this->title_; } 59 inline const std::string & getMessage(void) const 60 { return this->message_; } 61 inline const float getDisplayTime(void) const 62 { return displayTime_; } 63 64 bool setTitle(const std::string & title); 65 bool setMessage(const std::string & message); 66 bool setDisplayTime(float time); 67 68 private: 69 static const float DISPLAY_TIME = 4.0; 70 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); 77 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); 78 77 }; 79 80 78 } 81 79 -
code/branches/presentation/src/orxonox/overlays/notifications/NotificationManager.cc
r2385 r2435 36 36 #include "NotificationQueue.h" 37 37 38 namespace orxonox {39 38 namespace orxonox 39 { 40 40 std::list<NotificationContainer*> NotificationManager::notifications_s; 41 41 … … 55 55 56 56 for (std::list<NotificationContainer*>::iterator notification = notifications_s.begin(); notification != notifications_s.end(); ++notification) 57 57 { 58 58 NotificationContainer* container = *notification; 59 59 if(container->remainingTime == 0) 60 60 { 61 61 continue; 62 63 64 65 66 67 68 69 62 } 63 else if(container->remainingTime - dt <= 0) 64 { 65 container->remainingTime = 0; 66 update = true; 67 } 68 else 69 { 70 70 container->remainingTime = container->remainingTime -dt; 71 72 73 74 71 } 72 } 73 74 if(update) 75 75 updateQueue(); 76 76 } … … 81 81 return false; 82 82 83 84 85 83 NotificationContainer* container = new NotificationContainer; 84 container->notification = notification; 85 container->remainingTime = notification->getDisplayTime(); 86 86 notifications_s.push_front(container); 87 87 … … 105 105 continue; 106 106 107 107 text = text + "\n\n\n------------\n\n" + clipMessage(container->notification->getTitle()) + "\n\n" + clipMessage(container->notification->getMessage()); 108 108 } 109 109 -
code/branches/presentation/src/orxonox/overlays/notifications/NotificationManager.h
r2385 r2435 37 37 #include <string> 38 38 39 namespace orxonox {40 39 namespace orxonox 40 { 41 41 struct NotificationContainer 42 42 { … … 54 54 { 55 55 56 57 58 59 60 61 62 63 64 65 66 67 68 56 public: 57 NotificationManager(BaseObject* creator); 58 virtual ~NotificationManager(); 59 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); 69 69 70 70 }; -
code/branches/presentation/src/orxonox/overlays/notifications/NotificationQueue.cc
r2385 r2435 35 35 #include "NotificationManager.h" 36 36 37 namespace orxonox {38 37 namespace orxonox 38 { 39 39 NotificationQueue* NotificationQueue::queue_s = 0; 40 40 … … 46 46 //TDO: Does this work? 47 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 52 53 queue_s = this;54 55 56 57 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 58 } 59 59 -
code/branches/presentation/src/orxonox/overlays/notifications/NotificationQueue.h
r2385 r2435 38 38 #include <string> 39 39 40 namespace orxonox {41 40 namespace orxonox 41 { 42 42 /** 43 43 @brief … … 48 48 class _OrxonoxExport NotificationQueue : public OverlayText, public Tickable 49 49 { 50 51 52 53 54 55 56 57 58 59 60 61 62 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 63 { return this->length_; } 64 64 int getWidth(void) const 65 65 { return this->width_; } 66 67 68 69 70 71 72 73 74 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 75 76 76 };
Note: See TracChangeset
for help on using the changeset viewer.