Changeset 7354 for code/branches/notifications/src/modules
- Timestamp:
- Sep 5, 2010, 12:42:54 PM (14 years ago)
- Location:
- code/branches/notifications/src/modules/notifications
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/notifications/src/modules/notifications/CMakeLists.txt
r7338 r7354 12 12 FIND_HEADER_FILES 13 13 TOLUA_FILES 14 NotificationManager.h 14 15 PCH_FILE 15 16 NotificationsPrecompiledHeaders.h -
code/branches/notifications/src/modules/notifications/NotificationManager.cc
r7351 r7354 34 34 #include "NotificationManager.h" 35 35 36 #include "core/command/ConsoleCommand.h" 36 37 #include "core/CoreIncludes.h" 37 38 #include "core/GUIManager.h" 39 #include "core/LuaState.h" 38 40 #include "util/ScopedSingletonManager.h" 39 41 #include "interfaces/NotificationListener.h" … … 49 51 ManageScopedSingleton(NotificationManager, ScopeID::Graphics, false); 50 52 53 //TODO: Make work. 54 //SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode).description("Enter the NotificationLayer edit mode."); 55 51 56 /** 52 57 @brief … … 64 69 65 70 // Create first queue: 66 this->queue _ = new NotificationQueue("all");71 this->queues_.push_back(new NotificationQueue("all")); 67 72 } 68 73 } … … 74 79 NotificationManager::~NotificationManager() 75 80 { 76 //this->queue_->destroy(); 81 82 } 83 84 void NotificationManager::preDestroy(void) 85 { 86 for(std::vector<NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) 87 (*it)->destroy(); 88 this->queues_.clear(); 77 89 } 78 90 … … 291 303 } 292 304 305 void NotificationManager::createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime) 306 { 307 this->queues_.push_back(new NotificationQueue(name, targets, size, displayTime)); 308 } 309 293 310 } -
code/branches/notifications/src/modules/notifications/NotificationManager.h
r7349 r7354 40 40 #include <map> 41 41 #include <string> 42 #include <vector> 42 43 43 44 #include "util/Singleton.h" 44 45 #include "core/OrxonoxClass.h" 45 46 46 namespace orxonox 47 { 47 namespace orxonox // tolua_export 48 { // tolua_export 49 48 50 /** 49 51 @brief … … 53 55 Damian 'Mozork' Frick 54 56 */ 55 class _NotificationsExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass 56 { 57 class _NotificationsExport NotificationManager // tolua_export 58 : public Singleton<NotificationManager>, public OrxonoxClass 59 { // tolua_export 57 60 friend class Singleton<NotificationManager>; 58 61 public: 59 62 NotificationManager(); 60 63 virtual ~NotificationManager(); 64 65 virtual void preDestroy(void); 66 67 static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export 61 68 62 69 static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners. … … 80 87 { return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); } 81 88 89 void enterEditMode(void); 90 91 void createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime); // tolua_export 92 82 93 private: 83 94 static NotificationManager* singletonPtr_s; 84 95 85 NotificationQueue* queue_; //!< Initial, first, NotificationQueue.96 std::vector<NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager. 86 97 87 98 int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice. … … 94 105 bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map. 95 106 96 }; 107 }; // tolua_export 97 108 98 } 109 } // tolua_export 99 110 100 111 #endif /* _NotificationManager_H__ */ -
code/branches/notifications/src/modules/notifications/NotificationQueue.cc
r7349 r7354 45 45 { 46 46 47 const Vector2 NotificationQueue::DEFAULT_POSITION(0.0,0.0);48 49 47 /** 50 48 @brief 51 49 Constructor. Creates and initializes the object. 52 50 */ 53 NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, const Vector2& position,unsigned int displayTime)51 NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime) 54 52 { 55 53 this->registered_ = false; … … 62 60 this->name_ = name; 63 61 this->maxSize_ = size; 64 this->position_ = position;65 62 this->setDisplayTime(displayTime); 66 63 67 64 this->create(); 68 this->positionChanged();69 65 70 66 NotificationManager::getInstance().registerListener(this); … … 245 241 this->size_ = 0; 246 242 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")"); 247 }248 249 /**250 @brief251 Adjusts the NotificationQueue, when the position has changed.252 */253 void NotificationQueue::positionChanged(void)254 {255 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changePosition(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getPosition().x) + ", " + multi_cast<std::string>(this->getPosition().y) + ")");256 243 } 257 244 -
code/branches/notifications/src/modules/notifications/NotificationQueue.h
r7349 r7354 43 43 44 44 #include "tools/interfaces/Tickable.h" 45 #include "util/Math.h"46 45 #include "interfaces/NotificationListener.h" 47 46 #include "NotificationManager.h" … … 73 72 74 73 public: 75 NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, const Vector2& position = NotificationQueue::DEFAULT_POSITION,unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);74 NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME); 76 75 virtual ~NotificationQueue(); 77 76 … … 106 105 inline float getDisplayTime() const 107 106 { return this->displayTime_; } 108 /**109 @brief Returns the position of the NotificationQueue.110 @return Returns the position.111 */112 inline const Vector2 & getPosition() const113 { return this->position_; }114 107 115 108 /** … … 121 114 bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets. 122 115 123 /**124 @brief Sets the position of the NotificationQueue.125 @param pos The position.126 */127 inline void setPosition(Vector2 pos)128 { this->position_ = pos; this->positionChanged(); }129 130 116 private: 131 117 static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. 132 118 static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time. 133 static const Vector2 DEFAULT_POSITION; //!< the default position.134 119 135 120 std::string name_; //!< The name of the NotificationQueue. … … 137 122 unsigned int maxSize_; //!< The maximal number of Notifications displayed. 138 123 unsigned int size_; //!< The number of Notifications displayed. 139 unsigned int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.140 124 unsigned int displayTime_; //!< The time a Notification is displayed. 141 Vector2 position_; //!< The position of the NotificationQueue.142 125 143 126 std::set<std::string> targets_; //!< The targets the Queue displays Notifications of. … … 161 144 bool setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue. 162 145 163 void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.164 146 void sizeChanged(void); //!< Adjusts the NotificationQueue, when the maximum size has changed. 165 147
Note: See TracChangeset
for help on using the changeset viewer.