Changeset 7343 for code/branches/notifications
- Timestamp:
- Sep 3, 2010, 11:30:24 PM (14 years ago)
- Location:
- code/branches/notifications
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/notifications/data/gui/scripts/NotificationLayer.lua
r7342 r7343 9 9 local root = winMgr:getWindow("orxonox/NotificationLayer/Root") 10 10 local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name) 11 queue:setProperty("Alpha", 0.3) 12 queue:setProperty("InheritsAlpha", "setFalse") 11 13 root:addChildWindow(queue) 12 14 … … 34 36 winMgr:destroyWindow(queue) 35 37 end 36 end37 38 function P.changePosition(name, xPos, yPos)39 local queue = P.nameToQueueHelper(name)40 if queue == nil then41 cout(0, "Queue is nil!")42 return43 end44 queue:setPosition(CEGUI.UVector2(CEGUI.UDim(tonumber(xPos), 0), CEGUI.UDim(tonumber(yPos), 0)))45 38 end 46 39 … … 90 83 end 91 84 85 function P.changePosition(name, xPos, yPos) 86 local queue = P.nameToQueueHelper(name) 87 if queue == nil then 88 cout(0, "Queue is nil!") 89 return 90 end 91 queue:setPosition(CEGUI.UVector2(CEGUI.UDim(tonumber(xPos), 0), CEGUI.UDim(tonumber(yPos), 0))) 92 queue:setWidth(CEGUI.UDim(1.0, -xPos)) 93 end 94 95 function P.changeSize(name, size) 96 local queue = P.nameToQueueHelper(name) 97 if queue == nil then 98 cout(0, "Queue is nil!") 99 return 100 end 101 queue:setHeight(CEGUI.UDim(0, P.queueHeightHelper(queue, size))) 102 end 103 92 104 function P.nameToQueueHelper(name) 93 105 local queue = nil -
code/branches/notifications/src/modules/notifications/NotificationQueue.cc
r7342 r7343 176 176 /** 177 177 @brief 178 Adds a Notification , to the queue.178 Adds a Notification to the NotificationQueue. 179 179 It inserts it into the storage containers, creates a corresponding container and pushes the Notification message to the GUI. 180 180 @param notification … … 234 234 /** 235 235 @brief 236 Clears the queue by removing all containers.236 Clears the queue by removing all Notifications. 237 237 */ 238 238 void NotificationQueue::clear(void) … … 240 240 this->ordering_.clear(); 241 241 for(std::vector<NotificationContainer*>::iterator it = this->notifications_.begin(); it != this->notifications_.end(); it++) 242 {243 242 delete *it; 244 } 243 245 244 this->notifications_.clear(); 246 245 this->size_ = 0; … … 250 249 /** 251 250 @brief 251 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 } 257 258 /** 259 @brief 252 260 Sets the name of the NotificationQueue. 253 261 @param name … … 274 282 { 275 283 this->maxSize_ = size; 284 this->sizeChanged(); 285 } 286 287 /** 288 @brief 289 Adjusts the NotificationQueue, when the maximum size has changed. 290 */ 291 void NotificationQueue::sizeChanged(void) 292 { 293 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeSize(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getSize()) + ")"); 276 294 this->update(); 277 295 } … … 308 326 string->clear(); 309 327 bool first = true; 310 for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) // !<Iterate through the set of targets.328 for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) // Iterate through the set of targets. 311 329 { 312 330 if(!first) 313 {314 331 *string += ','; 315 }316 332 else 317 {318 333 first = false; 319 }320 334 *string += *it; 321 335 } … … 339 353 std::string* pTemp; 340 354 unsigned int index = 0; 341 while( index < targets.size() ) //!<Go through the string, character by character until the end is reached.355 while(index < targets.size()) // Go through the string, character by character until the end is reached. 342 356 { 343 357 pTemp = new std::string(); … … 354 368 } 355 369 356 /**357 @brief358 Aligns all the Notifications to the position of the NotificationQueue.359 */360 void NotificationQueue::positionChanged(void)361 {362 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changePosition(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getPosition().x) + ", " + multi_cast<std::string>(this->getPosition().y) + ")");363 }364 365 370 } -
code/branches/notifications/src/modules/notifications/NotificationQueue.h
r7342 r7343 28 28 29 29 /** 30 @file 30 @file NotificationQueue.h 31 31 @brief Definition of the NotificationQueue class. 32 32 */ … … 55 55 struct NotificationContainer 56 56 { 57 Notification* notification; //!< The Notification displayed by the overlay.57 Notification* notification; //!< The Notification displayed. 58 58 time_t time; //!< The time the Notification was sent and thus first displayed. 59 59 }; 60 60 61 //! Struct to allow ordering of Notification OverlayContainers.61 //! Struct to allow ordering of NotificationContainers. 62 62 struct NotificationContainerCompare { 63 63 bool operator() (const NotificationContainer* const & a, const NotificationContainer* const & b) const … … 71 71 Damian 'Mozork' Frick 72 72 */ 73 74 73 class _NotificationsExport NotificationQueue : public Tickable, public NotificationListener 75 74 { … … 134 133 static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. 135 134 static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time. 136 137 135 static const Vector2 DEFAULT_POSITION; //!< the default position. 138 136 … … 147 145 std::set<std::string> targets_; //!< The targets the Queue displays Notifications of. 148 146 149 std::multiset<NotificationContainer*, NotificationContainerCompare> ordering_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps. //TODO: Would set work as well?150 std::vector<NotificationContainer*> notifications_; 147 std::multiset<NotificationContainer*, NotificationContainerCompare> ordering_; //!< The NotificationContainers ordered by the time they were registered. //TODO: Would set work as well? 148 std::vector<NotificationContainer*> notifications_; //!< The NotificationContainers in the order they were added to the NotificationQueue. 151 149 152 float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick.150 float tickTime_; //!< Helper variable, to not have to check for Notifications that have been displayed too long, every tick. 153 151 NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 154 152 … … 156 154 157 155 void initialize(void); //!< Initializes the object. 158 void create(void); 156 void create(void); //!< Creates the NotificationQueue in lua. 159 157 160 158 bool setName(const std::string& name); //!< Sets the name of the NotificationQueue. … … 163 161 void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed. 164 162 165 bool setTargets(const std::string & targets); //!< Set the targets of this queue.163 bool setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue. 166 164 167 165 void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue. 166 void sizeChanged(void); //!< Adjusts the NotificationQueue, when the maximum size has changed. 168 167 169 void push(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.170 void pop(void); 171 void remove(NotificationContainer* container); 168 void push(Notification* notification, const std::time_t & time); //!< Add a Notification to the NotificationQueue. 169 void pop(void); //!< Removes the least recently added Notification form the NotificationQueue. 170 void remove(NotificationContainer* container); //!< Removes the Notification that is stored in the input container. 172 171 173 void clear(void); //!< Clear the queue.172 void clear(void); //!< Clears the queue by removing all Notifications. 174 173 175 174 };
Note: See TracChangeset
for help on using the changeset viewer.