- Timestamp:
- May 11, 2011, 10:45:56 PM (14 years ago)
- Location:
- code/branches/tutoriallevel2
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutoriallevel2/data/gui/scripts/NotificationLayer.lua
r8446 r8448 27 27 ["window"] = queue, 28 28 ["name"] = name, 29 [" edit"] = nil,29 ["maxSize"] = size, 30 30 ["visible"] = false, 31 31 ["fontSize"] = 12, … … 183 183 -- Change the size of the queue. 184 184 -- The parameters are (in order) 'name of the queue', 'relative width', 'absolute width in pixel', 'relative height', 'absolute heigth in pixel'. 185 -- Additionally the last parameter can be ommitted and relativeHeight can be set to the size (i.e. the maximal number of notifications displayed) of the queue, which leads to the height being set such that all notifications can be displayed.185 -- Additionally the last two parameters can be ommitted, which leads to the height being set such that all notifications can be displayed. using the size of the queue. 186 186 function P.resizeQueue(queueName, relativeWidth, absoluteWidth, relativeHeight, absoluteHeigth) 187 local queueWindow = P.queueList[queueName].window 187 local queue = P.queueList[queueName] 188 local queueWindow = queue.window 188 189 if queueWindow == nil then 189 190 return 190 191 end 191 192 if absoluteHeigth == nil then 192 absoluteHeigth = P.queueHeightHelper( P.queueList[queueName], relativeHeight)193 absoluteHeigth = P.queueHeightHelper(queue, queue.maxSize) 193 194 relativeHeight = 0 194 195 end … … 196 197 end 197 198 198 -- Change the font size and font color of all notifications in a queueHeightHelper 199 -- The parameters are (in order) 'name of the queue', 'font size', 'ARGB of the font color in hex notation'. 200 function P.changeQueueFont(queueName, size, color) 201 local queue = P.queueList[queueName] 202 local queueWindow = queue.window 203 if queueWindow == nil then 204 return 205 end 206 207 queue.fontSize = size 208 local changeColor = false 209 if color ~= nil then 210 queue.fontColor = color 211 changeColor = true 212 end 213 for i=queue.first,queue.last-1 do 214 P.setItemFontHelper(queue.items[i], queue, changeColor) 215 end 216 end 217 199 -- Change the horizontal alignment of the displayed notifications. 200 -- The parameters are the name of the queue and the alignment parameter, 218 201 function P.changeQueueAlignment(queueName, alignment) 219 202 local queue = P.queueList[queueName] … … 222 205 return 223 206 end 224 207 225 208 queue.alignment = alignment 226 209 local item = nil … … 228 211 item = queue.items[i] 229 212 item:setProperty("HorzFormatting", queue.alignment) 213 end 214 end 215 216 -- Change the font size of all notifications in a queue. 217 -- The parameters are (in order) 'name of the queue', 'font size'. 218 function P.changeQueueFontSize(queueName, size) 219 local queue = P.queueList[queueName] 220 local queueWindow = queue.window 221 if queueWindow == nil then 222 return 223 end 224 225 queue.fontSize = size 226 for i=queue.first,queue.last-1 do 227 P.setItemFontHelper(queue.items[i], queue, false) 228 end 229 end 230 231 -- Change the font color of all notifications in a queue. 232 -- The parameters are (in order) 'name of the queue', 'ARGB of the font color in hex notation'. 233 function P.changeQueueFontColor(queueName, color) 234 local queue = P.queueList[queueName] 235 local queueWindow = queue.window 236 if queueWindow == nil then 237 return 238 end 239 240 queue.fontColor = color 241 for i=queue.first,queue.last-1 do 242 P.setItemFontHelper(queue.items[i], queue, true) 230 243 end 231 244 end -
code/branches/tutoriallevel2/src/modules/notifications/Notification.cc
r8445 r8448 47 47 @param sender 48 48 The sender of the Notification. 49 @param type 50 The type of the Notification. 49 51 */ 50 52 Notification::Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type) -
code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc
r8446 r8448 36 36 #include "core/command/ConsoleCommand.h" 37 37 #include "core/CoreIncludes.h" 38 #include "core/GameMode.h"39 #include "core/GUIManager.h"40 38 #include "core/LuaState.h" 41 #include "util/Convert.h"42 39 #include "util/ScopedSingletonManager.h" 43 40 … … 48 45 #include "NotificationQueueCEGUI.h" 49 46 50 #include "ToluaBindNotifications.h"51 52 47 namespace orxonox 53 48 { 54 55 // Register tolua_open function when loading the library.56 DeclareToluaInterface(Notifications);57 49 58 50 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); … … 108 100 @param sender 109 101 The name of the entity (of the collective) that sent the new Notification. 102 @param type 103 The type of the new Notification. 110 104 @return 111 105 Returns true if successful. … … 126 120 @param sender 127 121 The The name of the entity (of the collective) that sent the command. 122 @return 123 Returns true if the command was successfully executed. 128 124 */ 129 125 bool NotificationManager::executeCommand(notificationCommand::Value command, const std::string& sender) 130 126 { 127 bool commandExecuted = false; 131 128 if(command == notificationCommand::clear) 132 129 { 133 this->commandClear(sender); 134 return true; 135 } 136 137 return false; 130 if(this->commandClear(sender)) 131 commandExecuted = true; 132 } 133 134 if(commandExecuted) 135 COUT(3) << "Notification command \"" << NotificationListener::command2Str(command) << "\" executed." << endl; 136 137 return commandExecuted; 138 138 } 139 139 … … 143 143 @param sender 144 144 The sender of the clear command. 145 */ 146 void NotificationManager::commandClear(const std::string& sender) 145 @return 146 Returns true if the command was successfully executed by at least one NotificationQueue, false if it was not executed. 147 */ 148 bool NotificationManager::commandClear(const std::string& sender) 147 149 { 148 150 bool all = (sender == NotificationListener::ALL); 151 bool executed = false; 149 152 // Clear all NotificationQueues that have the input sender as target. 150 153 for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues. … … 153 156 // If either the sender is 'all', the NotificationQueue has as target all or the NotificationQueue has the input sender as a target. 154 157 if(all || set.find(NotificationListener::ALL) != set.end() || set.find(sender) != set.end()) 155 it->second->tidy(); 156 } 158 executed = it->second->tidy() || executed; 159 } 160 161 return executed; 157 162 } 158 163 … … 385 390 /** 386 391 @brief 387 Loads all the NotificationQueues that should exist.388 */389 void NotificationManager::loadQueues(void)390 {391 NotificationQueue* allQueue = new NotificationQueueCEGUI("all");392 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"all\", 0.5, 0, " + multi_cast<std::string>(allQueue->getMaxSize()) + ")");393 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)");394 395 NotificationQueue* infoQueue = new NotificationQueueCEGUI("info", NotificationListener::ALL, 1, -1);396 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"CCFFFF00\")");397 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")");398 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"info\", 0.2, 0, 0.8, 0)");399 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueAlignment(\"info\", \"HorzCentred\")");400 }401 402 /**403 @brief404 Creates a new NotificationQueue.405 This is used in lua.406 @param name407 The name of the new NotificationQueue.408 */409 void NotificationManager::createQueue(const std::string& name)410 {411 new NotificationQueue(name);412 }413 414 /**415 @brief416 392 Get the NotificationQueue with the input name. 417 393 @param name … … 430 406 } 431 407 408 /** 409 @brief 410 Loads all the NotificationQueues that should exist. 411 */ 412 void NotificationManager::loadQueues(void) 413 { 414 NotificationQueueCEGUI* allQueue = new NotificationQueueCEGUI("all"); 415 allQueue->setDisplaySize(Vector2(0.5, 0)); 416 allQueue->setPosition(Vector4(0.0, 10, 0.3, 0)); 417 418 NotificationQueueCEGUI* infoQueue = new NotificationQueueCEGUI("info", NotificationListener::ALL, 1, -1); 419 infoQueue->setPosition(Vector4(0.2, 0, 0.8, 0)); 420 infoQueue->setFontSize(24); 421 infoQueue->setFontColor(Vector4(1.0, 1.0, 0.0, 0.8)); 422 infoQueue->setAlignment("HorzCentred"); 423 infoQueue->setDisplaySize(Vector2(0.6, 0.0)); 424 } 425 432 426 } -
code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h
r8446 r8448 50 50 /** 51 51 @brief 52 The Singleton NotificationManager is a NotificationListener and functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationQueue s"NotificationQueues".53 It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::Notification LQueue "NotificationQueues".52 The Singleton NotificationManager is a NotificationListener and functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationQueue "NotificationQueues". 53 It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationQueue "NotificationQueues". 54 54 It also works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer. 55 55 … … 98 98 void unregisterQueue(NotificationQueue* queue); // Unregisters a NotificationQueue. 99 99 100 // tolua_begin 101 void loadQueues(void); // Loads all the NotificationQueues that should exist. 102 void createQueue(const std::string& name); // Creates a new NotificationQueue. 103 orxonox::NotificationQueue* getQueue(const std::string & name); // Get the NotificationQueue with the input name. 104 // tolua_end 100 void loadQueues(void); // tolua_export // Loads all the NotificationQueues that should exist. 101 102 NotificationQueue* getQueue(const std::string & name); // Get the NotificationQueue with the input name. 105 103 106 104 private: … … 115 113 116 114 // Commands 117 voidcommandClear(const std::string& sender); // The clear command. Clears all NotificationQueues that have its sender as a target.115 bool commandClear(const std::string& sender); // The clear command. Clears all NotificationQueues that have its sender as a target. 118 116 119 117 }; // tolua_export -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc
r8446 r8448 208 208 209 209 COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl; 210 COUT(3) << "NotificationQueue \"" << this->getName() << "\": " << notification->getMessage() << endl; 210 211 } 211 212 … … 374 375 } 375 376 } 376 377 void NotificationQueue::tidy(void) 377 378 /** 379 @brief 380 Pops all Notifications from the NotificationQueue. 381 @return 382 Returns true if successful, false if not. 383 */ 384 bool NotificationQueue::tidy(void) 378 385 { 379 386 while(this->size_ > 0) 380 387 this->pop(); 388 return true; 381 389 } 382 390 -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h
r8446 r8448 142 142 const std::string& getTargets(void) const; //!< Returns a string consisting of the concatenation of the targets. 143 143 144 void tidy(void);144 bool tidy(void); // Pops all Notifications from the NotificationQueue. 145 145 146 146 protected: 147 static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.148 static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.149 static const int INF = -1; //!< Constant denoting infinity.150 151 147 /** 152 148 @brief Is called when a notification was pushed. … … 166 162 virtual void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers. 167 163 164 protected: 165 static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. 166 static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time. 167 static const int INF = -1; //!< Constant denoting infinity. 168 168 169 169 private: -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.cc
r8446 r8448 33 33 34 34 #include "NotificationQueueCEGUI.h" 35 36 #include <sstream> 35 37 36 38 #include "core/CoreIncludes.h" … … 42 44 #include "Notification.h" 43 45 46 #include "ToluaBindNotifications.h" 47 44 48 namespace orxonox 45 49 { 46 50 51 // Register tolua_open function when loading the library. 52 DeclareToluaInterface(Notifications); 53 47 54 NotificationQueueCEGUI::NotificationQueueCEGUI(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime) : NotificationQueue(name, senders, size, displayTime) 48 55 { 49 56 RegisterObject(NotificationQueueCEGUI); 57 58 this->displaySize_ = Vector4(1.0, 0.0, 0.0, 0.0); 59 this->position_ = Vector4(0.0, 0.0, 0.0, 0.0); 60 this->alignment_ = "LeftAligned"; 61 this->fontSize_ = 12; 62 this->fontColor_ = Vector4(1.0, 1.0, 1.0, 1.0); 63 this->fontColorStr_ = "FFFFFFFF"; 50 64 51 65 // Create the NotificationQueueCEGUI in lua. … … 73 87 NotificationQueue::destroy(); 74 88 } 75 89 90 /** 91 @brief 92 Set the size of the window that displays the NotificationQueue. 93 @param size 94 The size is a vector with components: 95 - The relative width of the window. (A value between 0 and 1) 96 - The absolute width in pixels. (Additional to the relative width, can be negative) 97 - The relative height of the window. (A value between 0 and 1) 98 - The absolute height in pixels. (Additional to the relative width, can be negative.) 99 If both the 3rd and 4th component of size are set to 0 the height is set such that exactly as many Notifications fit as is the maximum size of the NotificationQueue (in terms of the number of Notifications). 100 */ 101 void NotificationQueueCEGUI::setDisplaySize(const Vector4& size) 102 { 103 if(this->displaySize_ == size) 104 return; 105 106 if(size.x < 0.0 || size.x > 1.0 || size.z < 0.0 || size.z > 1.0) 107 { 108 COUT(2) << "The display size of the NotificationQueueCEGUI " << this->getName() << " was trying to be set, but the relative size was not in [0,1]. Aborting..." << endl; 109 return; 110 } 111 112 this->displaySize_ = size; 113 if(size.z == 0.0 && size.w == 0.0) 114 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->displaySize_.x) + ", " + multi_cast<std::string>(this->displaySize_.y) + ")"); 115 else 116 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->displaySize_.x) + ", " + multi_cast<std::string>(this->displaySize_.y) + ", " + multi_cast<std::string>(this->displaySize_.z) + ", " + multi_cast<std::string>(this->displaySize_.w) + ")"); 117 } 118 119 /** 120 @brief 121 Set the position of the window that displays the NotificationQueue. 122 @param position 123 The position is a vector with components: 124 - The relative x-position of the window. (A value between 0 and 1) 125 - The absolute x-position in pixels. (Additional to the relative x-position, can be negative) 126 - The relative y-position of the window. (A value between 0 and 1) 127 - The absolute y-position in pixels. (Additional to the relative y-position, can be negative.) 128 */ 129 void NotificationQueueCEGUI::setPosition(const Vector4& position) 130 { 131 if(this->position_ == position) 132 return; 133 134 if(position.x < 0.0 || position.x > 1.0 || position.z < 0.0 || position.z > 1.0) 135 { 136 COUT(2) << "The position the NotificationQueueCEGUI " << this->getName() << " was trying to be set, but the relative position was not in [0,1]. Aborting..." << endl; 137 return; 138 } 139 140 this->position_ = position; 141 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.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) + ")"); 142 } 143 144 /** 145 @brief 146 Set the horizontal alignment of the Notifications text. 147 @param alignment 148 The alignment of the Notifications, they are the possible string that the CEGUI Falagard StaticText HorzFormatting property can take. 149 @see http://cegui.org.uk/api_reference/classCEGUI_1_1FalagardStaticTextProperties_1_1HorzFormatting.html 150 */ 151 void NotificationQueueCEGUI::setAlignment(const std::string& alignment) 152 { 153 if(this->alignment_ == alignment) 154 return; 155 156 // TODO: Check whether the alignment string is correct? 157 this->alignment_ = alignment; 158 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueAlignment(\"" + this->getName() + "\", \"" + this->alignment_ + "\")"); 159 } 160 161 /** 162 @brief 163 Set the font size of the text displayed by this NotificationQueue. 164 @param size 165 The font size. 166 */ 167 void NotificationQueueCEGUI::setFontSize(unsigned int size) 168 { 169 if(this->fontSize_ == size) 170 return; 171 172 this->fontSize_ = size; 173 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFontSize(\"" + this->getName() + "\", " + multi_cast<std::string>(this->fontSize_) + ")"); 174 } 175 176 /** 177 @brief 178 Set the font color if the text displayed by this NotificationQueue. 179 @param color 180 The color is a vector with the components being RGBA and taking values from 0 to 1. 181 */ 182 void NotificationQueueCEGUI::setFontColor(const Vector4& color) 183 { 184 if(this->fontColor_ == color) 185 return; 186 187 this->fontColor_ = color; 188 // Convert to ARGB format. 189 std::stringstream stream; 190 for(unsigned int i = 0; i < 4; i++) 191 stream << std::hex << std::setw(2) << std::setfill('0') << int(this->fontColor_[(i+3)%4]*255); 192 this->fontColorStr_ = stream.str(); 193 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFontColor(\"" + this->getName() + "\", \"" + this->fontColorStr_ + "\")"); 194 } 195 196 /** 197 @brief 198 Get the NotificationQueueCEGUI with the input name. 199 @param name 200 The name of the NotificationQueueCEGUI to be got. 201 @return 202 Returns a pointer to the NotificationQueueCEGUI, or NULL if it doesn't exist. 203 */ 204 /*static*/ NotificationQueueCEGUI* NotificationQueueCEGUI::getQueue(const std::string& name) 205 { 206 NotificationQueue* queue = NotificationManager::getInstance().getQueue(name); 207 if(queue == NULL || !queue->isA(Class(NotificationQueueCEGUI))) 208 return NULL; 209 return static_cast<NotificationQueueCEGUI*>(queue); 210 } 211 76 212 /** 77 213 @brief … … 86 222 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")"); 87 223 } 88 224 89 225 /** 90 226 @brief … … 97 233 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")"); 98 234 } 99 235 100 236 /** 101 237 @brief Is called when a notification was removed. … … 108 244 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")"); 109 245 } 110 246 111 247 /** 112 248 @brief … … 118 254 { 119 255 NotificationQueue::clear(noGraphics); 120 256 121 257 // Clear the NotificationQueue in the GUI. 122 258 if(GameMode::showsGraphics() && !noGraphics) 123 259 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")"); 124 260 } 125 261 126 262 /** 127 263 @brief -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.h
r8446 r8448 39 39 40 40 #include <string> 41 #include "util/Math.h" 41 42 42 43 #include "NotificationManager.h" 44 43 45 #include "NotificationQueue.h" 44 46 … … 46 48 { // tolua_export 47 49 48 //TODO: Update.49 50 /** 50 51 @brief 51 Displays @ref orxonox::Notification "Notifications" from specific senders.52 Displays @ref orxonox::Notification "Notifications" using CEGUI. 52 53 53 There are quite some parameters that influence the behavior of the NotificationQueue: 54 - @b name The name of the NotificationQueue. It needs to be unique. 55 - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays. 56 - @b size The size of the NotificationQueue, it specifies how many @ref orxonox::Notification "Notifications" are displayed at once at the most. 57 - @b displayTime The time a @ref orxonox::Notification "Notification" is displayed with this NotificationQueue. 54 Apart form the parameters inherited by the @ref orxonox::NotificationQueue "NotificationQueue", there are some more parameters that influence the behavior of the NotificationQueueCEGUI: 55 - @b displaySize The size of the window that displays the NotificationQueue. 56 - @b position The position if the window that displays the NotificationQueue. 57 - @b alignment The horizontal alignment of the displayed Notifications. 58 - @b fontSize The font size of the displayed Notifications. 59 - @b fontColor The font color of the displayed Notifications. 58 60 59 61 @author 60 62 Damian 'Mozork' Frick 61 63 64 @see NotificationQueue 62 65 @ingroup Notifications 63 66 */ … … 70 73 virtual ~NotificationQueueCEGUI(); 71 74 72 //! Destroys the NotificationQueue. 73 void destroy(bool noGraphics = false); // tolua_export 75 void destroy(bool noGraphics = false); // Destroys the NotificationQueue. 76 77 /** 78 @brief Set the size of the window that displays the NotificationQueue. 79 @param size A vector whose first component is the relative width of the window (a value between 0 and 1) and whose second component is the absolute width in pixels (additional to the relative width, can be negative). The height is set such that exactly as many Notifications fit as is the maximum size of the NotificationQueue (in terms of the number of Notifications). 80 */ 81 inline void setDisplaySize(const Vector2& size) 82 { this->setDisplaySize(Vector4(size.x, size.y, 0.0, 0.0)); } 83 void setDisplaySize(const Vector4& size); // Set the size of the window that displays the NotificationQueue. 84 /** 85 @brief Get the size of the window that displays the NotificationQueue. 86 @return Returns a vector with the display size. 87 */ 88 inline const Vector4& getDisplaySize(void) const 89 { return this->displaySize_; } 90 91 void setPosition(const Vector4& position); // Set the position of the window that displays the NotificationQueue. 92 /** 93 @brief Get the position of the window that displays the NotificationQueue. 94 @return Returns a vector with the position. 95 */ 96 inline const Vector4& getPosition(void) const 97 { return this->position_; } 98 99 void setAlignment(const std::string& alignment); // Set the horizontal alignment of the Notifications text. 100 /** 101 @brief Get the horizontal alignment of the Notifications text. 102 @return Returns a string with the horizontal alignment property. 103 */ 104 inline const std::string& getAlignment(void) 105 { return this->alignment_; } 106 107 void setFontSize(unsigned int size); // Set the font size of the text displayed by this NotificationQueue. 108 /** 109 @brief Get the font size of the text displayed by this NotificationQueue. 110 @return Returns the font size. 111 */ 112 inline unsigned int getFontSize(void) 113 { return this->fontSize_; } 114 115 void setFontColor(const Vector4& color); // Set the font color if the text displayed by this NotificationQueue. 116 /** 117 @brief Get the font color of the text displayed by this NotificationQueue. 118 @return Returns a vector with the components being RGBA, with values from 0 to 1. 119 */ 120 inline const Vector4& getFontColor(void) const 121 { return this->fontColor_; } 122 /** 123 @brief Get the font color of the text displayed by this NotificationQueue. 124 @return Returns a string with the ARGB values in hexadecimal format. 125 */ 126 inline const std::string& getFontColorStr(void) const 127 { return this->fontColorStr_; } 128 129 static NotificationQueueCEGUI* getQueue(const std::string& name); // tolua_export 74 130 75 131 protected: … … 81 137 82 138 private: 83 void create(void); // Creates the NotificationQueue in lua. 139 Vector4 displaySize_; //!< The size of the window that displays the NotificationQueue. 140 Vector4 position_; //!< The position of the window that displays the NotificationQueue. 141 std::string alignment_; //!< The horizontal alignment of the Notifications text. 142 unsigned int fontSize_; //!< The font size of the Notifications text. 143 Vector4 fontColor_; //!< The font color of the Notifications text as a vector, in RGBA form, with values from 0 to 1. 144 std::string fontColorStr_; //!< The font color of the Notifications text as a string with the ARGB hexadecimal values. 145 146 void create(void); // Creates the NotificationQueue in lua. 84 147 85 148 }; // tolua_export -
code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.cc
r8445 r8448 47 47 // Commands 48 48 /*static*/ const std::string NotificationListener::COMMAND_CLEAR("clear"); 49 /*static*/ const std::string NotificationListener::COMMAND_NONE("none"); 49 50 50 51 registerStaticNetworkFunction(NotificationListener::sendHelper); … … 108 109 { 109 110 // If the notification is a message. 110 if(!isCommand && it->registerNotification(message, sender, notificationMessageType::Value(messageType)))111 COUT(3) << "Notification \"" << message << "\" sent." << std::endl;111 if(!isCommand) 112 it->registerNotification(message, sender, notificationMessageType::Value(messageType)); 112 113 113 114 // If the notification is a command. … … 115 116 { 116 117 notificationCommand::Value command = str2Command(message); 117 if(command != notificationCommand::none && it->executeCommand(command, sender))118 COUT(3) << "Command \"" << message << "\" executed." << std::endl;118 if(command != notificationCommand::none) 119 it->executeCommand(command, sender); 119 120 } 120 121 } … … 138 139 return command; 139 140 } 141 142 /** 143 @brief 144 Helper method. Converts a command enum into its corresponding string. 145 @param command 146 The command to be converted. 147 @return 148 Returns the corresponding string. 149 */ 150 /*static*/ const std::string& NotificationListener::command2Str(notificationCommand::Value command) 151 { 152 switch(command) 153 { 154 case notificationCommand::clear: 155 return NotificationListener::COMMAND_CLEAR; 156 default: 157 return NotificationListener::COMMAND_NONE; 158 } 159 } 140 160 141 161 } -
code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.h
r8445 r8448 108 108 /** 109 109 @brief Sends a specified command to the specified client from the specified sender. 110 @param messageThe command that should be sent (and later executed).110 @param command The command that should be sent (and later executed). 111 111 @param sender The sender that sent the notification. Default is 'none'. 112 112 @param sendMode The mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is notificationSendMode::local. … … 138 138 */ 139 139 virtual bool executeCommand(notificationCommand::Value command, const std::string& sender) { return false; } 140 141 public: 140 142 141 143 static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationQueues. … … 144 146 //! Commands 145 147 static const std::string COMMAND_CLEAR; 148 static const std::string COMMAND_NONE; 146 149 147 150 protected: 148 151 static void sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand = false, notificationMessageType::Value messageType = notificationMessageType::info); // Helper method to send both notifications and commands over the network. 149 152 150 153 static notificationCommand::Value str2Command(const std::string& string); // Helper method. Converts a string into the enum for a command. 154 static const std::string& command2Str(notificationCommand::Value command); // Helper method. Converts a command enum into its corresponding string. 151 155 }; 152 156 }
Note: See TracChangeset
for help on using the changeset viewer.