- Timestamp:
- May 11, 2011, 10:45:56 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.