Changeset 7324
- Timestamp:
- Sep 2, 2010, 10:06:51 AM (14 years ago)
- Location:
- code/branches/notifications/src/modules
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/notifications/src/modules/notifications/CMakeLists.txt
r7193 r7324 16 16 NotificationsPrecompiledHeaders.h 17 17 LINK_LIBRARIES 18 objects 18 19 orxonox 19 20 overlays -
code/branches/notifications/src/modules/notifications/Notification.cc
r7193 r7324 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "network/NetworkFunction.h" 37 38 #include "NotificationManager.h" 38 39 … … 42 43 CreateUnloadableFactory(Notification); 43 44 45 registerMemberNetworkFunction(Notification, send); 46 44 47 /** 45 48 @brief 46 49 Default constructor. Initializes the object. 47 50 */ 48 Notification::Notification(BaseObject* creator) : BaseObject(creator) 51 Notification::Notification(BaseObject* creator) : BaseObject(creator), Synchronisable(creator) 49 52 { 50 53 RegisterObject(Notification); 51 54 this->initialize(); 55 this->registerVariables(); 52 56 } 53 57 … … 58 62 The message of the Notification. 59 63 */ 60 Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator) 64 Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator), Synchronisable(creator) 61 65 { 62 66 RegisterObject(Notification); 63 67 this->initialize(); 64 68 this->message_ = message; 69 this->registerVariables(); 65 70 } 66 71 … … 85 90 } 86 91 87 /** 88 @brief 89 Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE. 90 @return 91 Returns true if successful. 92 */ 93 bool Notification::send(void) 92 void Notification::registerVariables(void) 94 93 { 95 return this->send(NotificationManager::NONE); 94 registerVariable(this->message_); 95 registerVariable(this->sender_); 96 registerVariable(this->sent_); 96 97 } 97 98 … … 104 105 Returns true if successful. 105 106 */ 106 bool Notification::send( const std::string & sender)107 bool Notification::send(unsigned int clientId, const std::string & sender = NotificationManager::NONE) 107 108 { 108 if(this->isSent()) //TODO: Needed? 109 return false; 110 111 this->sender_ = sender; 112 bool successful = NotificationManager::getInstance().registerNotification(this); 113 if(!successful) 114 return false; 115 this->sent_ = true; 109 if(GameMode::isMaster()) 110 { 111 if(this->isSent()) //TODO: Needed? 112 return false; 116 113 117 COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl; 114 this->sender_ = sender; 115 bool successful = NotificationManager::getInstance().registerNotification(this); 116 if(!successful) 117 return false; 118 this->sent_ = true; 119 120 COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl; 121 } 122 else 123 { 124 callMemberNetworkFunction(Notification, send, this->getObjectID(), clientId, clientId, sender); 125 } 118 126 119 127 return true; -
code/branches/notifications/src/modules/notifications/Notification.h
r7164 r7324 39 39 #include <string> 40 40 #include "core/BaseObject.h" 41 #include "network/synchronisable/Synchronisable.h" 41 42 42 43 namespace orxonox … … 49 50 Damian 'Mozork' Frick 50 51 */ 51 class _NotificationsExport Notification : public BaseObject 52 class _NotificationsExport Notification : public BaseObject, public Synchronisable 52 53 { 53 54 public: … … 56 57 virtual ~Notification(); 57 58 58 bool send(void); //!< Sends the Notification to the Notificationmanager, with sender NotificationManager::NONE; 59 bool send(const std::string & sender); //!< Sends the Notification to the Notificationmanager. 59 bool send(unsigned int clientId, const std::string & sender); //!< Sends the Notification to the Notificationmanager. 60 60 61 61 /** … … 83 83 84 84 void initialize(void); 85 void registerVariables(void); 85 86 86 87 }; -
code/branches/notifications/src/modules/notifications/NotificationDispatcher.cc
r7285 r7324 39 39 #include "Notification.h" 40 40 #include "NotificationManager.h" 41 #include "interfaces/PlayerTrigger.h" 42 #include "infos/PlayerInfo.h" 43 #include "worldentities/pawns/Pawn.h" 41 44 42 45 namespace orxonox … … 86 89 @brief 87 90 Dispatches a Notification with a message supplied by the createNotificationMessage() method, which can be overloaded. 91 @param clientId 92 The id of the client the notification should be dispatched to. 88 93 */ 89 void NotificationDispatcher::dispatch( void)94 void NotificationDispatcher::dispatch(unsigned int clientId) 90 95 { 91 96 const std::string message = this->createNotificationMessage(); 92 97 Notification* notification = new Notification(this, message); 93 98 94 notification->send( this->getSender());99 notification->send(clientId, this->getSender()); 95 100 } 96 101 … … 103 108 Returns true if the NotificationDispatcher was successfully triggered. 104 109 */ 105 bool NotificationDispatcher::trigger(bool triggered )110 bool NotificationDispatcher::trigger(bool triggered, BaseObject* trigger) 106 111 { 107 112 if(!triggered || !this->isActive()) // If the NotificationDispatcher is inactive it cannot be executed. … … 110 115 COUT(4) << "NotificationDispatcher (&" << this << ") triggered." << std::endl; 111 116 112 this->dispatch(); 117 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 118 Pawn* pawn = NULL; 119 120 // If the trigger is a PlayerTrigger. 121 if(pTrigger != NULL) 122 { 123 if(!pTrigger->isForPlayer()) //!< The PlayerTrigger is not exclusively for Pawns which means we cannot extract one. 124 return false; 125 else 126 pawn = pTrigger->getTriggeringPlayer(); 127 } 128 else 129 return false; 130 131 if(pawn == NULL) 132 { 133 COUT(4) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl; 134 return false; 135 } 136 137 //! Extract the PlayerInfo from the Pawn. 138 PlayerInfo* player = pawn->getPlayer(); 139 140 if(player == NULL) 141 { 142 COUT(3) << "The PlayerInfo* is NULL." << std::endl; 143 return false; 144 } 145 146 this->dispatch(player->getClientID()); 113 147 114 148 return true; -
code/branches/notifications/src/modules/notifications/NotificationDispatcher.h
r7285 r7324 65 65 { return this->sender_; } 66 66 67 void dispatch( void); //!< Dispatches a specific Notification.68 bool trigger(bool triggered ); //!< Is called when the NotificationDispatcher is triggered.67 void dispatch(unsigned int clientId); //!< Dispatches a specific Notification. 68 bool trigger(bool triggered, BaseObject* trigger); //!< Is called when the NotificationDispatcher is triggered. 69 69 70 70 protected: -
code/branches/notifications/src/modules/objects/triggers/MultiTriggerContainer.cc
r7301 r7324 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "worldentities/pawns/Pawn.h" 37 38 38 39 namespace orxonox … … 65 66 { 66 67 RegisterObject(MultiTriggerContainer); 68 69 Pawn* pawn = orxonox_cast<Pawn*>(data); 70 if(pawn != NULL) 71 { 72 this->setForPlayer(true); 73 this->setTriggeringPlayer(pawn); 74 } 67 75 } 68 76 -
code/branches/notifications/src/modules/objects/triggers/MultiTriggerContainer.h
r7301 r7324 38 38 39 39 #include "core/BaseObject.h" 40 #include "interfaces/PlayerTrigger.h" 40 41 41 42 namespace orxonox … … 48 49 Damian 'Mozork' Frick 49 50 */ 50 class _ObjectsExport MultiTriggerContainer : public BaseObject 51 class _ObjectsExport MultiTriggerContainer : public BaseObject, public PlayerTrigger 51 52 { 52 53 … … 72 73 MultiTrigger* originator_; //!< The originator. 73 74 BaseObject* data_; //!< The data. 75 74 76 }; 75 77 -
code/branches/notifications/src/modules/objects/triggers/Trigger.cc
r7319 r7324 160 160 void Trigger::triggered(bool bIsTriggered) 161 161 { 162 COUT(1) << "Trigger triggered." << std::endl; //TODO: Remove debug.163 162 this->fireEvent(bIsTriggered); 164 163 } -
code/branches/notifications/src/modules/questsystem/QuestNotification.cc
r7163 r7324 73 73 bool QuestNotification::send(void) 74 74 { 75 return t his->Notification::send(QuestNotification::SENDER);75 return true;//this->Notification::send(QuestNotification::SENDER); //TODO: Adjust. 76 76 } 77 77
Note: See TracChangeset
for help on using the changeset viewer.