- Timestamp:
- Sep 24, 2010, 12:01:57 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/doc/api/Groups.dox
r7487 r7488 153 153 The Notifications module has three major parts that interact with each other. First there is the @ref orxonox::NotificationQueue "NotificationQueue", this is the entity that (logically, not effectively) displays @ref orxonox::Notification "Notifications" according to some rules, then there is the NotificationLayer, which is the GUI which (actually) displays @ref orxonox::Notification "Notifications" by visualizing the @ref orxonox::NotificationQueue "NotificationQueues" and as a result also the @ref orxonox::Notification "Notifications", that are displayed by the respective @ref orxonox::NotificationQueue "NotificationQueues" and lastly there is the @ref orxonox::NotificationManager "NotificationManager", which connects these two. 154 154 155 @subsection NotificationQueue NotificationQueue 156 The @ref orxonox::NotificationQueue "NotificationQueue" is the entity, that (as said earlier) logically displays @ref orxonox::Notification "Notifications". Furthermore a @ref orxonox::NotificationQueue "NotificationQueue" displays only a subset of all the @ref orxonox::Notification "Notifications". The parameters that reduce the range of @ref orxonox::Notification "Notifications" are: 157 - @b senders The senders, set of targets of a @ref orxonox::NotificationQueue "NotificationQueue" is the set of senders a @ref orxonox::NotificationQueue "NotificationQueue" displays @ref orxonox::Notification "Notifications" from. E.g. If one would set the senders to "questsystem" then only @ref orxonox::Notification "Notifications" from the Questsystem wouuld be displayed in that particular queue. If you set senders to "all" then all Notifications will be displayed. Different senders can be concatinated with commas. 158 - @b size The size specifies how many @ref orxonox::Notification "Notifications" are displayed at the most, if there are more @ref orxonox::Notification "Notifications" that could be displayed but the size is smaller than the number of @ref orxonox::Notification "Notifications", then only the most recent are displayed. 159 - @b displayTime The display time specifies how long a @ref orxonox::Notification "Notification" is displayed at the most. 160 155 161 @subsection NotificationLayer NotificationLayer 156 162 The NotificationLayer is a GUI sheet, that displays all the @ref orxonox::NotificationQueue "NotificationQueues" and their @ref orxonox::Notification "Notifications". In its normal mode of operation it is transparent to input, meaning that it only functions as a means of displaying, however if switched to edit mode the NotificationLayer no longer is transparent to input and allows for the adding, removal and modification of @ref orxonox::NotificationQueue "NotificationQueues". 157 163 158 @subsection NotificationQueue NotificationQueue159 ...160 161 164 @subsection NotificationManager NotificationManager 162 ...165 The @ref orxonox::NotificationManager "NotificationManager" is (hence the name) the managing entity in this setting. It is responsible for the registering and unregistering of @ref orxonox::NotificationListener "NotificationListeners" (which the @ref orxonox::NotificationQueue "NotificationQueue" is) and also informs them about changes related to @ref orxonox::Notification "Notifications". It is also responsible for the creation and destruction of @ref orxonox::NotificationQueue "NotificationQueues" through the NotificationLayer and is also the point of approach for the NotificationLayer to get information it needs. Finally the @ref orxonox::NotificationManager "NotificationManager" is responsible for sending (and in the process creating) @ref orxonox::Notification "Notifications" and is a means for the @ref orxonox::NotificationQueue "NotificationQueues" to get the information they need about @ref orxonox::Notification "Notifications". 163 166 164 167 @subsection Notification Notification … … 172 175 @defgroup NotificationDispatchers Dispatchers 173 176 @ingroup Notifications 177 178 @ref orxonox::NotificationDispatcher "NotificationDispatchers" are entities that are instantiated in a level file (through XML) and that dispatch (or send) a specific @ref orxonox::Notification "Notification" upon having received a triggering event. 179 180 At this point there are two @ref orxonox::NotificationDispatcher "NotificationDispatchers", the @ref orxonox::SimpleNotification "SimpleNotification", which just displays a specified message, and the @ref orxonox::CommandNotification "CommandNotification" which displays a message with a binding for a specified command in it. 174 181 */ 175 182 -
code/trunk/src/modules/notifications/Notification.cc
r7484 r7488 60 60 The message of the Notification. 61 61 */ 62 Notification::Notification(const std::string & message)62 Notification::Notification(const std::string& message, const std::string& sender) 63 63 { 64 64 RegisterRootObject(Notification); 65 65 this->initialize(); 66 66 this->message_ = message; 67 this->sender_ = sender; 67 68 } 68 69 … … 84 85 this->message_.clear(); 85 86 this->sender_ = NotificationManager::NONE; 86 this->sent_ = false;87 }88 89 /**90 @brief91 Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues.92 @param sender93 The sender the Notification was sent by. Used by the NotificationManager to distributes the notification to the correct NotificationQueues.94 @return95 Returns true if successful.96 */97 bool Notification::send(const std::string & sender)98 {99 if(this->isSent()) //TODO: Needed?100 return false;101 102 this->sender_ = sender;103 bool successful = NotificationManager::getInstance().registerNotification(this);104 if(!successful)105 return false;106 this->sent_ = true;107 108 COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;109 110 return true;111 }112 113 /**114 @brief115 Sets the message of the notification.116 @param message117 The message to be set.118 @return119 Returns true if successful.120 */121 bool Notification::setMessage(const std::string & message)122 {123 if(this->isSent()) // The message cannot be changed if the message has already been sent.124 return false;125 this->message_ = message;126 return true;127 87 } 128 88 -
code/trunk/src/modules/notifications/Notification.h
r7486 r7488 54 54 public: 55 55 Notification(); 56 Notification(const std::string & message);56 Notification(const std::string& message, const std::string& sender); 57 57 virtual ~Notification(); 58 58 59 bool send(const std::string & sender); //!< Sends the Notification to the Notificationmanager.60 61 /**62 @brief Checks whether the Notification was sent.63 @return Returns true if the Notification was sent already.64 */65 inline bool isSent(void) const66 { return this->sent_; }67 59 /** 68 60 @brief Returns the message of the Notification. … … 75 67 { return this->sender_; } 76 68 77 bool setMessage(const std::string & message); //!< Sets the message of the notification.78 79 69 private: 80 70 std::string message_; //!< The Notification message. 81 71 std::string sender_; //!< The sender of the notification. 82 bool sent_; //!< Whether Notification has been sent, if so it cannot be changed.83 72 84 73 void initialize(void); //!< Registers the object and sets some default values. -
code/trunk/src/modules/notifications/NotificationDispatcher.cc
r7484 r7488 83 83 SUPER(NotificationDispatcher, XMLPort, xmlelement, mode); 84 84 85 XMLPortParam(NotificationDispatcher, "sender", getSender, setSender, xmlelement, mode); 86 85 87 XMLPortEventSink(NotificationDispatcher, BaseObject, "trigger", trigger, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers. 86 88 } -
code/trunk/src/modules/notifications/NotificationDispatcher.h
r7484 r7488 49 49 A NotificationDispatcher is an entity that, upon being triggered, dispatches (or sends) a specified @ref orxonox::Notification "Notification". 50 50 51 There is one parameter to be set, the @b sender . The sender specifies the part of Orxonox the sent @ref orxonox::Notification "Notification" comes from. The default value is set by the classes implementing NotificationDispatcher. 52 51 53 Its standard usage is: 52 54 @code 53 <NotificationDispatcher >55 <NotificationDispatcher sender="me"> 54 56 <events> 55 57 <trigger> … … 76 78 @return Returns the name of the sender. 77 79 */ 78 const std::string& getSender(void) 80 const std::string& getSender(void) const 79 81 { return this->sender_; } 82 /** 83 @brief Set the sender of the Notification dispatched by this NotificationDispatcher. 84 @param sender The name of the sender. 85 */ 86 void setSender(const std::string& sender) 87 { this->sender_ = sender; } 80 88 81 89 void dispatch(unsigned int clientId); //!< Dispatches a specific Notification. … … 86 94 87 95 void registerVariables(void); //!< Register some variables for synchronisation. 88 89 /**90 @brief Set the sender of the Notification dispatched by this NotificationDispatcher.91 @param sender The name of the sender.92 */93 void setSender(const std::string& sender)94 { this->sender_ = sender; }95 96 96 97 /** -
code/trunk/src/modules/notifications/NotificationManager.cc
r7486 r7488 58 58 DeclareToluaInterface(Notifications); 59 59 60 ManageScopedSingleton(NotificationManager, ScopeID:: Graphics, false);60 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); 61 61 62 62 // Setting console command to enter the edit mode. … … 88 88 ModifyConsoleCommand("enterEditMode").setObject(NULL); 89 89 90 // Destroys all Notifications. 91 for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++) 92 it->second->destroy(); 93 this->allNotificationsList_.clear(); 94 90 95 COUT(3) << "NotificationManager destroyed." << std::endl; 91 96 } … … 98 103 { 99 104 // Destroys all NotificationQueues that have been registered with the NotificationManager. 100 for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); ) 101 { 102 NotificationQueue* queue = (*it).second; 103 it++; 104 queue->destroy(); 105 for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) 106 { 107 it->second->destroy(true); 105 108 } 106 109 this->queues_.clear(); … … 124 127 if(GameMode::isStandalone() || isLocal || Host::getPlayerID() == clientId) 125 128 { 126 Notification* notification = new Notification(message); 127 notification->send(sender); 129 Notification* notification = new Notification(message, sender); 130 if(NotificationManager::getInstance().registerNotification(notification)) 131 COUT(3) << "Notification \"" << notification->getMessage() << "\" sent." << std::endl; 128 132 } 129 133 // If we're on the server (and the server is not the intended recipient of the Notification) we send it over the network. -
code/trunk/src/modules/notifications/NotificationQueue.cc
r7484 r7488 38 38 39 39 #include "core/CoreIncludes.h" 40 #include "core/GameMode.h" 40 41 #include "core/GUIManager.h" 41 42 #include "core/LuaState.h" … … 112 113 this->targets_.clear(); 113 114 114 if(this->registered_) // If the 115 { 116 this->clear( );115 if(this->registered_) // If the NotificationQueue is registered. 116 { 117 this->clear(true); 117 118 118 119 // Unregister with the NotificationManager. 119 120 NotificationManager::getInstance().unregisterListener(this); 120 121 NotificationManager::getInstance().unregisterQueue(this); 121 122 // Remove the NotificationQueue in lua. 122 } 123 } 124 125 /** 126 @brief 127 Destroys the NotificationQueue. 128 Used in lua and NotificationManager. 129 @param noGraphics 130 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. 131 */ 132 void NotificationQueue::destroy(bool noGraphics) 133 { 134 // Remove the NotificationQueue in lua. 135 if(GameMode::showsGraphics() && !noGraphics) 123 136 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")"); 124 } 137 138 this->OrxonoxClass::destroy(); 125 139 } 126 140 … … 131 145 void NotificationQueue::create(void) 132 146 { 133 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getMaxSize()) + ")"); 147 if(GameMode::showsGraphics()) 148 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getMaxSize()) + ")"); 134 149 } 135 150 … … 226 241 227 242 // Push the Notification to the GUI. 228 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")"); 243 if(GameMode::showsGraphics()) 244 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")"); 229 245 } 230 246 … … 254 270 255 271 // Pops the Notification from the GUI. 256 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")"); 272 if(GameMode::showsGraphics()) 273 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")"); 257 274 } 258 275 … … 276 293 277 294 // Removes the Notification from the GUI. 278 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")"); 295 if(GameMode::showsGraphics()) 296 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")"); 279 297 } 280 298 … … 282 300 @brief 283 301 Clears the NotificationQueue by removing all NotificationContainers. 284 */ 285 void NotificationQueue::clear(void) 302 @param noGraphics 303 If this is eset to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally. 304 */ 305 void NotificationQueue::clear(bool noGraphics) 286 306 { 287 307 this->ordering_.clear(); … … 295 315 296 316 // Clear the NotificationQueue in the GUI. 297 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")"); 317 if(GameMode::showsGraphics() && !noGraphics) 318 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")"); 298 319 } 299 320 -
code/trunk/src/modules/notifications/NotificationQueue.h
r7486 r7488 69 69 70 70 There are quite some parameters that influence the behaviour of the NotificationQueue: 71 - 'name':The name of the NotificationQueue. It needs to be unique.72 - 'senders':The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays.73 - 'size':The size of the NotificationQueue, it specifies how many @ref orxonox::Notification "Notifications" are displayed at once at the most.74 - 'displayTime':The time a @ref orxonox::Notification "Notification" is displayed with this NotificationQueue.71 - @b name The name of the NotificationQueue. It needs to be unique. 72 - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays. 73 - @b size The size of the NotificationQueue, it specifies how many @ref orxonox::Notification "Notifications" are displayed at once at the most. 74 - @b displayTime The time a @ref orxonox::Notification "Notification" is displayed with this NotificationQueue. 75 75 76 76 @author … … 85 85 virtual ~NotificationQueue(); 86 86 87 /** 88 @brief Destroys the NotificationQueue. 89 Used in lua. 90 */ 91 void destroy(void) { this->OrxonoxClass::destroy(); } // tolua_export 87 //! Destroys the NotificationQueue. 88 void destroy(bool noGraphics = false); // tolua_export 92 89 93 90 virtual void tick(float dt); //!< To update from time to time. … … 168 165 void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer. 169 166 170 void clear( void); //!< Clears the NotificationQueue by removing all NotificationContainers.167 void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers. 171 168 172 169 }; // tolua_export -
code/trunk/src/modules/notifications/dispatchers/CommandNotification.h
r7484 r7488 50 50 In use it would like this: 51 51 @code 52 <CommandNotification preMessage="Please press " command="someCommand" postMessage=" to do something." >52 <CommandNotification preMessage="Please press " command="someCommand" postMessage=" to do something." sender="me"> 53 53 <events> 54 54 <trigger> -
code/trunk/src/modules/notifications/dispatchers/SimpleNotification.h
r7484 r7488 49 49 In use it would like this: 50 50 @code 51 <SimpleNotification message="some message..." >51 <SimpleNotification message="some message..." sender="me"> 52 52 <events> 53 53 <trigger>
Note: See TracChangeset
for help on using the changeset viewer.