Changeset 5619 for code/branches/libraries/src/orxonox/overlays
- Timestamp:
- Aug 11, 2009, 12:33:16 AM (15 years ago)
- Location:
- code/branches/libraries/src/orxonox/overlays/notifications
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/libraries/src/orxonox/overlays/notifications/CMakeLists.txt
r2911 r5619 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 Notification.cc3 NotificationManager.cc4 2 NotificationOverlay.cc 5 3 NotificationQueue.cc -
code/branches/libraries/src/orxonox/overlays/notifications/NotificationOverlay.cc
r3301 r5619 36 36 #include "util/Exception.h" 37 37 #include "core/CoreIncludes.h" 38 #include " Notification.h"38 #include "objects/quest/notifications/Notification.h" 39 39 #include "NotificationQueue.h" 40 40 … … 65 65 { 66 66 this->initialize(); 67 67 68 68 if(notification == NULL || queue == NULL) //!> If either notification or queue are not given an Exception is thrown. 69 69 { … … 73 73 this->queue_ = queue; 74 74 this->defineOverlay(); 75 75 76 76 this->processNotification(notification); 77 77 } 78 78 79 79 /** 80 80 @brief … … 85 85 this->queue_ = NULL; 86 86 } 87 87 88 88 /** 89 89 @brief -
code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.cc
r3301 r5619 39 39 #include "core/XMLPort.h" 40 40 #include "NotificationOverlay.h" 41 #include " NotificationManager.h"41 #include "objects/quest/notifications/NotificationManager.h" 42 42 43 43 namespace orxonox … … 80 80 this->tickTime_ = 0.0; 81 81 82 NotificationManager::getInstance().register Queue(this);82 NotificationManager::getInstance().registerListener(this); 83 83 } 84 84 -
code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.h
r3196 r5619 45 45 #include "interfaces/Tickable.h" 46 46 #include "overlays/OverlayGroup.h" 47 #include "interfaces/NotificationListener.h" 47 48 48 49 namespace orxonox … … 57 58 std::string name; //!< The name of the overlay. 58 59 }; 59 60 60 61 //! Struct to allow ordering of NotificationOverlayContainers. 61 62 struct NotificationOverlayContainerCompare { … … 84 85 */ 85 86 86 class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable 87 class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable, public NotificationListener 87 88 { 88 89 89 90 public: 90 91 NotificationQueue(BaseObject* creator); 91 92 virtual ~NotificationQueue(); 92 93 93 94 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML. 94 95 95 96 virtual void tick(float dt); //!< To update from time to time. 96 97 97 98 void update(void); //!< Updates the queue. 98 99 void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue. 99 100 100 101 /** 101 102 @brief Returns the maximum number of Notifications displayed. … … 140 141 inline const std::string & getFont() const 141 142 { return this->font_; } 142 143 143 144 /** 144 145 @brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue. … … 148 149 { return this->targets_; } 149 150 bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets. 150 151 151 152 /** 152 153 @brief Sets the position of the NotificationQueue. 153 154 @param pos The position. 154 155 */ 155 inline void setPosition(Vector2 pos) 156 inline void setPosition(Vector2 pos) 156 157 { this->position_ = pos; this->positionChanged(); } 157 158 158 159 void scroll(const Vector2 pos); //!< Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector. 159 160 160 161 private: 161 162 static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. … … 166 167 static const std::string DEFAULT_FONT; //!< The default font. 167 168 static const Vector2 DEFAULT_POSITION; //!< the default position. 168 169 169 170 int maxSize_; //!< The maximal number of Notifications displayed. 170 171 int size_; //!< The number of Notifications displayed. … … 172 173 int displayTime_; //!< The time a Notification is displayed. 173 174 Vector2 position_; //!< The position of the NotificationQueue. 174 175 175 176 std::set<std::string> targets_; //!< The targets the Queue displays Notifications of. 176 177 177 178 float fontSize_; //!< The font size. 178 179 std::string font_; //!< The font. 179 180 180 181 std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps. 181 182 std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding. 182 183 183 184 float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick. 184 185 NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 185 186 186 187 void initialize(void); //!< Initializes the object. 187 188 void setDefaults(void); //!< Helper method to set the default values. 188 189 189 190 bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications. 190 191 bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have. 191 192 bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed. 192 193 193 194 bool setTargets(const std::string & targets); //!< Set the targets of this queue. 194 195 195 196 bool setFontSize(float size); //!< Set the font size. 196 197 bool setFont(const std::string & font); //!< Set the font. 197 198 198 199 void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue. 199 200 200 201 void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue. 201 202 bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue. 202 203 203 204 void clear(void); //!< Clear the queue. 204 205 205 206 }; 206 207
Note: See TracChangeset
for help on using the changeset viewer.