Changeset 8371 for code/branches/tutoriallevel2/src/modules/notifications
- Timestamp:
- May 1, 2011, 2:43:33 PM (14 years ago)
- Location:
- code/branches/tutoriallevel2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutoriallevel2
- Property svn:mergeinfo changed
/code/branches/tutoriallevel (added) merged: 7828-7831,7894,8370
- Property svn:mergeinfo changed
-
code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc
r8079 r8371 40 40 #include "network/Host.h" 41 41 #include "network/NetworkFunction.h" 42 #include "util/Convert.h" 42 43 #include "util/ScopedSingletonManager.h" 43 44 … … 342 343 /** 343 344 @brief 345 Fetches the newest Notifications for a specific NotificationListener and stores them in the input map. 346 @param listener 347 The NotificationListener the Notifications are fetched for. 348 @param map 349 A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. 350 @param numberOfNotifications 351 The number of newest Notifications to be got. 352 @return 353 Returns true if successful. 354 */ 355 void NotificationManager::getNewestNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications) 356 { 357 assert(listener); 358 assert(map); 359 360 std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // All the Notifications for the input NotificationListener. 361 362 if(!notifications->empty()) // If the list of Notifications is not empty. 363 { 364 std::multimap<std::time_t,Notification*>::iterator it = notifications->end(); 365 for(int i = 0; i < numberOfNotifications; i++) // Iterate through the Notifications from the newest until we have the specified number of notifications. 366 { 367 it--; 368 map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); // Add the found Notifications to the map. 369 if(it == notifications->begin()) 370 break; 371 } 372 } 373 } 374 375 /** 376 @brief 344 377 Enters the edit mode of the NotificationLayer. 345 378 */ … … 387 420 void NotificationManager::loadQueues(void) 388 421 { 389 new NotificationQueue("all"); 422 NotificationQueue* allQueue = new NotificationQueue("all"); 423 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"all\", 0.5, 0, " + multi_cast<std::string>(allQueue->getMaxSize()) + ")"); 424 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)"); 425 426 NotificationQueue* infoQueue = new NotificationQueue("info", NotificationManager::ALL, 1, -1); 427 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"FFFFFF00\")"); 428 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")"); 429 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"info\", 0.2, 0, 0.8, 0)"); 390 430 } 391 431 -
code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h
r7552 r8371 98 98 { this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); } 99 99 100 void getNewestNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications); //!< Fetches the newest Notifications for a specific NotificationListener and stores them in the input map. 101 100 102 void enterEditMode(void); //!< Enters the edit mode of the NotificationLayer. 101 103 -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc
r8079 r8371 161 161 { 162 162 this->tickTime_ += dt; // Add the time interval that has passed to the time counter. 163 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.163 if(this->displayTime_ != INF && 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. 164 164 { 165 165 this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containig the current time. … … 188 188 std::multimap<std::time_t, Notification*>* notifications = new std::multimap<std::time_t, Notification*>; 189 189 // Get the Notifications sent in the interval from now to now minus the display time. 190 NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_); 190 if(this->displayTime_ == INF) 191 NotificationManager::getInstance().getNewestNotifications(this, notifications, this->getMaxSize()); 192 else 193 NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_); 191 194 192 195 if(!notifications->empty()) … … 364 367 Sets the maximum number of seconds a Notification is displayed. 365 368 @param time 366 The number of seconds the Notifications is displayed. 367 @return 368 Returns true if successful. 369 */ 370 void NotificationQueue::setDisplayTime(unsigned int time) 369 The number of seconds a Notification is displayed. 370 */ 371 void NotificationQueue::setDisplayTime(int time) 371 372 { 372 373 if(this->displayTime_ == time) -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h
r7552 r8371 121 121 { return this->maxSize_; } 122 122 123 void setDisplayTime( unsignedint time); //!< Sets the maximum number of seconds a Notification is displayed.123 void setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed. 124 124 /** 125 125 @brief Returns the time interval the Notification is displayed. 126 126 @return Returns the display time. 127 127 */ 128 inline unsignedint getDisplayTime() const128 inline int getDisplayTime() const 129 129 { return this->displayTime_; } 130 130 // tolua_end … … 152 152 static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. 153 153 static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time. 154 static const int INF = -1; //!< Constant denoting infinity. 154 155 155 156 std::string name_; //!< The name of the NotificationQueue. … … 157 158 unsigned int maxSize_; //!< The maximal number of Notifications displayed. 158 159 unsigned int size_; //!< The number of Notifications displayed. 159 unsignedint displayTime_; //!< The time a Notification is displayed.160 int displayTime_; //!< The time a Notification is displayed. 160 161 161 162 bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
Note: See TracChangeset
for help on using the changeset viewer.