- Timestamp:
- Dec 17, 2008, 9:11:12 AM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/overlays/notifications
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/overlays/notifications/NotificationManager.cc
r2436 r2501 49 49 //TDO: Destroy the containers 50 50 } 51 51 52 52 void NotificationManager::tick(float dt) 53 53 { 54 54 bool update = false; 55 55 56 56 for (std::list<NotificationContainer*>::iterator notification = notifications_s.begin(); notification != notifications_s.end(); ++notification) 57 57 { … … 71 71 } 72 72 } 73 73 74 74 if(update) 75 75 updateQueue(); 76 76 } 77 77 78 78 bool NotificationManager::insertNotification(Notification* notification) 79 79 { 80 80 if(notification == NULL) 81 81 return false; 82 82 83 83 NotificationContainer* container = new NotificationContainer; 84 84 container->notification = notification; 85 85 container->remainingTime = notification->getDisplayTime(); 86 86 notifications_s.push_front(container); 87 87 88 88 updateQueue(); 89 89 90 90 COUT(4) << "Notification inserted. Title: " << notification->getTitle() << std::endl; 91 91 92 92 return true; 93 93 } 94 94 95 95 void NotificationManager::updateQueue(void) 96 96 { 97 97 std::string text = ""; 98 98 99 if (!NotificationQueue::queue_s) 100 return; 101 99 102 int i = NotificationQueue::queue_s->getLength(); 100 103 for (std::list<NotificationContainer*>::iterator notification = notifications_s.begin(); notification != notifications_s.end() && i > 0; ++notification) … … 104 107 if(container->remainingTime == 0.0) 105 108 continue; 106 109 107 110 text = text + "\n\n\n------------\n\n" + clipMessage(container->notification->getTitle()) + "\n\n" + clipMessage(container->notification->getMessage()); 108 111 } 109 112 110 113 NotificationQueue::queue_s->setQueueText(text); 111 114 } 112 115 113 116 const std::string NotificationManager::clipMessage(const std::string & str) 114 117 { 115 118 116 119 std::string message = str; 117 120 unsigned int i = 0; 118 121 119 122 unsigned int found = message.find("\\n", i); 120 123 while(found != std::string::npos) … … 124 127 found = message.find("\\n", i); 125 128 } 126 129 127 130 std::string clippedMessage = ""; 128 131 int wordLength = 0; … … 136 139 wordLength++; 137 140 } 138 141 139 142 if(wordLength <= widthLeft) 140 143 { … … 165 168 } 166 169 } 167 170 168 171 return clippedMessage; 169 172 } -
code/branches/presentation/src/orxonox/overlays/notifications/NotificationQueue.cc
r2500 r2501 56 56 this->length_ = 3; 57 57 this->width_ = 50; 58 COUT(0) << "added notification queue" << std::endl;59 58 } 60 59 61 60 NotificationQueue::~NotificationQueue() 62 61 { 63 COUT(0) << "deleted notification queue" << std::endl;64 62 65 63 } … … 102 100 void NotificationQueue::setQueueText(const std::string & text) 103 101 { 104 COUT(0) << "queue: " << text << std::endl;105 102 this->queueText_ = text; 106 103 } … … 110 107 this->text_->setCaption(queueText_); 111 108 } 112 113 109 } -
code/branches/presentation/src/orxonox/overlays/notifications/NotificationQueue.h
r2436 r2501 42 42 /** 43 43 @brief 44 44 45 45 @author 46 46 Damian 'Mozork' Frick … … 51 51 NotificationQueue(BaseObject* creator); 52 52 virtual ~NotificationQueue(); 53 53 54 54 static NotificationQueue* queue_s; //TDO Singleton? oder im level. 55 55 56 56 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 57 57 58 58 virtual void tick(float dt); 59 59 60 60 void update(void); 61 61 62 62 int getLength(void) const 63 63 { return this->length_; } 64 64 int getWidth(void) const 65 65 { return this->width_; } 66 66 67 67 void setQueueText(const std::string & text); 68 68 bool setLength(int length); 69 69 bool setWidth(int width); 70 70 71 71 private: 72 72 Ogre::UTFString queueText_; 73 73 int length_; 74 74 int width_; 75 75 76 76 }; 77 77
Note: See TracChangeset
for help on using the changeset viewer.