Changeset 2501 for code/branches/presentation/src/orxonox/overlays/notifications/NotificationManager.cc
- Timestamp:
- Dec 17, 2008, 9:11:12 AM (15 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.