Changeset 2783 for code/branches/questsystem5/src
- Timestamp:
- Mar 13, 2009, 3:39:54 PM (16 years ago)
- Location:
- code/branches/questsystem5/src/orxonox/overlays/notifications
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationManager.cc
r2779 r2783 97 97 98 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++) 99 for(std::map<NotificationQueue*,int>::iterator it = queueList_s.begin(); it != queueList_s.end(); it++) //!< Iterate through all queues. 100 100 { 101 101 std::set<std::string> set = it->first->getTargetsSet(); … … 107 107 } 108 108 109 COUT(3) << "Notification Queueregistered with the NotificationManager." << std::endl;109 COUT(3) << "Notification registered with the NotificationManager." << std::endl; 110 110 111 111 return true; … … 133 133 { 134 134 notificationLists_s[index] = &allNotificationsList_s; 135 COUT(3) << "NotificationQueue registered with the NotificationManager." << std::endl; 135 136 return true; 136 137 } … … 148 149 } 149 150 150 COUT(3) << "Notification registered with the NotificationManager." << std::endl;151 152 151 queue->update(); //!< Update the queue. 152 153 COUT(3) << "NotificationQueue registered with the NotificationManager." << std::endl; 153 154 154 155 return true; … … 171 172 /*static*/ std::multimap<std::time_t,Notification*>* NotificationManager::getNotifications(NotificationQueue* queue, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd) 172 173 { 173 COUT(1) << "Queue: " << queue << ", timeFrameStart: " << timeFrameStart << ", timeFrameEnd: " << timeFrameEnd << std::endl;174 175 174 std::multimap<std::time_t,Notification*>* notifications = NotificationManager::notificationLists_s[NotificationManager::queueList_s[queue]]; 176 175 -
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationOverlay.cc
r2781 r2783 87 87 } 88 88 89 const std::string NotificationOverlay::clipMessage(const std::string & str)89 const std::string NotificationOverlay::clipMessage(const std::string & message) 90 90 { 91 if( str.length() <= (unsigned int)this->queue_->getNotificationLength())92 return str;93 return str.substr(0, this->queue_->getNotificationLength());91 if(message.length() <= (unsigned int)this->queue_->getNotificationLength()) 92 return message; 93 return message.substr(0, this->queue_->getNotificationLength()); 94 94 } 95 95 -
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc
r2779 r2783 59 59 @brief 60 60 Destructor. 61 @todo62 I'm pretty sure that there are some thing that have to be distroyed.63 61 */ 64 62 NotificationQueue::~NotificationQueue() 65 63 { 66 64 this->targets_.clear(); 65 this->clear(); 67 66 } 68 67 … … 76 75 RegisterObject(NotificationQueue); 77 76 78 this->setDefaults();79 77 this->size_ = 0; 80 78 this->tickTime_ = 0.0; … … 107 105 SUPER(NotificationQueue, XMLPort, xmlElement, mode); 108 106 107 this->setDefaults(); 108 109 109 XMLPortParam(NotificationQueue, "maxSize", setMaxSize, getMaxSize, xmlElement, mode); 110 110 XMLPortParam(NotificationQueue, "notificationLength", setNotificationLength, getNotificationLength, xmlElement, mode); … … 135 135 { 136 136 this->removeContainer(*it); 137 this->scroll(Vector2(0.0,-(1.1*this->getFontSize()))); 137 138 it = this->containers_.begin(); //TDO: Needed? 138 139 } … … 176 177 this->addNotification(notification, time); 177 178 178 //TDO: Position!179 180 179 std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it; 181 180 while(this->getSize() > this->getMaxSize()) … … 183 182 it = this->containers_.begin(); 184 183 this->removeContainer(*it); 184 this->scroll(Vector2(0.0,-(1.1*this->getFontSize()))); 185 185 } 186 186 … … 241 241 /** 242 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(""); 243 Produces all targets concatinated as string, with kommas (',') as seperators. 244 @param string 245 Pointer to a string which will be used by the method to fill with the concatination of the targets. 246 @return 247 Returns true if successful. 248 */ 249 bool NotificationQueue::getTargets(std::string* string) const 250 { 251 if(string == NULL) 252 { 253 COUT(4) << "Input string must have memory allocated." << std::endl; 254 return false; 255 } 256 string->clear(); 252 257 bool first = true; 253 258 for(std::set<std::string>::iterator it = this->targets_.begin(); it != this->targets_.end(); it++) //!< Iterate through the set of targets. … … 255 260 if(!first) 256 261 { 257 * pTemp+= ",";262 *string += ","; 258 263 } 259 264 else … … 261 266 first = false; 262 267 } 263 * pTemp+= *it;264 } 265 266 return *pTemp;268 *string += *it; 269 } 270 271 return true; 267 272 } 268 273 … … 278 283 bool NotificationQueue::setTargets(const std::string & targets) 279 284 { 285 this->targets_.clear(); 286 280 287 std::string* pTemp; 281 288 unsigned int index = 0; … … 283 290 { 284 291 pTemp = new std::string(""); 285 while( targets[index] != ',' && targets[index] != ' ' && index < targets.size())292 while(index < targets.size() && targets[index] != ',' && targets[index] != ' ') 286 293 { 287 294 *pTemp += targets[index]; 288 295 index++; 289 296 } 297 index++; 290 298 this->targets_.insert(*pTemp); 291 299 } … … 331 339 return true; 332 340 } 333 341 342 void NotificationQueue::scroll(const Vector2 pos) 343 { 344 for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); ++it) //!< Scroll each overlay. 345 { 346 it->second->overlay->scroll(pos); 347 } 348 } 349 334 350 /** 335 351 @brief … … 358 374 this->insertElement(container->overlay, container->name); 359 375 this->size_= this->size_+1; 376 377 container->overlay->scroll(Vector2(0.0,(1.1*this->getFontSize())*(this->getSize()-1))); 360 378 } 361 379 -
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.h
r2779 r2783 44 44 #include <map> 45 45 #include <ctime> 46 #include "util/Math.h" 46 47 47 48 #include "orxonox/overlays/OverlayGroup.h" … … 120 121 inline const std::set<std::string> & getTargetsSet() 121 122 { return this->targets_; } 122 const std::string & getTargets() const; //!< Returns a string consisting of tehconcatination of the targets.123 bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets. 123 124 124 125 /** … … 134 135 inline const std::string & getFont() const 135 136 { return this->font_; } 137 138 void scroll(const Vector2 pos); 136 139 137 140 private:
Note: See TracChangeset
for help on using the changeset viewer.