Changeset 8656 for code/branches/presentation/src
- Timestamp:
- May 29, 2011, 11:24:31 AM (13 years ago)
- Location:
- code/branches/presentation/src/modules/notifications
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/modules/notifications/NotificationQueue.cc
r8651 r8656 136 136 { 137 137 this->tickTime_ += dt; // Add the time interval that has passed to the time counter. 138 if(this->displayTime_ != INF && this->tickTime_ >= 1.0) // If the time counter is greater than 1 s all Notifications that have expired are removed, if it is smaller we wait to the next tick.138 if(this->displayTime_ != INF && this->tickTime_ >= 1.0) // If the time counter is greater than 1 s all Notifications that have expired are removed, if it is smaller we wait to the next tick. 139 139 { 140 140 this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containing the current time. … … 171 171 void NotificationQueue::registerVariables() 172 172 { 173 registerVariable( this->maxSize_, VariableDirection::ToClient 174 registerVariable( this->targets_, VariableDirection::ToClient 175 registerVariable( this->displayTime_, VariableDirection::ToClient 173 registerVariable( this->maxSize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::maxSizeChanged)); 174 registerVariable( this->targets_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::targetsChanged)); 175 registerVariable( this->displayTime_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::displayTimeChanged)); 176 176 } 177 177 … … 229 229 @brief 230 230 Adds (pushes) a Notification to the NotificationQueue. 231 It inserts it into the storage containers, creates a corresponding container and pushes the Notification message to the GUI.231 It inserts it into the storage containers, creates a corresponding container and pushes the notification message to the GUI. 232 232 @param notification 233 233 The Notification to be pushed. … … 363 363 364 364 this->maxSize_ = size; 365 365 this->maxSizeChanged(); 366 } 367 368 /** 369 @brief 370 Is called when the maximum number of displayed Notifications has changed. 371 */ 372 void NotificationQueue::maxSizeChanged(void) 373 { 366 374 if(this->isRegistered()) 367 375 this->update(); … … 385 393 386 394 this->displayTime_ = time; 387 395 this->displayTimeChanged(); 396 } 397 398 /** 399 @brief 400 Is called when the maximum number of seconds a Notification is displayed has changed. 401 */ 402 void NotificationQueue::displayTimeChanged(void) 403 { 388 404 if(this->isRegistered()) 389 405 this->update(); … … 428 444 this->targets_.insert(string[i]); 429 445 446 this->targetsChanged(); 447 } 448 449 /** 450 @brief 451 Is called when the NotificationQueue's targets have changed. 452 */ 453 void NotificationQueue::targetsChanged(void) 454 { 430 455 // TODO: Why? 431 456 if(this->isRegistered()) -
code/branches/presentation/src/modules/notifications/NotificationQueue.h
r8651 r8656 95 95 public: 96 96 NotificationQueue(BaseObject* creator); 97 NotificationQueue(BaseObject* creator, const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);98 97 virtual ~NotificationQueue(); 99 98 … … 129 128 { return this->displayTime_; } 130 129 // tolua_end 130 void maxSizeChanged(void); // Is called when the maximum number of displayed Notifications has changed. 131 void displayTimeChanged(void); 131 132 132 133 /** … … 146 147 void setTargets(const std::string & targets); // Set the targets of this NotificationQueue. 147 148 const std::string& getTargets(void) const; // Returns a string consisting of the concatenation of the targets. 149 void targetsChanged(void); // Is called when the NotificationQueue's targets have changed. 148 150 149 151 /** -
code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.cc
r8651 r8656 95 95 void NotificationQueueCEGUI::registerVariables() 96 96 { 97 registerVariable( this->position_, VariableDirection::ToClient 98 registerVariable( this->fontSize_, VariableDirection::ToClient 99 registerVariable( this->fontColor_, VariableDirection::ToClient 100 registerVariable( this->alignment_, VariableDirection::ToClient 101 registerVariable( this->displaySize_, VariableDirection::ToClient 97 registerVariable( this->position_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::positionChanged)); 98 registerVariable( this->fontSize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::fontSizeChanged)); 99 registerVariable( this->fontColor_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::fontColorChanged)); 100 registerVariable( this->alignment_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::alignmentChanged)); 101 registerVariable( this->displaySize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::displaySizeChanged)); 102 102 } 103 103 … … 141 141 142 142 this->displaySize_ = size; 143 this->displaySizeChanged(); 144 } 145 146 /** 147 @brief 148 Is called when the display size has changed. 149 */ 150 void NotificationQueueCEGUI::displaySizeChanged(void) 151 { 143 152 if(GameMode::showsGraphics()) 144 153 { 145 if( size.z == 0.0 && size.w == 0.0)154 if(this->displaySize_.z == 0.0 && this->displaySize_.w == 0.0) 146 155 GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".resizeQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->displaySize_.x) + ", " + multi_cast<std::string>(this->displaySize_.y) + ")"); 147 156 else … … 172 181 173 182 this->position_ = position; 183 this->positionChanged(); 184 } 185 186 /** 187 @brief 188 Is called when the NotificationQueue's position has changed. 189 */ 190 void NotificationQueueCEGUI::positionChanged(void) 191 { 174 192 if(GameMode::showsGraphics()) 175 193 GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".moveQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->position_.x) + ", " + multi_cast<std::string>(this->position_.y) + ", " + multi_cast<std::string>(this->position_.z) + ", " + multi_cast<std::string>(this->position_.w) + ")"); … … 190 208 // TODO: Check whether the alignment string is correct? 191 209 this->alignment_ = alignment; 210 this->alignmentChanged(); 211 } 212 213 /** 214 @brief 215 Is called when the horizontal alignment of the Notifications text has changed. 216 */ 217 void NotificationQueueCEGUI::alignmentChanged(void) 218 { 192 219 if(GameMode::showsGraphics()) 193 220 GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueAlignment(\"" + this->getName() + "\", \"" + this->alignment_ + "\")"); … … 206 233 207 234 this->fontSize_ = size; 235 this->fontSizeChanged(); 236 } 237 238 /** 239 @brief 240 Is called when the font size of the text displayed by this NotificationQueue has changed. 241 */ 242 void NotificationQueueCEGUI::fontSizeChanged(void) 243 { 208 244 if(GameMode::showsGraphics()) 209 245 GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueFontSize(\"" + this->getName() + "\", " + multi_cast<std::string>(this->fontSize_) + ")"); … … 222 258 223 259 this->fontColor_ = color; 260 this->fontColorChanged(); 261 } 262 263 /** 264 @brief 265 Is called when the font color if the text displayed by this NotificationQueue. 266 */ 267 void NotificationQueueCEGUI::fontColorChanged(void) 268 { 224 269 // Convert to ARGB format. 225 270 std::stringstream stream; … … 227 272 stream << std::hex << std::setw(2) << std::setfill('0') << int(this->fontColor_[(i+3)%4]*255); 228 273 this->fontColorStr_ = stream.str(); 274 229 275 if(GameMode::showsGraphics()) 230 276 GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueFontColor(\"" + this->getName() + "\", \"" + this->fontColorStr_ + "\")"); … … 249 295 /** 250 296 @brief 251 Is called by the NotificationQueue when a notification was pushed.297 Is called by the NotificationQueue when a Notification was pushed. 252 298 @param notification 253 299 The Notification that was pushed. … … 262 308 /** 263 309 @brief 264 Is called by the NotificationQueue when a notification was popped.310 Is called by the NotificationQueue when a Notification was popped. 265 311 */ 266 312 void NotificationQueueCEGUI::notificationPopped(void) … … 273 319 /** 274 320 @brief Is called when a notification was removed. 275 @param index The index the removed notification was at.321 @param index The index the removed Notification was at. 276 322 */ 277 323 void NotificationQueueCEGUI::notificationRemoved(unsigned int index) -
code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.h
r8651 r8656 86 86 inline const Vector4& getDisplaySize(void) const 87 87 { return this->displaySize_; } 88 void displaySizeChanged(void); // Is called when the display size has changed. 88 89 89 90 void setPosition(const Vector4& position); // Set the position of the window that displays the NotificationQueue. … … 94 95 inline const Vector4& getPosition(void) const 95 96 { return this->position_; } 97 void positionChanged(void); // Is called when the NotificationQueue's position has changed. 96 98 97 99 void setAlignment(const std::string& alignment); // Set the horizontal alignment of the Notifications text. … … 102 104 inline const std::string& getAlignment(void) 103 105 { return this->alignment_; } 106 void alignmentChanged(void); // Is called when the horizontal alignment of the Notifications text has changed. 104 107 105 108 void setFontSize(unsigned int size); // Set the font size of the text displayed by this NotificationQueue. … … 110 113 inline unsigned int getFontSize(void) 111 114 { return this->fontSize_; } 115 void fontSizeChanged(void); // Is called when the font size of the text displayed by this NotificationQueue has changed. 112 116 113 117 void setFontColor(const Vector4& color); // Set the font color if the text displayed by this NotificationQueue. … … 124 128 inline const std::string& getFontColorStr(void) const 125 129 { return this->fontColorStr_; } 130 void fontColorChanged(void); // Is called when the font color if the text displayed by this NotificationQueue has changed. 126 131 127 132 static NotificationQueueCEGUI* getQueue(const std::string& name); // tolua_export // Get the NotificationQueueCEGUI with the input name. … … 130 135 virtual void create(void); // Creates the NotificationQueue in lua. 131 136 132 virtual void notificationPushed(Notification* notification); // Is called by the NotificationQueue when a notification was pushed133 virtual void notificationPopped(void); // Is called by the NotificationQueue when a notification was popped.134 virtual void notificationRemoved(unsigned int index); // Is called when a notification was removed.137 virtual void notificationPushed(Notification* notification); // Is called by the NotificationQueue when a Notification was pushed 138 virtual void notificationPopped(void); // Is called by the NotificationQueue when a Notification was popped. 139 virtual void notificationRemoved(unsigned int index); // Is called when a Notification was removed. 135 140 136 141 virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
Note: See TracChangeset
for help on using the changeset viewer.