Changeset 8446 for code/branches/tutoriallevel2/src
- Timestamp:
- May 11, 2011, 12:21:32 PM (14 years ago)
- Location:
- code/branches/tutoriallevel2/src/modules/notifications
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutoriallevel2/src/modules/notifications/CMakeLists.txt
r7403 r8446 4 4 NotificationManager.cc 5 5 NotificationQueue.cc 6 NotificationQueueCEGUI.cc 6 7 ) 7 8 … … 13 14 TOLUA_FILES 14 15 NotificationManager.h 15 NotificationQueue .h16 NotificationQueueCEGUI.h 16 17 PCH_FILE 17 18 NotificationsPrecompiledHeaders.h -
code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc
r8445 r8446 46 46 #include "Notification.h" 47 47 #include "NotificationQueue.h" 48 #include "NotificationQueueCEGUI.h" 48 49 49 50 #include "ToluaBindNotifications.h" … … 57 58 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); 58 59 59 // Setting console command to enter the edit mode.60 SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode);61 62 60 /** 63 61 @brief … … 68 66 RegisterRootObject(NotificationManager); 69 67 70 ModifyConsoleCommand("enterEditMode").setObject(this);71 72 68 COUT(3) << "NotificatioManager created." << std::endl; 73 69 } … … 79 75 NotificationManager::~NotificationManager() 80 76 { 81 ModifyConsoleCommand("enterEditMode").setObject(NULL);82 83 77 // Destroys all Notifications. 84 78 for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++) … … 99 93 while(it != this->queues_.end()) 100 94 { 101 it->second->destroy( true);95 it->second->destroy(); 102 96 it = this->queues_.begin(); 103 97 } … … 313 307 /** 314 308 @brief 315 Enters the edit mode of the NotificationLayer.316 */317 void NotificationManager::enterEditMode(void)318 {319 if(GameMode::showsGraphics())320 {321 GUIManager::getInstance().hideGUI("NotificationLayer");322 GUIManager::getInstance().showGUI("NotificationLayer", false, false);323 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.enterEditMode()");324 }325 }326 327 /**328 @brief329 309 Registers a NotificationQueue. 330 310 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. … … 409 389 void NotificationManager::loadQueues(void) 410 390 { 411 NotificationQueue* allQueue = new NotificationQueue ("all");391 NotificationQueue* allQueue = new NotificationQueueCEGUI("all"); 412 392 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"all\", 0.5, 0, " + multi_cast<std::string>(allQueue->getMaxSize()) + ")"); 413 393 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)"); 414 394 415 NotificationQueue* infoQueue = new NotificationQueue ("info", NotificationListener::ALL, 1, -1);395 NotificationQueue* infoQueue = new NotificationQueueCEGUI("info", NotificationListener::ALL, 1, -1); 416 396 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"CCFFFF00\")"); 417 397 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")"); -
code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h
r8445 r8446 50 50 /** 51 51 @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::NotificationL istener "NotificationListeners".54 It also provides a static function to send @ref orxonox::Notification "Notifications" andworks as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer.52 The Singleton NotificationManager is a NotificationListener and functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationQueues "NotificationQueues". 53 It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationLQueue "NotificationQueues". 54 It also works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer. 55 55 56 56 @author … … 95 95 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. 96 96 97 void enterEditMode(void); // Enters the edit mode of the NotificationLayer.98 99 97 bool registerQueue(NotificationQueue* queue); // Registers a NotificationQueue. 100 98 void unregisterQueue(NotificationQueue* queue); // Unregisters a NotificationQueue. -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc
r8445 r8446 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"44 40 #include "util/SubString.h" 45 41 … … 88 84 } 89 85 90 this->create(); // Creates the NotificationQueue in lua.91 92 86 COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl; 93 87 } … … 108 102 NotificationManager::getInstance().unregisterQueue(this); 109 103 } 110 } 111 112 /** 113 @brief 114 Destroys the NotificationQueue. 115 Used in lua and NotificationManager. 116 @param noGraphics 117 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. 118 */ 119 void NotificationQueue::destroy(bool noGraphics) 120 { 121 // Remove the NotificationQueue in lua. 122 if(GameMode::showsGraphics() && !noGraphics) 123 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")"); 124 104 125 105 COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl; 126 127 this->OrxonoxClass::destroy();128 }129 130 /**131 @brief132 Creates the NotificationQueue in lua.133 */134 void NotificationQueue::create(void)135 {136 if(GameMode::showsGraphics())137 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");138 106 } 139 107 … … 236 204 this->notifications_.insert(this->notifications_.begin(), container); 237 205 238 // Push the Notification to the GUI. 239 if(GameMode::showsGraphics()) 240 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")"); 206 // Inform that a Notification was pushed. 207 this->notificationPushed(notification); 241 208 242 209 COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl; … … 269 236 delete container; 270 237 271 // Pops the Notification from the GUI. 272 if(GameMode::showsGraphics()) 273 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")"); 238 // Inform that a Notification was popped. 239 this->notificationPopped(); 274 240 } 275 241 … … 295 261 delete *containerIterator; 296 262 297 // Removes the Notification from the GUI.298 if(GameMode::showsGraphics())299 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");263 // TODO: index automatically cast? 264 // Inform that a Notification was removed. 265 this->notificationRemoved(index); 300 266 } 301 267 … … 316 282 this->notifications_.clear(); 317 283 this->size_ = 0; 318 319 // Clear the NotificationQueue in the GUI.320 if(GameMode::showsGraphics() && !noGraphics)321 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");322 284 } 323 285 -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h
r8445 r8446 47 47 #include "tools/interfaces/Tickable.h" 48 48 49 namespace orxonox // tolua_export50 { // tolua_export49 namespace orxonox 50 { 51 51 52 52 /** … … 88 88 @ingroup Notifications 89 89 */ 90 class _NotificationsExport NotificationQueue // tolua_export 91 : public Tickable 92 { // tolua_export 90 class _NotificationsExport NotificationQueue : public Tickable 91 { 93 92 94 93 public: 95 NotificationQueue(const std::string& name, const std::string& senders = Notification Manager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);94 NotificationQueue(const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME); 96 95 virtual ~NotificationQueue(); 97 98 //! Destroys the NotificationQueue.99 void destroy(bool noGraphics = false); // tolua_export100 96 101 97 virtual void tick(float dt); //!< To update from time to time. … … 143 139 { return this->targets_; } 144 140 145 // tolua_begin146 141 void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue. 147 142 const std::string& getTargets(void) const; //!< Returns a string consisting of the concatenation of the targets. 148 // tolua_end149 143 150 144 void tidy(void); 151 152 pr ivate:145 146 protected: 153 147 static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. 154 148 static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time. 155 149 static const int INF = -1; //!< Constant denoting infinity. 150 151 /** 152 @brief Is called when a notification was pushed. 153 @param notification The Notification that was pushed. 154 */ 155 virtual void notificationPushed(Notification* notification) {} 156 /** 157 @brief Is called when a notification was popped. 158 */ 159 virtual void notificationPopped(void) {} 160 /** 161 @brief Is called when a notification was removed. 162 @param index The index the removed notification was at. 163 */ 164 virtual void notificationRemoved(unsigned int index) {} 165 166 virtual void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers. 156 167 168 169 private: 157 170 std::string name_; //!< The name of the NotificationQueue. 158 171 … … 171 184 NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 172 185 173 void create(void); //!< Creates the NotificationQueue in lua.174 175 186 void setName(const std::string& name); //!< Sets the name of the NotificationQueue. 176 187 … … 179 190 void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer. 180 191 181 void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.192 }; 182 193 183 }; // tolua_export 194 } 184 195 185 } // tolua_export 186 187 #endif /* _NotificationOverlay_H__ */ 196 #endif /* _NotificationQueue_H__ */
Note: See TracChangeset
for help on using the changeset viewer.