Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 11, 2009, 12:33:16 AM (15 years ago)
Author:
landauf
Message:

Moved Notification and NotificationManger from overlays to the quest objects (NotificationOverlay and NotificationQueue remain with the other overlays).

Added a new interface NotificationListener. The NotificationManager sends notifications to all listeners. NotificationQueue is such a listener (through inheritance). This removes another dependency between orxonox and overlays.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.h

    r3196 r5619  
    4545#include "interfaces/Tickable.h"
    4646#include "overlays/OverlayGroup.h"
     47#include "interfaces/NotificationListener.h"
    4748
    4849namespace orxonox
     
    5758        std::string name; //!< The name of the overlay.
    5859    };
    59    
     60
    6061    //! Struct to allow ordering of NotificationOverlayContainers.
    6162    struct NotificationOverlayContainerCompare {
     
    8485    */
    8586
    86     class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable
     87    class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable, public NotificationListener
    8788    {
    88    
     89
    8990        public:
    9091            NotificationQueue(BaseObject* creator);
    9192            virtual ~NotificationQueue();
    92            
     93
    9394            virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML.
    94            
     95
    9596            virtual void tick(float dt); //!< To update from time to time.
    96            
     97
    9798            void update(void); //!< Updates the queue.
    9899            void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue.
    99            
     100
    100101            /**
    101102            @brief Returns the maximum number of Notifications displayed.
     
    140141            inline const std::string & getFont() const
    141142                { return this->font_; }
    142                
     143
    143144            /**
    144145            @brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.
     
    148149                { return this->targets_; }
    149150            bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
    150            
     151
    151152            /**
    152153            @brief Sets the position of the NotificationQueue.
    153154            @param pos The position.
    154155            */
    155             inline void setPosition(Vector2 pos) 
     156            inline void setPosition(Vector2 pos)
    156157                { this->position_ = pos; this->positionChanged(); }
    157158
    158159            void scroll(const Vector2 pos); //!< Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
    159            
     160
    160161        private:
    161162            static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
     
    166167            static const std::string DEFAULT_FONT; //!< The default font.
    167168            static const Vector2 DEFAULT_POSITION; //!< the default position.
    168        
     169
    169170            int maxSize_; //!< The maximal number of Notifications displayed.
    170171            int size_; //!< The number of Notifications displayed.
     
    172173            int displayTime_; //!< The time a Notification is displayed.
    173174            Vector2 position_; //!< The position of the NotificationQueue.
    174            
     175
    175176            std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
    176            
     177
    177178            float fontSize_; //!< The font size.
    178179            std::string font_; //!< The font.
    179            
     180
    180181            std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps.
    181182            std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding.
    182            
     183
    183184            float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick.
    184185            NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
    185            
     186
    186187            void initialize(void); //!< Initializes the object.
    187188            void setDefaults(void); //!< Helper method to set the default values.
    188            
     189
    189190            bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications.
    190191            bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
    191192            bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
    192            
     193
    193194            bool setTargets(const std::string & targets); //!< Set the targets of this queue.
    194            
     195
    195196            bool setFontSize(float size); //!< Set the font size.
    196197            bool setFont(const std::string & font); //!< Set the font.
    197198
    198199            void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
    199            
     200
    200201            void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.
    201202            bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue.
    202            
     203
    203204            void clear(void); //!< Clear the queue.
    204    
     205
    205206    };
    206207
Note: See TracChangeset for help on using the changeset viewer.