Changeset 7489 for code/trunk/src/modules/notifications
- Timestamp:
- Sep 24, 2010, 4:01:04 PM (14 years ago)
- Location:
- code/trunk/src/modules/notifications
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/notifications/Notification.cc
r7488 r7489 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "network/NetworkFunction.h"38 #include "network/Host.h"39 37 #include "NotificationManager.h" 40 38 … … 44 42 /** 45 43 @brief 46 Default constructor. Initializes the object. 47 */ 48 Notification::Notification() 49 { 50 RegisterRootObject(Notification); 51 this->initialize(); 52 } 53 54 /** 55 @brief 56 Constructor. Creates a Notification with the input message. 57 @param creator 58 The creator. 44 Constructor. Creates a Notification with the input message and sender. 59 45 @param message 60 46 The message of the Notification. 47 @param sender 48 The sender of the Notification. 61 49 */ 62 50 Notification::Notification(const std::string& message, const std::string& sender) -
code/trunk/src/modules/notifications/Notification.h
r7488 r7489 39 39 40 40 #include <string> 41 #include "core/ BaseObject.h"41 #include "core/OrxonoxClass.h" 42 42 43 43 namespace orxonox … … 46 46 /** 47 47 @brief 48 A Notification is a short message used to inform the player about something that just happened. A Notification can be sent from any part of orxonox and is then displayed in the proper @ref orxonox::NotificationQueue "NotificationQueue" (depending on which senders the specific @ref orxonox::NotificationQueue "NotificationQueue" accepts). 48 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). 49 50 A Notification is just a datastructure that is used internally by the Notifications module. 49 51 @author 50 52 Damian 'Mozork' Frick … … 53 55 { 54 56 public: 55 Notification();56 57 Notification(const std::string& message, const std::string& sender); 57 58 virtual ~Notification(); 58 59 59 60 /** 60 @brief Returnsthe message of the Notification.61 @brief Get the message of the Notification. 61 62 @return Returns the message of the Notification. 62 63 */ … … 64 65 { return this->message_; } 65 66 67 /** 68 @brief Get the sender of the Notification. 69 @return Returns the sender of the Notification. 70 */ 66 71 inline const std::string & getSender(void) const 67 72 { return this->sender_; } -
code/trunk/src/modules/notifications/NotificationDispatcher.cc
r7488 r7489 44 44 #include "worldentities/pawns/Pawn.h" 45 45 46 #include "Notification.h"47 46 #include "NotificationManager.h" 48 47 -
code/trunk/src/modules/notifications/NotificationManager.cc
r7488 r7489 104 104 // Destroys all NotificationQueues that have been registered with the NotificationManager. 105 105 for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) 106 {107 106 it->second->destroy(true); 108 } 107 109 108 this->queues_.clear(); 110 109 } … … 343 342 void NotificationManager::enterEditMode(void) 344 343 { 345 GUIManager::getInstance().hideGUI("NotificationLayer"); 346 GUIManager::getInstance().showGUI("NotificationLayer", false, false); 347 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.enterEditMode()"); 344 if(GameMode::showsGraphics()) 345 { 346 GUIManager::getInstance().hideGUI("NotificationLayer"); 347 GUIManager::getInstance().showGUI("NotificationLayer", false, false); 348 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.enterEditMode()"); 349 } 348 350 } 349 351 -
code/trunk/src/modules/notifications/NotificationManager.h
r7486 r7489 52 52 The Singleton NotificationManager functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationListener "NotificationListeners". 53 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.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. 55 55 @author 56 56 Damian 'Mozork' Frick -
code/trunk/src/modules/notifications/NotificationQueue.cc
r7488 r7489 90 90 this->create(); // Creates the NotificationQueue in lua. 91 91 92 // register the NotificationQueue as NotificationListener with the NotificationManager.92 // Register the NotificationQueue as NotificationListener with the NotificationManager. 93 93 bool listenerRegistered = NotificationManager::getInstance().registerListener(this); 94 94 if(!listenerRegistered) // If the registration has failed. … … 96 96 this->registered_ = false; 97 97 // Remove the NotificationQueue in lua. 98 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")"); 98 if(GameMode::showsGraphics()) 99 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")"); 99 100 NotificationManager::getInstance().unregisterQueue(this); 100 101 COUT(1) << "Error: NotificationQueue '" << this->getName() << "' could not be registered." << std::endl; … … 210 211 void NotificationQueue::update(Notification* notification, const std::time_t & time) 211 212 { 213 assert(notification); 214 212 215 this->push(notification, time); 213 216 … … 226 229 void NotificationQueue::push(Notification* notification, const std::time_t & time) 227 230 { 231 assert(notification); 232 228 233 NotificationContainer* container = new NotificationContainer; 229 234 container->notification = notification; … … 254 259 // Get all the NotificationContainers that were sent the same time the NotificationContainer we want to pop was sent. 255 260 std::pair<std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator, std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator> iterators = this->ordering_.equal_range(container); 256 // Iterate th ourgh all suspects and remove the container as soon as we find it.261 // Iterate through all suspects and remove the container as soon as we find it. 257 262 for(std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = iterators.first; it != iterators.second; it++) 258 263 { … … 311 316 312 317 this->notifications_.clear(); 313 314 318 this->size_ = 0; 315 319 -
code/trunk/src/modules/notifications/NotificationQueue.h
r7488 r7489 43 43 #include <vector> 44 44 45 #include "NotificationManager.h" 46 45 47 #include "tools/interfaces/Tickable.h" 46 47 48 #include "interfaces/NotificationListener.h" 48 #include "NotificationManager.h"49 49 50 50 namespace orxonox // tolua_export … … 54 54 struct NotificationContainer 55 55 { 56 Notification* notification; // The Notification displayed.57 time_t time; // The time the Notification was sent and thus first displayed.56 Notification* notification; //!< The Notification displayed. 57 time_t time; //!< The time the Notification was sent and thus first displayed. 58 58 }; 59 59 … … 61 61 struct NotificationContainerCompare { 62 62 bool operator() (const NotificationContainer* const & a, const NotificationContainer* const & b) const 63 { return a->time < b->time; } // Orderedby time.63 { return a->time < b->time; } //!< Ordering by time. 64 64 }; 65 65 -
code/trunk/src/modules/notifications/dispatchers/CommandNotification.cc
r7484 r7489 64 64 CommandNotification::~CommandNotification() 65 65 { 66 66 67 67 } 68 68 … … 114 114 Returns a human readable version of the input binding. 115 115 */ 116 //TODO: Move to KeyBinderManager... 116 117 const std::string& CommandNotification::bindingNiceifyer(const std::string& binding) 117 118 { -
code/trunk/src/modules/notifications/dispatchers/CommandNotification.h
r7488 r7489 46 46 @brief 47 47 This class implements a method of displaying a Notification with information to an input command and the key the command is mapped to. 48 The message that is displayed is a string made out uf the concatenation of the preMessage, the key the specified command is mapped to and the postMessage.48 The message that is displayed is a string made out of the concatenation of the preMessage, the key the specified command is mapped to and the postMessage. 49 49 50 50 In use it would like this: … … 120 120 { this->postMessage_ = message; } 121 121 122 const std::string& bindingNiceifyer(const std::string& binding); 122 const std::string& bindingNiceifyer(const std::string& binding); //!< Transforms the input binding into a human readable form. 123 123 124 124 };
Note: See TracChangeset
for help on using the changeset viewer.