Changeset 8637 for code/branches/presentation/src/modules
- Timestamp:
- May 28, 2011, 5:10:01 PM (14 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 4 deleted
- 16 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
/code/branches/tutoriallevel (added) merged: 7828-7831,7894,8370 /code/branches/tutoriallevel2 (added) merged: 8371,8374,8376-8378,8444-8451 /code/branches/tutoriallevel3 (added) merged: 8453,8634,8636
- Property svn:mergeinfo changed
-
code/branches/presentation/src/modules/notifications/CMakeLists.txt
r7403 r8637 1 1 SET_SOURCE_FILES(NOTIFICATIONS_SRC_FILES 2 Notification.cc3 2 NotificationDispatcher.cc 4 3 NotificationManager.cc 5 4 NotificationQueue.cc 5 NotificationQueueCEGUI.cc 6 6 ) 7 7 … … 13 13 TOLUA_FILES 14 14 NotificationManager.h 15 NotificationQueue .h15 NotificationQueueCEGUI.h 16 16 PCH_FILE 17 17 NotificationsPrecompiledHeaders.h -
code/branches/presentation/src/modules/notifications/NotificationDispatcher.cc
r7552 r8637 41 41 42 42 #include "infos/PlayerInfo.h" 43 #include "interfaces/NotificationListener.h" 43 44 #include "interfaces/PlayerTrigger.h" 44 45 #include "worldentities/pawns/Pawn.h" 45 46 #include "NotificationManager.h"47 46 48 47 namespace orxonox … … 61 60 RegisterObject(NotificationDispatcher); 62 61 63 this->sender_ = Notification Manager::NONE;62 this->sender_ = NotificationListener::NONE; 64 63 this->registerVariables(); 65 64 } … … 114 113 { 115 114 const std::string message = this->createNotificationMessage(); 116 NotificationManager::sendNotification(message, clientId, this->getSender()); 115 // TODO: Make the type configurable. 116 NotificationListener::sendNotification(message, this->getSender(), notificationMessageType::info, notificationSendMode::network, clientId); 117 117 } 118 118 else if(GameMode::isServer()) … … 164 164 if(player == NULL) 165 165 { 166 C OUT(3) << "The PlayerInfo* is NULL." << std::endl;166 CCOUT(3) << "The PlayerInfo* is NULL." << std::endl; 167 167 return false; 168 168 } -
code/branches/presentation/src/modules/notifications/NotificationManager.cc
r8079 r8637 36 36 #include "core/command/ConsoleCommand.h" 37 37 #include "core/CoreIncludes.h" 38 #include "core/GUIManager.h"39 38 #include "core/LuaState.h" 40 #include "network/Host.h"41 #include "network/NetworkFunction.h"42 39 #include "util/ScopedSingletonManager.h" 43 40 44 41 #include "interfaces/NotificationListener.h" 45 42 46 #include "Notification.h"47 43 #include "NotificationQueue.h" 48 49 #include "ToluaBindNotifications.h" 44 #include "NotificationQueueCEGUI.h" 50 45 51 46 namespace orxonox 52 47 { 53 48 54 const std::string NotificationManager::ALL("all");55 const std::string NotificationManager::NONE("none");56 57 // Register tolua_open function when loading the library.58 DeclareToluaInterface(Notifications);59 60 49 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); 61 50 62 // Setting console command to enter the edit mode.63 SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode);64 65 registerStaticNetworkFunction(NotificationManager::sendNotification);66 67 51 /** 68 52 @brief … … 73 57 RegisterRootObject(NotificationManager); 74 58 75 this->highestIndex_ = 0;76 77 ModifyConsoleCommand("enterEditMode").setObject(this);78 79 59 COUT(3) << "NotificatioManager created." << std::endl; 80 60 } … … 86 66 NotificationManager::~NotificationManager() 87 67 { 88 ModifyConsoleCommand("enterEditMode").setObject(NULL);89 90 68 // Destroys all Notifications. 91 69 for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++) … … 106 84 while(it != this->queues_.end()) 107 85 { 108 it->second->destroy( true);86 it->second->destroy(); 109 87 it = this->queues_.begin(); 110 88 } … … 115 93 /** 116 94 @brief 117 Sends a Notification with the specified message to the specified client from the specified sender. 95 Creates and registers a Notification with the input message from the input sender. 96 This is called by the NotificationListener, whenever a new notification arrives. 118 97 @param message 119 The message that should be sent. 120 @param clientId 121 The id of the client the notification should be sent to. 98 The message of the new Notification. 122 99 @param sender 123 The sender that sent the notification. 124 @param isLocal 125 If this is set to true (false is default), then the Notification is sent to the client where this function is executed, meaning the Notification is sent locally. 126 */ 127 /*static*/ void NotificationManager::sendNotification(const std::string& message, unsigned int clientId, const std::string& sender, bool isLocal) 128 { 129 // If we're in standalone mode or we're already no the right client we create and send the Notification. 130 if(GameMode::isStandalone() || isLocal || Host::getPlayerID() == clientId) 131 { 132 Notification* notification = new Notification(message, sender); 133 if(NotificationManager::getInstance().registerNotification(notification)) 134 COUT(3) << "Notification \"" << notification->getMessage() << "\" sent." << std::endl; 135 } 136 // If we're on the server (and the server is not the intended recipient of the Notification) we send it over the network. 137 else if(GameMode::isServer()) 138 { 139 callStaticNetworkFunction(NotificationManager::sendNotification, clientId, message, clientId, sender); 140 } 141 } 142 143 /** 144 @brief 145 Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender. 100 The name of the entity (of the collective) that sent the new Notification. 101 @param type 102 The type of the new Notification. 103 @return 104 Returns true if successful. 105 */ 106 bool NotificationManager::registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type) 107 { 108 // TODO: Do something with the type. 109 Notification* notification = new Notification(message, sender, type); 110 return this->registerNotification(notification); 111 } 112 113 /** 114 @brief 115 Executes the input command from the input sender. 116 This is called by the NotificationListener, whenever a new command arrives. 117 @param command 118 The command to be executed, 119 @param sender 120 The The name of the entity (of the collective) that sent the command. 121 @return 122 Returns true if the command was successfully executed. 123 */ 124 bool NotificationManager::executeCommand(notificationCommand::Value command, const std::string& sender) 125 { 126 bool commandExecuted = false; 127 if(command == notificationCommand::clear) 128 { 129 if(this->commandClear(sender)) 130 commandExecuted = true; 131 } 132 133 if(commandExecuted) 134 COUT(3) << "Notification command \"" << NotificationListener::command2Str(command) << "\" executed." << endl; 135 136 return commandExecuted; 137 } 138 139 /** 140 @brief 141 The clear command. Clears all NotificationQueues that have its sender as a target. 142 @param sender 143 The sender of the clear command. 144 @return 145 Returns true if the command was successfully executed by at least one NotificationQueue, false if it was not executed. 146 */ 147 bool NotificationManager::commandClear(const std::string& sender) 148 { 149 bool all = (sender == NotificationListener::ALL); 150 bool executed = false; 151 // Clear all NotificationQueues that have the input sender as target. 152 for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues. 153 { 154 const std::set<std::string>& set = it->second->getTargetsSet(); 155 // If either the sender is 'all', the NotificationQueue has as target all or the NotificationQueue has the input sender as a target. 156 if(all || set.find(NotificationListener::ALL) != set.end() || set.find(sender) != set.end()) 157 executed = it->second->tidy() || executed; 158 } 159 160 return executed; 161 } 162 163 /** 164 @brief 165 Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationQueues associated with its sender. 146 166 @param notification 147 167 The Notification to be registered. … … 158 178 this->allNotificationsList_.insert(std::pair<std::time_t, Notification*>(time, notification)); 159 179 160 if(notification->getSender() == Notification Manager::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.180 if(notification->getSender() == NotificationListener::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications. 161 181 return true; 162 182 163 bool all = false; 164 if(notification->getSender() == NotificationManager::ALL) // If all are the sender, then the Notifications is added to every NotificationListener. 165 all = true; 166 167 // Insert the Notification in all NotificationListeners that have its sender as target. 168 for(std::map<NotificationListener*, unsigned int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) // Iterate through all NotificationListeners. 169 { 170 const std::set<std::string>& set = it->first->getTargetsSet(); 171 bool bAll = set.find(NotificationManager::ALL) != set.end(); 172 // If either the Notification has as sender 'all', the NotificationListener displays all Notifications or the NotificationListener has the sender of the Notification as target. 183 // If all are the sender, then the Notifications is added to every NotificationQueue. 184 bool all = (notification->getSender() == NotificationListener::ALL); 185 186 // Insert the Notification in all NotificationQueues that have its sender as target. 187 for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues. 188 { 189 const std::set<std::string>& set = it->second->getTargetsSet(); 190 bool bAll = set.find(NotificationListener::ALL) != set.end(); 191 // If either the Notification has as sender 'all', the NotificationQueue displays all Notifications or the NotificationQueue has the sender of the Notification as target. 173 192 if(all || bAll || set.find(notification->getSender()) != set.end()) 174 193 { 175 194 if(!bAll) 176 this->notificationLists_[it->second ]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationListener.177 it-> first->update(notification, time); // Update the NotificationListener.195 this->notificationLists_[it->second->getName()]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationQueue. 196 it->second->update(notification, time); // Update the NotificationQueue. 178 197 } 179 198 } … … 186 205 /** 187 206 @brief 188 Unregisters a Notification within the NotificationManager for a given Notification Listener.207 Unregisters a Notification within the NotificationManager for a given NotificationQueue. 189 208 @param notification 190 209 A pointer to the Notification to be unregistered. 191 @param listener192 A pointer to the Notification Listenerthe Notification is unregistered for.193 */ 194 void NotificationManager::unregisterNotification(Notification* notification, Notification Listener* listener)210 @param queue 211 A pointer to the NotificationQueue the Notification is unregistered for. 212 */ 213 void NotificationManager::unregisterNotification(Notification* notification, NotificationQueue* queue) 195 214 { 196 215 assert(notification); 197 assert( listener);198 199 // Remove the Notification from the list of Notifications of the input Notification Listener.200 this->removeNotification(notification, *(this->notificationLists_.find( this->listenerList_.find(listener)->second)->second));201 202 COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from listener (&" << listener << ")" << std::endl;216 assert(queue); 217 218 // Remove the Notification from the list of Notifications of the input NotificationQueue. 219 this->removeNotification(notification, *(this->notificationLists_.find(queue->getName())->second)); 220 221 COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from NotificationQueue " << queue->getName() << "." << std::endl; 203 222 } 204 223 … … 230 249 /** 231 250 @brief 232 Registers a NotificationListener within the NotificationManager. 233 @param listener 234 The NotificationListener to be registered. 235 @return 236 Returns true if successful. Fales if the NotificationListener is already registered. 237 */ 238 bool NotificationManager::registerListener(NotificationListener* listener) 239 { 240 assert(listener); 241 242 // If the NotificationListener is already registered. 243 if(this->listenerList_.find(listener) != this->listenerList_.end()) 244 return false; 245 246 this->highestIndex_ += 1; 247 unsigned int index = this->highestIndex_; // An identifier that identifies each registered NotificationListener uniquely. 248 249 this->listenerList_[listener] = index; // Add the NotificationListener to the list of NotificationListeners. 250 251 const std::set<std::string>& set = listener->getTargetsSet(); 252 253 // If all senders are the target of the NotificationListener, then the list of Notifications for that specific NotificationListener is the same as the list of all Notifications. 254 bool bAll = set.find(NotificationManager::ALL) != set.end(); 255 std::multimap<std::time_t, Notification*>* map = NULL; 256 if(bAll) 257 this->notificationLists_[index] = &this->allNotificationsList_; 258 // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationListeners. 259 else 260 { 261 this->notificationLists_[index] = new std::multimap<std::time_t, Notification*>; 262 map = this->notificationLists_[index]; 263 } 264 265 // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener. 266 for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++) 267 { 268 if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target. 269 map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); 270 } 271 272 listener->update(); // Update the listener. 273 274 COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl; 275 276 return true; 277 } 278 279 /** 280 @brief 281 Unregisters a NotificationListener within the NotificationManager. 282 @param listener 283 The NotificationListener to be unregistered. 284 */ 285 void NotificationManager::unregisterListener(NotificationListener* listener) 286 { 287 assert(listener); 288 289 unsigned int identifier = this->listenerList_.find(listener)->second; 290 std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(identifier)->second; 291 292 // If the map is not the map of all Notifications, make sure all Notifications are unregistered. 293 std::multimap<std::time_t, Notification*>::iterator it = map->begin(); 294 if(map != &this->allNotificationsList_) 295 { 296 while(it != map->end()) 297 { 298 this->unregisterNotification(it->second, listener); 299 it = map->begin(); 300 } 301 delete map; 302 } 303 304 COUT(4) << "NotificationListener '" << identifier << "' unregistered with the NotificationManager." << std::endl; 305 306 // Remove the NotificationListener from the list of NotificationListeners. 307 this->listenerList_.erase(listener); 308 // Remove the Notifications list that was associated with the input NotificationListener. 309 this->notificationLists_.erase(identifier); 310 } 311 312 /** 313 @brief 314 Fetches the Notifications for a specific NotificationListener in a specified timeframe and stores them in the input map. 315 @param listener 316 The NotificationListener the Notifications are fetched for. 251 Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map. 252 @param queue 253 The NotificationQueue the Notifications are fetched for. 317 254 @param map 318 255 A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. … … 324 261 Returns true if successful. 325 262 */ 326 void NotificationManager::getNotifications(Notification Listener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)327 { 328 assert( listener);263 void NotificationManager::getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd) 264 { 265 assert(queue); 329 266 assert(map); 330 267 331 std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[ this->listenerList_[listener]]; // All the Notifications for the input NotificationListener.268 std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue. 332 269 333 270 std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest; … … 342 279 /** 343 280 @brief 344 Enters the edit mode of the NotificationLayer. 345 */ 346 void NotificationManager::enterEditMode(void) 347 { 348 if(GameMode::showsGraphics()) 349 { 350 GUIManager::getInstance().hideGUI("NotificationLayer"); 351 GUIManager::getInstance().showGUI("NotificationLayer", false, false); 352 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.enterEditMode()"); 281 Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map. 282 @param queue 283 The NotificationQueue the Notifications are fetched for. 284 @param map 285 A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. 286 @param numberOfNotifications 287 The number of newest Notifications to be got. 288 @return 289 Returns true if successful. 290 */ 291 void NotificationManager::getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications) 292 { 293 assert(queue); 294 assert(map); 295 296 std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue. 297 298 if(!notifications->empty()) // If the list of Notifications is not empty. 299 { 300 std::multimap<std::time_t,Notification*>::iterator it = notifications->end(); 301 for(int i = 0; i < numberOfNotifications; i++) // Iterate through the Notifications from the newest until we have the specified number of notifications. 302 { 303 it--; 304 map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); // Add the found Notifications to the map. 305 if(it == notifications->begin()) 306 break; 307 } 353 308 } 354 309 } … … 357 312 @brief 358 313 Registers a NotificationQueue. 359 This makes sure that the NotificationQueue can be a ttained through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.314 This makes sure that the NotificationQueue can be accessed through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager. 360 315 @param queue 361 316 A pointer to the NotificationQueue to be registered. … … 365 320 bool NotificationManager::registerQueue(NotificationQueue* queue) 366 321 { 322 assert(queue); 323 324 // If the NotificationQueue is already registered. 325 if(this->queues_.find(queue->getName()) != this->queues_.end()) 326 return false; 327 328 this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)); // Add the NotificationQueue to the list of NotificationQueues. 329 330 const std::set<std::string>& set = queue->getTargetsSet(); 331 332 // If all senders are the target of the NotificationQueue, then the list of Notifications for that specific NotificationQueue is the same as the list of all Notifications. 333 bool bAll = set.find(NotificationListener::ALL) != set.end(); 334 std::multimap<std::time_t, Notification*>* map = NULL; 335 if(bAll) 336 this->notificationLists_[queue->getName()] = &this->allNotificationsList_; 337 // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationQueues. 338 else 339 { 340 this->notificationLists_[queue->getName()] = new std::multimap<std::time_t, Notification*>; 341 map = this->notificationLists_[queue->getName()]; 342 } 343 344 // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue. 345 for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++) 346 { 347 if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target. 348 map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); 349 } 350 351 queue->update(); // Update the queue. 352 367 353 COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl; 368 return t his->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;354 return true; 369 355 } 370 356 … … 377 363 void NotificationManager::unregisterQueue(NotificationQueue* queue) 378 364 { 365 assert(queue); 366 367 std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(queue->getName())->second; 368 369 // If the map is not the map of all Notifications, make sure all Notifications are unregistered. 370 std::multimap<std::time_t, Notification*>::iterator it = map->begin(); 371 if(map != &this->allNotificationsList_) 372 { 373 while(it != map->end()) 374 { 375 this->unregisterNotification(it->second, queue); 376 it = map->begin(); 377 } 378 delete map; 379 } 380 381 // Remove the NotificationQueue from the list of NotificationQueues. 382 this->queues_.erase(queue->getName()); 383 // Remove the Notifications list that was associated with the input NotificationQueue. 384 this->notificationLists_.erase(queue->getName()); 385 379 386 COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl; 380 this->queues_.erase(queue->getName());381 }382 383 /**384 @brief385 Loads all the NotificationQueues that should exist.386 */387 void NotificationManager::loadQueues(void)388 {389 new NotificationQueue("all");390 }391 392 /**393 @brief394 Creates a new NotificationQueue.395 This is used in lua.396 @param name397 The name of the new NotificationQueue.398 */399 void NotificationManager::createQueue(const std::string& name)400 {401 new NotificationQueue(name);402 387 } 403 388 … … 420 405 } 421 406 407 /** 408 @brief 409 Loads all the NotificationQueues that should exist. 410 */ 411 void NotificationManager::loadQueues(void) 412 { 413 /*NotificationQueueCEGUI* allQueue = new NotificationQueueCEGUI("all"); 414 allQueue->setDisplaySize(Vector2(0.5, 0)); 415 allQueue->setPosition(Vector4(0.0, 10, 0.3, 0)); 416 417 NotificationQueueCEGUI* infoQueue = new NotificationQueueCEGUI("info", "gameinfo", 1, -1); 418 infoQueue->setPosition(Vector4(0.2, 0, 0.8, 0)); 419 infoQueue->setFontSize(24); 420 infoQueue->setFontColor(Vector4(1.0, 1.0, 0.0, 0.8)); 421 infoQueue->setAlignment("HorzCentred"); 422 infoQueue->setDisplaySize(Vector2(0.6, 0.0));*/ 423 } 424 425 // Notification class 426 427 /** 428 @brief 429 Constructor. Creates a Notification with the input message and sender. 430 @param message 431 The message of the Notification. 432 @param sender 433 The sender of the Notification. 434 @param type 435 436 */ 437 Notification::Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type) 438 { 439 this->initialize(); 440 this->message_ = message; 441 this->sender_ = sender; 442 this->type_ = type; 443 } 444 445 /** 446 @brief 447 Destructor. 448 */ 449 Notification::~Notification() 450 { 451 452 } 453 454 /** 455 @brief 456 Registers the object and sets some default values. 457 */ 458 void Notification::initialize(void) 459 { 460 this->message_.clear(); 461 this->sender_ = NotificationListener::NONE; 462 } 463 422 464 } -
code/branches/presentation/src/modules/notifications/NotificationManager.h
r7552 r8637 42 42 #include <string> 43 43 44 #include "core/OrxonoxClass.h" 44 45 #include "util/Singleton.h" 45 #include " core/OrxonoxClass.h"46 #include "interfaces/NotificationListener.h" 46 47 47 48 namespace orxonox // tolua_export … … 50 51 /** 51 52 @brief 52 The Singleton NotificationManager functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationListener "NotificationListeners". 53 It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationListener "NotificationListeners". 54 It also provides a static function to send @ref orxonox::Notification "Notifications" and works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer. 53 A Notification represents a short message used to inform the player about something that just happened. With the @ref orxonox::NotificationManager "NotificationManager" a Notification can be sent from any part of orxonox and is then displayed by the proper @ref orxonox::NotificationQueue "NotificationQueue(s)" (depending on which senders the specific @ref orxonox::NotificationQueue "NotificationQueues" accepts). 54 55 A Notification is just a data structure that is used internally by the Notifications module. 56 57 @author 58 Damian 'Mozork' Frick 59 60 @ingroup Notifications 61 */ 62 class _NotificationsExport Notification 63 { 64 public: 65 Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type); 66 virtual ~Notification(); 67 68 /** 69 @brief Destroys the Notification. 70 */ 71 void destroy(void) 72 { delete this; } 73 74 /** 75 @brief Get the message of the Notification. 76 @return Returns the message of the Notification. 77 */ 78 inline const std::string & getMessage(void) const 79 { return this->message_; } 80 81 /** 82 @brief Get the sender of the Notification. 83 @return Returns the sender of the Notification. 84 */ 85 inline const std::string & getSender(void) const 86 { return this->sender_; } 87 88 /** 89 @brief Get the type of the Notification. 90 @return Returns an enum with the type of the Notification. 91 */ 92 inline notificationMessageType::Value getType(void) const 93 { return this->type_; } 94 95 private: 96 std::string message_; //!< The Notification message. 97 std::string sender_; //!< The sender of the notification. 98 notificationMessageType::Value type_; //!< The type of the notification. 99 100 void initialize(void); //!< Registers the object and sets some default values. 101 102 }; 103 104 /** 105 @brief 106 The Singleton NotificationManager is a NotificationListener and functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationQueue "NotificationQueues". 107 It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationQueue "NotificationQueues". 108 It also works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer. 55 109 56 110 @author … … 60 114 */ 61 115 class _NotificationsExport NotificationManager // tolua_export 62 : public Singleton<NotificationManager>, public OrxonoxClass116 : public Singleton<NotificationManager>, public NotificationListener 63 117 { // tolua_export 64 118 friend class Singleton<NotificationManager>; … … 67 121 virtual ~NotificationManager(); 68 122 69 virtual void preDestroy(void); // !<Is called before the object is destroyed.123 virtual void preDestroy(void); // Is called before the object is destroyed. 70 124 71 125 /** … … 75 129 static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export 76 130 77 static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.78 static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener.131 virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type); 132 virtual bool executeCommand(notificationCommand::Value command, const std::string& sender); 79 133 80 //! Sends a Notification with the specified message to the specified client from the specified sender.81 static void sendNotification(const std::string& message, unsigned int clientId, const std::string& sender = NotificationManager::NONE, bool isLocal = false);134 bool registerNotification(Notification* notification); // Registers a Notification within the NotificationManager. 135 void unregisterNotification(Notification* notification, NotificationQueue* queue); // Unregisters a Notification within the NotificationManager for a given NotificationQueue. 82 136 83 bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. 84 void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager for a given NotificationListener. 85 bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager. 86 void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager. 87 88 void getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Fetches the Notifications for a specific NotificationListener in a specified timeframe and stores them in the input map. 137 void getNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); // Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map. 89 138 90 139 /** 91 @brief Fetches the Notifications for a specific Notification Listener in a timeframe from now-timeDelayto now and stores them in the input map.92 @param listener The NotificationListenerthe Notifications are fetched for.140 @brief Fetches the Notifications for a specific NotificationQueue in a timeframe from (now-timeDelay) to now and stores them in the input map. 141 @param queue The NotificationQueue the Notifications are fetched for. 93 142 @param map A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. 94 143 @param timeDelay The timespan. 95 144 @return Returns true if successful. 96 145 */ 97 void getNotifications(Notification Listener* listener, std::multimap<std::time_t, Notification*>* map, int timeDelay)98 { this->getNotifications( listener, map, std::time(0)-timeDelay, std::time(0)); }146 void getNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int timeDelay) 147 { this->getNotifications(queue, map, std::time(0)-timeDelay, std::time(0)); } 99 148 100 void enterEditMode(void); //!< Enters the edit mode of the NotificationLayer.149 void getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications); // Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map. 101 150 102 bool registerQueue(NotificationQueue* queue); // !<Registers a NotificationQueue.103 void unregisterQueue(NotificationQueue* queue); // !<Unregisters a NotificationQueue.151 bool registerQueue(NotificationQueue* queue); // Registers a NotificationQueue. 152 void unregisterQueue(NotificationQueue* queue); // Unregisters a NotificationQueue. 104 153 105 // tolua_begin 106 void loadQueues(void); //!< Loads all the NotificationQueues that should exist. 107 void createQueue(const std::string& name); //!< Creates a new NotificationQueue. 108 orxonox::NotificationQueue* getQueue(const std::string & name); //!< Get the NotificationQueue with the input name. 109 // tolua_end 154 void loadQueues(void); // tolua_export // Loads all the NotificationQueues that should exist. 155 156 NotificationQueue* getQueue(const std::string & name); // Get the NotificationQueue with the input name. 110 157 111 158 private: 112 159 static NotificationManager* singletonPtr_s; 113 160 114 unsigned int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.115 116 161 std::multimap<std::time_t, Notification*> allNotificationsList_; //!< Container where all Notifications are stored. 117 std::map<NotificationListener*, unsigned int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier. 118 std::map<int,std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored. 162 std::map<const std::string, std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored. 119 163 120 164 std::map<const std::string, NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager. 121 165 122 bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input Notification form an input map. 166 bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); // Helper method that removes an input Notification form an input map. 167 168 // Commands 169 bool commandClear(const std::string& sender); // The clear command. Clears all NotificationQueues that have its sender as a target. 123 170 124 171 }; // tolua_export -
code/branches/presentation/src/modules/notifications/NotificationQueue.cc
r8079 r8637 38 38 39 39 #include "core/CoreIncludes.h" 40 #include "core/GameMode.h" 41 #include "core/GUIManager.h" 42 #include "core/LuaState.h" 43 #include "util/Convert.h" 40 #include "core/XMLPort.h" 44 41 #include "util/SubString.h" 45 46 #include "Notification.h"47 42 48 43 namespace orxonox 49 44 { 50 45 51 /** 52 @brief 53 Constructor. Creates and initializes the object. 46 CreateFactory(NotificationQueue); 47 48 /** 49 @brief 50 Default constructor. Registers and initializes the object. 51 @param creator 52 The creator of the NotificationQueue. 53 */ 54 NotificationQueue::NotificationQueue(BaseObject* creator) : BaseObject(creator), registered_(false) 55 { 56 RegisterObject(NotificationQueue); 57 58 this->initialize(); 59 } 60 61 // TODO move to docu. 62 /** 63 @brief 64 Constructor. Registers and initializes the object. 65 @param creator 66 The creator of the NotificationQueue 54 67 @param name 55 68 The name of the new NotificationQueue. It needs to be unique … … 62 75 The time during which a Notification is (at most) displayed. 63 76 */ 64 NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime) 65 { 66 this->registered_ = false; 67 68 RegisterRootObject(NotificationQueue); 69 70 // Initialize. 77 78 /** 79 @brief 80 Destructor. 81 */ 82 NotificationQueue::~NotificationQueue() 83 { 84 this->targets_.clear(); 85 86 if(this->isRegistered()) // If the NotificationQueue is registered. 87 { 88 this->clear(true); 89 90 // Unregister with the NotificationManager. 91 NotificationManager::getInstance().unregisterQueue(this); 92 } 93 } 94 95 /** 96 @brief 97 Initializes the NotificationQueue. 98 */ 99 void NotificationQueue::initialize(void) 100 { 71 101 this->size_ = 0; 72 102 this->tickTime_ = 0.0f; 73 74 // Sets the input values. 75 this->setTargets(senders); 76 this->name_ = name; 77 this->maxSize_ = size; 78 this->setDisplayTime(displayTime); 79 103 this->maxSize_ = NotificationQueue::DEFAULT_SIZE; 104 this->displayTime_ = NotificationQueue::DEFAULT_DISPLAY_TIME; 105 106 this->creationTime_ = std::time(0); 107 } 108 109 /** 110 @brief 111 Creates the NotificationQueue. 112 */ 113 void NotificationQueue::create(void) 114 { 80 115 // Register the NotificationQueue with the NotificationManager. 81 116 bool queueRegistered = NotificationManager::getInstance().registerQueue(this); … … 88 123 } 89 124 90 this->create(); // Creates the NotificationQueue in lua.91 92 // Register the NotificationQueue as NotificationListener with the NotificationManager.93 bool listenerRegistered = NotificationManager::getInstance().registerListener(this);94 if(!listenerRegistered) // If the registration has failed.95 {96 this->registered_ = false;97 // Remove the NotificationQueue in lua.98 if(GameMode::showsGraphics())99 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")");100 NotificationManager::getInstance().unregisterQueue(this);101 COUT(1) << "Error: NotificationQueue '" << this->getName() << "' could not be registered." << std::endl;102 return;103 }104 105 125 COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl; 106 }107 108 /**109 @brief110 Destructor.111 */112 NotificationQueue::~NotificationQueue()113 {114 this->targets_.clear();115 116 if(this->registered_) // If the NotificationQueue is registered.117 {118 this->clear(true);119 120 // Unregister with the NotificationManager.121 NotificationManager::getInstance().unregisterListener(this);122 NotificationManager::getInstance().unregisterQueue(this);123 }124 }125 126 /**127 @brief128 Destroys the NotificationQueue.129 Used in lua and NotificationManager.130 @param noGraphics131 If this is set to true (false is default), then the queue is not removed in lua. This is used to destroy the queue, after the GUIManager has been destroyed.132 */133 void NotificationQueue::destroy(bool noGraphics)134 {135 // Remove the NotificationQueue in lua.136 if(GameMode::showsGraphics() && !noGraphics)137 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")");138 139 COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl;140 141 this->OrxonoxClass::destroy();142 }143 144 /**145 @brief146 Creates the NotificationQueue in lua.147 */148 void NotificationQueue::create(void)149 {150 if(GameMode::showsGraphics())151 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");152 126 } 153 127 … … 161 135 { 162 136 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.164 { 165 this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containi g the current time.137 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. 138 { 139 this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containing the current time. 166 140 167 141 std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = this->ordering_.begin(); … … 177 151 } 178 152 153 void NotificationQueue::XMLPort(Element& xmlelement, XMLPort::Mode mode) 154 { 155 SUPER(NotificationQueue, XMLPort, xmlelement, mode); 156 157 XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlelement, mode).defaultValues(NotificationListener::ALL); 158 XMLPortParam(NotificationQueue, "size", setMaxSize, getMaxSize, xmlelement, mode); 159 XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlelement, mode); 160 161 this->create(); 162 } 163 179 164 /** 180 165 @brief 181 166 Updates the NotificationQueue. 182 167 Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting them into the queue. 168 This is called by the NotificationManager when the Notifications have changed so much, that the NotificationQueue may have to re-initialize his operations. 183 169 */ 184 170 void NotificationQueue::update(void) … … 188 174 std::multimap<std::time_t, Notification*>* notifications = new std::multimap<std::time_t, Notification*>; 189 175 // Get the Notifications sent in the interval from now to now minus the display time. 190 NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_); 176 if(this->displayTime_ == INF) 177 NotificationManager::getInstance().getNewestNotifications(this, notifications, this->getMaxSize()); 178 else 179 NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_); 191 180 192 181 if(!notifications->empty()) 193 182 { 194 // Add all Notifications .183 // Add all Notifications that have been created after this NotificationQueue was created. 195 184 for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) 196 this->push(it->second, it->first); 185 { 186 if(it->first >= this->creationTime_) 187 this->push(it->second, it->first); 188 } 197 189 } 198 190 … … 246 238 this->notifications_.insert(this->notifications_.begin(), container); 247 239 248 // Push the Notification to the GUI. 249 if(GameMode::showsGraphics()) 250 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")"); 240 // Inform that a Notification was pushed. 241 this->notificationPushed(notification); 251 242 252 243 COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl; 244 COUT(3) << "NotificationQueue \"" << this->getName() << "\": " << notification->getMessage() << endl; 253 245 } 254 246 … … 279 271 delete container; 280 272 281 // Pops the Notification from the GUI. 282 if(GameMode::showsGraphics()) 283 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")"); 273 // Inform that a Notification was popped. 274 this->notificationPopped(); 284 275 } 285 276 … … 305 296 delete *containerIterator; 306 297 307 // Removes the Notification from the GUI.308 if(GameMode::showsGraphics())309 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");298 // TODO: index automatically cast? 299 // Inform that a Notification was removed. 300 this->notificationRemoved(index); 310 301 } 311 302 … … 314 305 Clears the NotificationQueue by removing all NotificationContainers. 315 306 @param noGraphics 316 If this is eset to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally.307 If this is set to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally. 317 308 */ 318 309 void NotificationQueue::clear(bool noGraphics) … … 326 317 this->notifications_.clear(); 327 318 this->size_ = 0; 328 329 // Clear the NotificationQueue in the GUI.330 if(GameMode::showsGraphics() && !noGraphics)331 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");332 319 } 333 320 … … 354 341 return; 355 342 343 if(size == 0) 344 { 345 COUT(2) << "Trying to set maximal size of NotificationQueue '" << this->getName() << "' to 0. Ignoring..." << endl; 346 return; 347 } 348 356 349 this->maxSize_ = size; 357 350 358 if(this-> registered_)351 if(this->isRegistered()) 359 352 this->update(); 360 353 } … … 364 357 Sets the maximum number of seconds a Notification is displayed. 365 358 @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) 359 The number of seconds a Notification is displayed. 360 */ 361 void NotificationQueue::setDisplayTime(int time) 371 362 { 372 363 if(this->displayTime_ == time) 373 364 return; 374 365 366 if(time != NotificationQueue::INF && time <= 0) 367 { 368 COUT(2) << "Trying to set display time of NotificationQueue '" << this->getName() << "' to non-positive value. Ignoring..." << endl; 369 } 370 375 371 this->displayTime_ = time; 376 372 377 if(this-> registered_)373 if(this->isRegistered()) 378 374 this->update(); 379 375 } … … 381 377 /** 382 378 @brief 383 Produces all targets of the NotificationQueue concat inated as string, with commas (',') as seperators.379 Produces all targets of the NotificationQueue concatenated as string, with commas (',') as separators. 384 380 @return 385 381 Returns the targets as a string. … … 407 403 The targets are the senders whose Notifications are displayed in this queue. 408 404 @param targets 409 Accepts a string of targets, each sep erated by commas (','), spaces are ignored.405 Accepts a string of targets, each separated by commas (','), spaces are ignored. 410 406 */ 411 407 void NotificationQueue::setTargets(const std::string & targets) … … 417 413 this->targets_.insert(string[i]); 418 414 419 if(this->registered_) 420 { 421 NotificationManager::getInstance().unregisterListener(this); 422 NotificationManager::getInstance().registerListener(this); 423 } 415 // TODO: Why? 416 if(this->isRegistered()) 417 { 418 NotificationManager::getInstance().unregisterQueue(this); 419 NotificationManager::getInstance().registerQueue(this); 420 } 421 } 422 423 /** 424 @brief 425 Pops all Notifications from the NotificationQueue. 426 @return 427 Returns true if successful, false if not. 428 */ 429 bool NotificationQueue::tidy(void) 430 { 431 while(this->size_ > 0) 432 this->pop(); 433 return true; 424 434 } 425 435 -
code/branches/presentation/src/modules/notifications/NotificationQueue.h
r7552 r8637 45 45 #include "NotificationManager.h" 46 46 47 #include "core/BaseObject.h" 47 48 #include "tools/interfaces/Tickable.h" 48 #include "interfaces/NotificationListener.h" 49 50 namespace orxonox // tolua_export 51 { // tolua_export 49 50 namespace orxonox 51 { 52 52 53 53 /** … … 78 78 Displays @ref orxonox::Notification "Notifications" from specific senders. 79 79 80 There are quite some parameters that influence the behavio ur of the NotificationQueue:80 There are quite some parameters that influence the behavior of the NotificationQueue: 81 81 - @b name The name of the NotificationQueue. It needs to be unique. 82 82 - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays. … … 89 89 @ingroup Notifications 90 90 */ 91 class _NotificationsExport NotificationQueue // tolua_export 92 : public Tickable, public NotificationListener 93 { // tolua_export 91 class _NotificationsExport NotificationQueue : public BaseObject, public Tickable 92 { 94 93 95 94 public: 96 NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME); 95 NotificationQueue(BaseObject* creator); 96 NotificationQueue(BaseObject* creator, const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME); 97 97 virtual ~NotificationQueue(); 98 98 99 //! Destroys the NotificationQueue. 100 void destroy(bool noGraphics = false); // tolua_export 101 102 virtual void tick(float dt); //!< To update from time to time. 103 104 void update(void); //!< Updates the NotificationQueue. 105 void update(Notification* notification, const std::time_t & time); //!< Updates the NotificationQueue by adding an new Notification. 99 virtual void tick(float dt); // To update from time to time. 100 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 101 102 void update(void); // Updates the NotificationQueue. 103 void update(Notification* notification, const std::time_t & time); // Updates the NotificationQueue by adding an new Notification. 106 104 107 105 // tolua_begin … … 110 108 @return Returns the name. 111 109 */ 112 inline const std::string& getName( ) const113 { return this-> name_; }114 115 void setMaxSize(unsigned int size); // !<Sets the maximum number of displayed Notifications.110 inline const std::string& getName(void) const 111 { return this->BaseObject::getName(); } 112 113 void setMaxSize(unsigned int size); // Sets the maximum number of displayed Notifications. 116 114 /** 117 115 @brief Returns the maximum number of Notifications displayed. 118 116 @return Returns maximum size. 119 117 */ 120 inline unsigned int getMaxSize( ) const118 inline unsigned int getMaxSize(void) const 121 119 { return this->maxSize_; } 122 120 123 void setDisplayTime( unsigned int time); //!<Sets the maximum number of seconds a Notification is displayed.121 void setDisplayTime(int time); // Sets the maximum number of seconds a Notification is displayed. 124 122 /** 125 123 @brief Returns the time interval the Notification is displayed. 126 124 @return Returns the display time. 127 125 */ 128 inline unsigned int getDisplayTime() const126 inline int getDisplayTime(void) const 129 127 { return this->displayTime_; } 130 128 // tolua_end … … 134 132 @return Returns the size of the NotificationQueue. 135 133 */ 136 inline unsigned int getSize( ) const134 inline unsigned int getSize(void) const 137 135 { return this->size_; } 138 136 … … 141 139 @return Returns a set of strings holding the different targets. 142 140 */ 143 inline const std::set<std::string> & getTargetsSet( )141 inline const std::set<std::string> & getTargetsSet(void) 144 142 { return this->targets_; } 145 143 146 // tolua_begin 147 void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue. 148 const std::string& getTargets(void) const; //!< Returns a string consisting of the concatination of the targets. 149 // tolua_end 150 151 private: 144 void setTargets(const std::string & targets); // Set the targets of this NotificationQueue. 145 const std::string& getTargets(void) const; // Returns a string consisting of the concatenation of the targets. 146 147 /** 148 @brief Check whether the NotificationQueue is registered with the NotificationManager. 149 @return Returns true if it is registered, false if not. 150 */ 151 inline bool isRegistered(void) 152 { return this->registered_; } 153 154 bool tidy(void); // Pops all Notifications from the NotificationQueue. 155 156 protected: 157 /** 158 @brief Is called when a notification was pushed. 159 @param notification The Notification that was pushed. 160 */ 161 virtual void notificationPushed(Notification* notification) {} 162 /** 163 @brief Is called when a notification was popped. 164 */ 165 virtual void notificationPopped(void) {} 166 /** 167 @brief Is called when a notification was removed. 168 @param index The index the removed notification was at. 169 */ 170 virtual void notificationRemoved(unsigned int index) {} 171 172 virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers. 173 174 protected: 152 175 static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. 153 176 static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time. 154 155 std::string name_; //!< The name of the NotificationQueue. 156 177 static const int INF = -1; //!< Constant denoting infinity. 178 179 virtual void create(void); // Creates the NotificationQueue. 180 181 private: 182 void initialize(void); // Initializes the NotificationQueue. 183 184 time_t creationTime_; // The time this NotificationQueue was created. 185 157 186 unsigned int maxSize_; //!< The maximal number of Notifications displayed. 158 187 unsigned int size_; //!< The number of Notifications displayed. 159 unsignedint displayTime_; //!< The time a Notification is displayed.188 int displayTime_; //!< The time a Notification is displayed. 160 189 161 190 bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already. … … 169 198 NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 170 199 171 void create(void); //!< Creates the NotificationQueue in lua.172 173 200 void setName(const std::string& name); //!< Sets the name of the NotificationQueue. 174 201 175 void push(Notification* notification, const std::time_t & time); //!< Adds (pushes) a Notification to the NotificationQueue. 176 void pop(void); //!< Removes (pops) the least recently added Notification form the NotificationQueue. 177 void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer. 178 179 void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers. 180 181 }; // tolua_export 182 183 } // tolua_export 184 185 #endif /* _NotificationOverlay_H__ */ 202 void push(Notification* notification, const std::time_t & time); // Adds (pushes) a Notification to the NotificationQueue. 203 void pop(void); // Removes (pops) the least recently added Notification form the NotificationQueue. 204 void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); // Removes the Notification that is stored in the input NotificationContainer. 205 206 }; 207 208 } 209 210 #endif /* _NotificationQueue_H__ */ -
code/branches/presentation/src/modules/objects/triggers/DistanceTrigger.cc
r8213 r8637 280 280 Check whether the DistanceTrigger is triggered. 281 281 It is triggered if it is triggered according only to its mode (i.e. its sub-triggers) and if a target is in range. 282 @param 282 @param mode 283 The mode for which it is tested, whether the DistanceTrigger is triggered. 284 @return 283 285 Returns true if it is triggered ,false if not. 284 286 */ -
code/branches/presentation/src/modules/objects/triggers/DistanceTrigger.h
r8213 r8637 71 71 - @b target Which specifies the class of objects that can trigger the DistanceTrigger. Default is <code>"Pawn"</code>. 72 72 - @b beaconMode Which specifies, whether the DistanceTrigger operates on @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacons" or not. If <em>off</em> the DistanceMultiTrigger works as usual. If set to <em>identify</em> the DistanceTrigger is only triggered by objects that have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon", with the same name as specified in <em>targetname</em>, attached to them. If set to <em>exclude</em> the DistanceTrigger is only triggered by objects that don't have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon", with the same name as specified in <em>targetname</em>, attached to them. Default is <em>off</em>. 73 - @b targetname Which specifies the name @ref or oxnox::DistanceTriggerBeacon "DistanceTriggerBeacons" need to have to make the DistanceTrigger react to them if it is in <em>beacon-mode</em> (the beaconMode is not <em>off</em>).73 - @b targetname Which specifies the name @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacons" need to have to make the DistanceTrigger react to them if it is in <em>beacon-mode</em> (the beaconMode is not <em>off</em>). 74 74 75 75 A simple DistanceTrigger could look like this: -
code/branches/presentation/src/modules/objects/triggers/EventTrigger.h
r8213 r8637 60 60 61 61 @see Trigger 62 For more information on @ref or oxnox::Trigger "Triggers".62 For more information on @ref orxonox::Trigger "Triggers". 63 63 64 64 @author -
code/branches/presentation/src/modules/objects/triggers/MultiTrigger.cc
r8561 r8637 198 198 if(bActive ^ this->isActive(state->originator)) 199 199 { 200 201 200 bool bFire = true; 202 201 -
code/branches/presentation/src/modules/objects/triggers/TriggerBase.h
r8213 r8637 133 133 inline int getActivations(void) const 134 134 { return this->remainingActivations_; } 135 /** 136 @brief Check whether the trigger has still at least one remaining activation. 137 @return Returns true if the trigger has remaining activations (i.e. the number of remaining activations is not zero). 138 */ 139 inline bool hasRemainingActivations(void) const 140 { return this->remainingActivations_ > 0 || this->remainingActivations_ == INF_s; } 135 141 136 142 /** -
code/branches/presentation/src/modules/overlays/hud/CMakeLists.txt
r8178 r8637 7 7 HUDTimer.cc 8 8 ChatOverlay.cc 9 GametypeStatus.cc10 9 AnnounceMessage.cc 11 10 KillMessage.cc -
code/branches/presentation/src/modules/questsystem/QuestDescription.cc
r7474 r8637 40 40 #include "infos/PlayerInfo.h" 41 41 42 #include " notifications/NotificationManager.h"42 #include "interfaces/NotificationListener.h" 43 43 44 44 namespace orxonox … … 119 119 } 120 120 121 Notification Manager::sendNotification(message, player->getClientID(), QuestDescription::SENDER);121 NotificationListener::sendNotification(message, QuestDescription::SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID()); 122 122 return true; 123 123 } -
code/branches/presentation/src/modules/questsystem/QuestManager.cc
r8079 r8637 274 274 int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player) 275 275 { 276 if(quest == NULL) 277 return this->getNumRootQuests(player); 278 276 279 std::list<Quest*> quests = quest->getSubQuestList(); 277 280 int numQuests = 0; … … 296 299 Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index) 297 300 { 301 if(quest == NULL) 302 return this->getRootQuest(player, index); 303 298 304 std::list<Quest*> quests = quest->getSubQuestList(); 299 305 for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++) … … 312 318 @param player 313 319 The player. 314 @return Returns the number of QuestHints of the input Quest for the input player. 320 @return 321 Returns the number of QuestHints of the input Quest for the input player. 315 322 */ 316 323 int QuestManager::getNumHints(Quest* quest, PlayerInfo* player) … … 335 342 @param index 336 343 The index of the QuestHint. 344 @return 345 Returns a pointer to the index-th QuestHint of the input Quest for the input player. 337 346 */ 338 347 QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index) … … 345 354 } 346 355 return NULL; 356 } 357 358 /** 359 @brief 360 Get the parent-quest of the input Quest. 361 @param quest 362 The Quest to get the parent-quest of. 363 @return 364 Returns a pointer to the parent-quest of the input Quest. 365 */ 366 Quest* QuestManager::getParentQuest(Quest* quest) 367 { 368 return quest->getParentQuest(); 347 369 } 348 370 … … 375 397 /** 376 398 @brief 399 Get the id of the input Quest. 400 @param item 401 The Quest to get the id of. 402 @return 403 Returns the id of the input Quest. 404 */ 405 const std::string QuestManager::getId(Quest* item) const 406 { 407 return item->getId(); 408 } 409 410 /** 411 @brief 412 Get the id of the input QuestHint. 413 @param item 414 The QuestHint to get the id of. 415 @return 416 Returns the id of the input QuestHint. 417 */ 418 const std::string QuestManager::getId(QuestHint* item) const 419 { 420 return item->getId(); 421 } 422 423 /** 424 @brief 377 425 Retrieve the player for a certain GUI. 378 426 @param guiName -
code/branches/presentation/src/modules/questsystem/QuestManager.h
r7552 r8637 81 81 QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index); //!< Get the index-th QuestHint of the input Quest for the input player. 82 82 83 QuestDescription* getDescription(Quest* item); 84 QuestDescription* getDescription(QuestHint* item); 83 Quest* getParentQuest(Quest* quest); //!< Get the parent-quest of the input Quest. 84 85 QuestDescription* getDescription(Quest* item); //!< Get the QuestDescription of the input Quest. 86 QuestDescription* getDescription(QuestHint* item); //!< Get the QuestDescription of the input QuestHint. 87 88 const std::string getId(Quest* item) const; //!< Get the id of the input Quest. 89 const std::string getId(QuestHint* item) const; //!< Get the id of the input QuestHint. 85 90 // tolua_end 86 91
Note: See TracChangeset
for help on using the changeset viewer.