- Timestamp:
- Sep 5, 2010, 12:42:54 PM (14 years ago)
- Location:
- code/branches/notifications
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/notifications/data/gui/scripts/NotificationLayer.lua
r7351 r7354 6 6 P.nameList = {} 7 7 P.visible = nil 8 P.editMode = false 9 P.editList = {} 8 10 9 11 function P.createQueue(name, size) 10 12 local root = winMgr:getWindow("orxonox/NotificationLayer/Root") 11 13 local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name) 12 queue:setProperty("BackgroundColor", " 66FFFFFF")14 queue:setProperty("BackgroundColor", "00FFFFFF") 13 15 root:addChildWindow(queue) 14 16 … … 123 125 end 124 126 127 function P.enterEditMode() 128 P.editMode = true 129 130 local root = winMgr:getWindow("orxonox/NotificationLayer/Root") 131 --Replace all queues with FrameWindows 132 for k,v in pairs(P.queueList) do 133 if v ~= nil then 134 root:removeChildWindow(v) 135 local frame = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. P.nameList(k)) 136 frame:setArea(v:getArea()) 137 P.editList[k] = frame 138 end 139 end 140 end 141 142 function P.leaveEditMode() 143 P.editMode = false 144 145 local root = winMgr:getWindow("orxonox/NotificationLayer/Root") 146 --Replace all queues with FrameWindows 147 for k,v in pairs(P.queueList) do 148 if v ~= nil then 149 root:addChildWindow(v) 150 v:setArea(P.editList[k]:getArea()) 151 winMgr:destroyWindow(P.editList[k]) 152 P.editList[k] = nil 153 end 154 end 155 end 156 157 function P.onHide() 158 if P.editMode then 159 P.leaveEditMode() 160 end 161 end 162 125 163 function P.nameToQueueHelper(name) 126 164 local queue = nil -
code/branches/notifications/data/levels/Fight in our Back.oxw
r7163 r7354 7 7 include("templates/spaceship_Transporter.oxt") 8 8 ?> 9 10 <NotificationQueue11 name = "notification"12 position = "0.40, 0.05"13 font = "VeraMono"14 textsize = 0.02015 length = 316 width = 5017 />18 9 19 10 <!--*****************************************************************************************************************************************************************************************--> -
code/branches/notifications/data/levels/Quest_PirateAttack.oxw
r7163 r7354 19 19 dofile("includes/CuboidSpaceStation.lua") 20 20 ?> 21 22 <NotificationQueue23 name = "notification"24 position = "0.40, 0.05"25 font = "VeraMono"26 textsize = 0.02027 length = 328 width = 5029 />30 31 32 21 33 22 <Level -
code/branches/notifications/data/levels/old/princessaeryn.oxw
r6417 r7354 8 8 dofile("includes/CuboidSpaceStation.lua") 9 9 ?> 10 11 <NotificationQueue12 name = "notification"13 position = "1.0, 1.0"14 targets = "questsystem"15 />16 10 17 11 <Level -
code/branches/notifications/data/levels/old/questsystem.oxw
r6417 r7354 4 4 include("templates/spaceship_assff.oxt") 5 5 ?> 6 7 <NotificationQueue8 name = "notification"9 position = "1.0, 1.0"10 targets = "all"11 />12 6 13 7 <Level -
code/branches/notifications/data/levels/princessaeryn.oxw
r7163 r7354 14 14 description = "The Tale of Princess Aeryn" 15 15 > 16 17 <NotificationQueue18 name = "notification"19 position = "0.55, 0.05"20 font = "VeraMono"21 textsize = 0.02022 length = 323 width = 5024 />25 16 26 17 <templates> -
code/branches/notifications/data/levels/tutorial.oxw
r7319 r7354 13 13 <Template link=lodtemplate_default /> 14 14 </templates> 15 16 <NotificationQueue17 name = "notification"18 position = "0.05, 0.05"19 font = "VeraMono"20 textsize = 0.02021 length = 322 width = 5023 />24 15 25 16 <Scene -
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.