Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 3, 2010, 3:55:32 PM (14 years ago)
Author:
dafrick
Message:

Changing from OrxonoxOverlays to CEGUI as means of displaying Notifications.
Still messy and not working completely but it's a start.

Location:
code/branches/notifications/src
Files:
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/notifications/src/libraries/core/GUIManager.cc

    r7284 r7338  
    240240        The function executes the Lua function with the same name in case the GUIManager is ready.
    241241    */
    242     /*static*/ void GUIManager::showGUI(const std::string& name, bool bHidePrevious)
    243     {
    244         GUIManager::getInstance().executeCode("showMenuSheet(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ")");
     242    /*static*/ void GUIManager::showGUI(const std::string& name, bool bHidePrevious, bool bNoInput)
     243    {
     244        GUIManager::getInstance().executeCode("showMenuSheet(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ")");
    245245    }
    246246
     
    249249        Hack-ish. Needed for GUIOverlay.
    250250    */
    251     void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious)
    252     {
    253         this->executeCode("showMenuSheet(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + ptr + ")");
     251    void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious, bool bNoInput)
     252    {
     253        this->executeCode("showMenuSheet(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ", " + ptr + ")");
    254254    }
    255255
  • code/branches/notifications/src/libraries/core/GUIManager.h

    r7163 r7338  
    7575
    7676        void loadGUI(const std::string& name);
    77         static void showGUI(const std::string& name, bool bHidePrevious = false);
    78         void showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious = false);
     77        static void showGUI(const std::string& name, bool bHidePrevious = false, bool bNoInput = false);
     78        void showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious = false, bool bNoInput = false);
    7979        static void hideGUI(const std::string& name);
    8080        void keyESC();
  • code/branches/notifications/src/modules/notifications/CMakeLists.txt

    r7326 r7338  
    33  NotificationDispatcher.cc
    44  NotificationManager.cc
    5   NotificationOverlay.cc
    65  NotificationQueue.cc
    76)
     
    1716  LINK_LIBRARIES
    1817    orxonox
    19     overlays
    2018  SOURCE_FILES ${NOTIFICATIONS_SRC_FILES}
    2119)
  • code/branches/notifications/src/modules/notifications/Notification.cc

    r7326 r7338  
    9494        registerVariable(this->message_);
    9595        registerVariable(this->sender_);
    96         registerVariable(this->sent_);
     96        registerVariable(this->sent_, ObjectDirection::Bidirectional);
    9797    }
    9898
     
    108108    {
    109109
    110         callMemberNetworkFunction(Notification, sendHelper, this->getObjectID(), clientId, clientId, sender);
     110        if(GameMode::isMaster())
     111        {
     112            this->sendHelper(sender);
     113        }
     114        else
     115        {
     116            callMemberNetworkFunction(Notification, sendHelper, this->getObjectID(), clientId, sender);
     117        }
    111118
    112119        return true;
    113120    }
    114121
    115     bool Notification::sendHelper(unsigned int clientId, const std::string& sender)
     122    bool Notification::sendHelper(const std::string& sender)
    116123    {
    117124        if(this->isSent()) //TODO: Needed?
  • code/branches/notifications/src/modules/notifications/Notification.h

    r7326 r7338  
    5858
    5959            bool send(unsigned int clientId, const std::string & sender); //!< Sends the Notification to the Notificationmanager.
    60             bool sendHelper(unsigned int clientId, const std::string& sender);
     60            bool sendHelper(const std::string& sender);
    6161
    6262            /**
  • code/branches/notifications/src/modules/notifications/NotificationManager.cc

    r7284 r7338  
    4040#include "Notification.h"
    4141#include "interfaces/NotificationListener.h"
     42#include "core/GUIManager.h"
     43#include "NotificationQueue.h"
    4244
    4345namespace orxonox
     
    4749    const std::string NotificationManager::NONE("none");
    4850
    49     ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
     51    ManageScopedSingleton(NotificationManager, ScopeID::Graphics, false);
    5052
    5153    /**
     
    5860
    5961        this->highestIndex_ = 0;
     62
     63        //TODO: What if no graphics?
     64        GUIManager::getInstance().loadGUI("NotificationLayer");
     65        // Create first queue:
     66        NotificationQueue* queue = new NotificationQueue("general");
    6067    }
    6168
  • code/branches/notifications/src/modules/notifications/NotificationManager.h

    r7164 r7338  
    7171
    7272            /**
    73             @brief Fetches the Notifications for a specific NotificationListener starting at a specified time.
    74             @param listener The NotificationListener the Notifications are fetched for.
    75             @param map A multimap, in which the notifications are stored.
    76             @param timeFrameStart The start time the Notifications are fetched from.
    77             @return Returns true if successful.
    78             */
    79             bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart)
    80                 { return this->getNotifications(listener, map, timeFrameStart, std::time(0)); }
    81             /**
    8273            @brief Fetches the Notifications for a specific NotificationListener starting at a specified timespan before now.
    8374            @param listener The NotificationListener the Notifications are fetched for.
  • code/branches/notifications/src/modules/notifications/NotificationQueue.cc

    r7163 r7338  
    3737#include "core/CoreIncludes.h"
    3838#include "core/XMLPort.h"
    39 #include "NotificationOverlay.h"
    40 #include "NotificationManager.h"
     39#include "Notification.h"
     40#include "core/GUIManager.h"
     41#include "core/LuaState.h"
     42#include <algorithm>
    4143
    4244namespace orxonox
    4345{
    44 
    45     CreateFactory(NotificationQueue);
    4646
    4747    const std::string NotificationQueue::DEFAULT_FONT("VeraMono");
     
    5353        Constructor. Creates and initializes the object.
    5454    */
    55     NotificationQueue::NotificationQueue(BaseObject* creator) : OverlayGroup(creator)
     55    NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, const Vector2& position, unsigned int length, unsigned int displayTime)
    5656    {
    5757        this->registered_ = false;
    5858
    59         RegisterObject(NotificationQueue);
     59        RegisterRootObject(NotificationQueue);
     60
    6061        this->initialize();
     62
     63        this->setTargets(senders);
     64        this->name_ = name;
     65        this->maxSize_ = size;
     66        this->position_ = position;
     67        this->notificationLength_ = length;
     68        this->setDisplayTime(displayTime);
     69
     70        this->create();
     71
     72        NotificationManager::getInstance().registerListener(this);
     73        this->registered_ = true;
     74
     75        COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
    6176    }
    6277
     
    8398        this->size_ = 0;
    8499        this->tickTime_ = 0.0;
    85 
    86         NotificationManager::getInstance().registerListener(this);
    87         this->registered_ = true;
    88     }
    89 
    90     /**
    91     @brief
    92         Sets the defaults.
    93     */
    94     void NotificationQueue::setDefaults(void)
    95     {
    96         this->setMaxSize(DEFAULT_SIZE);
    97         this->setNotificationLength(DEFAULT_LENGTH);
    98         this->setDisplayTime(DEFAULT_DISPLAY_TIME);
    99         this->setPosition(DEFAULT_POSITION);
    100 
    101         this->setTargets(NotificationManager::ALL);
    102 
    103         this->setFontSize(DEFAULT_FONT_SIZE);
    104         this->setFont(DEFAULT_FONT);
    105     }
    106 
    107     /**
    108     @brief
    109         Method for creating a NotificationQueue object through XML.
    110     */
    111     void NotificationQueue::XMLPort(Element& xmlElement, XMLPort::Mode mode)
    112     {
    113         SUPER(NotificationQueue, XMLPort, xmlElement, mode);
    114 
    115         this->setDefaults();
    116 
    117         XMLPortParam(NotificationQueue, "maxSize", setMaxSize, getMaxSize, xmlElement, mode);
    118         XMLPortParam(NotificationQueue, "notificationLength", setNotificationLength, getNotificationLength, xmlElement, mode);
    119         XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlElement, mode);
    120         XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlElement, mode);
    121         XMLPortParam(NotificationQueue, "font", setFont, getFont, xmlElement, mode);
    122         XMLPortParam(NotificationQueue, "fontSize", setFontSize, getFontSize, xmlElement, mode);
    123         XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode);
    124 
    125         COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
     100    }
     101
     102    /**
     103    //TODO: Document.
     104    */
     105    void NotificationQueue::create(void)
     106    {
     107        //TODO: Also transfer font and fontsize.
     108        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
     109        this->positionChanged();
    126110    }
    127111
     
    139123            this->timeLimit_.time = std::time(0)-this->displayTime_; //!< Container containig the current time.
    140124
    141             std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it;
    142             it = this->containers_.begin();
    143             while(it != this->containers_.upper_bound(&this->timeLimit_)) //!< Iterate through all elements whose creation time is smaller than the current time minus the display time.
     125            std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = this->ordering_.begin();
     126            while(it != this->ordering_.upper_bound(&this->timeLimit_)) //!< Iterate through all elements whose creation time is smaller than the current time minus the display time.
    144127            {
    145                 this->removeContainer(*it);
    146                 this->scroll(Vector2(0.0f,-(1.1f*this->getFontSize())));
    147                 it = this->containers_.begin(); //TODO: Needed?
     128                NotificationContainer* temp = *it;
     129                it++;
     130                this->remove(temp);
    148131            }
    149132
    150             this->tickTime_ = 0.0f; //!< Reset time counter.
     133            this->tickTime_ = this->tickTime_ - (int)this->tickTime_; //!< Reset time counter.
    151134        }
    152135    }
     
    161144        this->clear();
    162145
    163         std::multimap<std::time_t,Notification*>* notifications = new std::multimap<std::time_t,Notification*>;
     146        std::multimap<std::time_t, Notification*>* notifications = new std::multimap<std::time_t, Notification*>;
    164147        if(!NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_)) //!< Get the Notifications sent in the interval form now to minus the display time.
    165148        {
     
    171154            return;
    172155
    173         for(std::multimap<std::time_t,Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) //!> Add all Notifications.
    174         {
    175             this->addNotification(it->second, it->first);
    176         }
     156        for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) //!> Add all Notifications.
     157            this->push(it->second, it->first);
    177158
    178159        delete notifications;
     
    191172    void NotificationQueue::update(Notification* notification, const std::time_t & time)
    192173    {
    193         this->addNotification(notification, time);
    194 
    195         std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it;
    196         while(this->getSize() > this->getMaxSize())
    197         {
    198             it = this->containers_.begin();
    199             this->removeContainer(*it);
    200             this->scroll(Vector2(0.0f,-(1.1f*this->getFontSize())));
    201         }
    202 
    203         COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notifications has been added." << std::endl;
     174        this->push(notification, time);
     175
     176        COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notification has been added." << std::endl;
     177    }
     178
     179    /**
     180    @brief
     181        Sets the name of the NotificationQueue.
     182    @param name
     183        The name to be set.
     184    @return
     185        returns true if successful.
     186    */
     187    bool NotificationQueue::setName(const std::string& name)
     188    {
     189        //TODO: Test uniqueness of name.
     190        this->name_ = name;
     191        return true;
    204192    }
    205193
     
    212200        Returns true if successful.
    213201    */
    214     bool NotificationQueue::setMaxSize(int size)
    215     {
    216         if(size < 0)
    217             return false;
     202    void NotificationQueue::setMaxSize(unsigned int size)
     203    {
    218204        this->maxSize_ = size;
    219205        this->update();
    220         return true;
    221206    }
    222207
     
    229214        Returns true if successful.
    230215    */
    231     bool NotificationQueue::setNotificationLength(int length)
    232     {
    233         if(length < 0)
    234             return false;
     216    void NotificationQueue::setNotificationLength(unsigned int length)
     217    {
    235218        this->notificationLength_ = length;
    236219        this->update();
    237         return true;
    238220    }
    239221
     
    246228        Returns true if successful.
    247229    */
    248     bool NotificationQueue::setDisplayTime(int time)
    249     {
    250         if(time < 0)
    251             return false;
     230    void NotificationQueue::setDisplayTime(unsigned int time)
     231    {
    252232        this->displayTime_ = time;
    253233        this->update();
    254         return true;
    255234    }
    256235
     
    330309        if(size <= 0)
    331310            return false;
    332         this->fontSize_ = size;
    333         for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); it++) //!< Set the font size for each overlay.
    334         {
    335             it->second->overlay->setFontSize(size);
    336         }
     311       
    337312        return true;
    338313    }
     
    348323    bool NotificationQueue::setFont(const std::string & font)
    349324    {
    350         this->font_ = font;
    351         for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); it++) //!< Set the font for each overlay.
    352         {
    353             it->second->overlay->setFont(font);
    354         }
     325       
    355326        return true;
    356327    }
     
    358329    /**
    359330    @brief
    360         Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
    361     @param pos
    362         The vector the NotificationQueue is scrolled.
    363     */
    364     void NotificationQueue::scroll(const Vector2 pos)
    365     {
    366         for (std::map<Notification*, NotificationOverlayContainer*>::iterator it = this->overlays_.begin(); it != this->overlays_.end(); ++it) //!< Scroll each overlay.
    367         {
    368             it->second->overlay->scroll(pos);
    369         }
    370     }
    371 
    372     /**
    373     @brief
    374331        Aligns all the Notifications to the position of the NotificationQueue.
    375332    */
    376333    void NotificationQueue::positionChanged(void)
    377334    {
    378         int counter = 0;
    379         for (std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it = this->containers_.begin(); it != this->containers_.end(); it++) //!< Set the position for each overlay.
    380         {
    381             (*it)->overlay->setPosition(this->getPosition());
    382             (*it)->overlay->scroll(Vector2(0.0f,(1.1f*this->getFontSize())*counter));
    383             counter++;
    384         }
     335        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changePosition(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getPosition().x) + ", " + multi_cast<std::string>(this->getPosition().y) + ")");
    385336    }
    386337
     
    388339    @brief
    389340        Adds a Notification, to the queue.
    390         It inserts it into the storage containers, creates an corresponding overlay and a container.
     341        It inserts it into the storage containers, creates a corresponding container and pushes the Notification message to the GUI.
    391342    @param notification
    392343        The Notification.
     
    394345        The time.
    395346    */
    396     void NotificationQueue::addNotification(Notification* notification, const std::time_t & time)
    397     {
    398         NotificationOverlayContainer* container = new NotificationOverlayContainer;
    399         container->overlay = new NotificationOverlay(this, notification);
     347    void NotificationQueue::push(Notification* notification, const std::time_t & time)
     348    {
     349        NotificationContainer* container = new NotificationContainer;
    400350        container->notification = notification;
    401351        container->time = time;
    402         std::string timeString = std::ctime(&time);
    403         timeString.erase(timeString.length()-1);
    404         const std::string& addressString = multi_cast<std::string>(reinterpret_cast<unsigned long>(notification));
    405         container->name = "NotificationOverlay(" + timeString + ")&" + addressString;
    406 
    407         this->containers_.insert(container);
    408         this->overlays_[notification] = container;
    409         this->addElement(container->overlay);
    410         this->size_= this->size_+1;
    411 
    412         container->overlay->scroll(Vector2(0.0f,(1.1f*this->getFontSize())*(this->getSize()-1)));
    413     }
    414 
    415     /**
    416     @brief
    417         Removes a container from the queue.
     352       
     353        // If the maximum size of the NotificationQueue has been reached the last (least recently added) Notification is removed.
     354        if(this->getSize() >= this->getMaxSize())
     355            this->pop();
     356
     357        this->size_++;
     358
     359        this->ordering_.insert(container);
     360        this->notifications_.insert(this->notifications_.begin(), container);
     361
     362        //TODO: Clip message if necessary.
     363        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
     364    }
     365
     366    /**
     367    @brief
     368        Removes the least recently added Notification form the NotificationQueue.
     369    */
     370    void NotificationQueue::pop(void)
     371    {
     372        NotificationContainer* container = this->notifications_.back();
     373        this->ordering_.erase(container);
     374        this->notifications_.pop_back();
     375        this->size_--;
     376        delete container;
     377        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")");
     378    }
     379
     380    /**
     381    @brief
     382        Removes the Notification that is stored in the input container.
    418383    @param container
    419         A pointer to the container.
    420     @return
    421         Returns true if successful.
    422     */
    423     bool NotificationQueue::removeContainer(NotificationOverlayContainer* container)
    424     {
    425         if(this->size_ == 0) //!< You cannot remove anything if the queue is empty.
    426             return false;
    427 
    428         // Unregister the NotificationQueue with the NotificationManager.
    429         NotificationManager::getInstance().unregisterNotification(container->notification, this);
    430 
    431         this->removeElement(container->overlay);
    432         this->containers_.erase(container);
    433         this->overlays_.erase(container->notification);
    434         container->overlay->destroy();
     384        The NotificationContainer with the Notification to be removed.
     385    */
     386    void NotificationQueue::remove(NotificationContainer* container)
     387    {
     388        std::vector<NotificationContainer*>::iterator it = std::find(this->notifications_.begin(), this->notifications_.end(), container);
     389        std::vector<NotificationContainer*>::difference_type index = it - this->notifications_.begin ();
     390        this->ordering_.erase(container);
     391        this->notifications_.erase(it);
     392        this->size_--;
    435393        delete container;
    436         this->size_= this->size_-1;
    437 
    438         return true;
     394        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
    439395    }
    440396
     
    445401    void NotificationQueue::clear(void)
    446402    {
    447         std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare>::iterator it = this->containers_.begin();
    448         while(it != this->containers_.end())
    449         {
    450             this->removeContainer(*it);
    451             it = this->containers_.begin();
    452         }
     403        this->ordering_.clear();
     404        for(std::vector<NotificationContainer*>::iterator it = this->notifications_.begin(); it != this->notifications_.end(); it++)
     405        {
     406            delete *it;
     407        }
     408        this->notifications_.clear();
     409        this->size_ = 0;
     410        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
    453411    }
    454412
  • code/branches/notifications/src/modules/notifications/NotificationQueue.h

    r7164 r7338  
    4141#include <set>
    4242#include <string>
     43#include <vector>
    4344
    4445#include "util/Math.h"
     46#include "core/OrxonoxClass.h"
    4547#include "tools/interfaces/Tickable.h"
    46 #include "overlays/OverlayGroup.h"
    4748#include "interfaces/NotificationListener.h"
     49#include "NotificationManager.h"
    4850
    4951namespace orxonox
     
    5153
    5254    //! Container to allow easy handling.
    53     struct NotificationOverlayContainer
     55    struct NotificationContainer
    5456    {
    55         NotificationOverlay* overlay; //!< Pointer to the NotificationOverlay, everything is about.
    5657        Notification* notification; //!< The Notification displayed by the overlay.
    5758        time_t time; //!< The time the Notification was sent and thus first displayed.
    58         std::string name; //!< The name of the overlay.
    5959    };
    6060
    6161    //! Struct to allow ordering of NotificationOverlayContainers.
    62     struct NotificationOverlayContainerCompare {
    63         bool operator() (const NotificationOverlayContainer* const & a, const NotificationOverlayContainer* const & b) const
     62    struct NotificationContainerCompare {
     63        bool operator() (const NotificationContainer* const & a, const NotificationContainer* const & b) const
    6464            { return a->time < b->time; } //!< Ordered by time.
    6565    };
     
    6868    @brief
    6969        Displays Notifications from specific senders.
    70         Beware! The NotificationQueue is an OverlayGruop and thus cannot be be a sub-element of an OverlayGroup (at least no for now.)
    71 
    72         Creating a NotificationQueue through XML goes as follows:
    73         Be aware that the NotificationQueue must be inside the <Level></Level> tags or bad things will happen.
    74         <NotificationQueue
    75             name = "SuperQueue" //Name of your OverlayQueue.
    76             maxSize = "5" //The maximum number of Notifications displayed. (Default is 5)
    77             notificationLength = "64" //The maximum number of characters of a Notification, that are displayed. (Default is 64)
    78             displayTime = "30" //The time a Notification is displayed in seconds. (Default is 30)
    79             targets = "target1, target2" //The senders this NotificationQueue displays Notifications from. (all, if all Notifications should be displayed.)
    80             font = "VeraMono" //The font (Default is VeraMono)
    81             fontSize = '0.4' //The font size. (Default is 0.025)
    82             position = "0.0, 0.0" //The position of the NotificationQueue. (Default is 0.0,0.0)
    83         />
    8470    @author
    8571        Damian 'Mozork' Frick
    8672    */
    8773
    88     class _NotificationsExport NotificationQueue : public OverlayGroup, public Tickable, public NotificationListener
     74    class _NotificationsExport NotificationQueue : public Tickable, public NotificationListener
    8975    {
    9076
    9177        public:
    92             NotificationQueue(BaseObject* creator);
     78            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 length = NotificationQueue::DEFAULT_LENGTH, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
    9379            virtual ~NotificationQueue();
    94 
    95             virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML.
    9680
    9781            virtual void tick(float dt); //!< To update from time to time.
     
    10185
    10286            /**
     87            @brief Get the name of the NotificationQueue.
     88            @return Returns the name.
     89            */
     90            inline const std::string& getName() const
     91                { return this->name_; }
     92
     93            /**
    10394            @brief Returns the maximum number of Notifications displayed.
    10495            @return Returns maximum size.
    10596            */
    106             inline int getMaxSize() const
     97            inline unsigned int getMaxSize() const
    10798                { return this->maxSize_; }
    10899            /**
     
    110101            @return Returns the size of the queue.
    111102            */
    112             inline int getSize() const
     103            inline unsigned int getSize() const
    113104                { return this->size_; }
    114105            /**
     
    116107            @return Returns the maximum Notification length.
    117108            */
    118             inline int getNotificationLength() const
     109            inline unsigned int getNotificationLength() const
    119110                { return this->notificationLength_; }
    120111            /**
     
    122113            @return Returns the display time.
    123114            */
    124             inline int getDisplayTime() const
     115            inline float getDisplayTime() const
    125116                { return this->displayTime_; }
    126117            /**
     
    158149                { this->position_ = pos; this->positionChanged(); }
    159150
    160             void scroll(const Vector2 pos); //!< Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
    161 
    162151        private:
    163             static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    164             static const int DEFAULT_LENGTH = 64; //!< The default maximum number of characters displayed.
    165             static const int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
     152            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
     153            static const unsigned int DEFAULT_LENGTH = 64; //!< The default maximum number of characters displayed.
     154            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
    166155            static const float DEFAULT_FONT_SIZE; //!< The default font size.
    167156
     
    169158            static const Vector2 DEFAULT_POSITION; //!< the default position.
    170159
    171             int maxSize_; //!< The maximal number of Notifications displayed.
    172             int size_; //!< The number of Notifications displayed.
    173             int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.
    174             int displayTime_; //!< The time a Notification is displayed.
     160            std::string name_; //!< The name of the NotificationQueue.
     161
     162            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
     163            unsigned int size_; //!< The number of Notifications displayed.
     164            unsigned int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.
     165            unsigned int displayTime_; //!< The time a Notification is displayed.
    175166            Vector2 position_; //!< The position of the NotificationQueue.
    176167
     
    180171            std::string font_; //!< The font.
    181172
    182             std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps.
    183             std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding.
     173            std::multiset<NotificationContainer*, NotificationContainerCompare> ordering_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps. //TODO: Would set work as well?
     174            std::vector<NotificationContainer*> notifications_;
    184175
    185176            float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick.
    186             NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
     177            NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
    187178
    188179            bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
    189180
    190181            void initialize(void); //!< Initializes the object.
    191             void setDefaults(void); //!< Helper method to set the default values.
    192 
    193             bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications.
    194             bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
    195             bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
     182            void create(void);
     183
     184            bool setName(const std::string& name); //!< Sets the name of the NotificationQueue.
     185
     186            void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
     187            void setNotificationLength(unsigned int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
     188            void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
    196189
    197190            bool setTargets(const std::string & targets); //!< Set the targets of this queue.
     
    202195            void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
    203196
    204             void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.
    205             bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue.
     197            void push(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.
     198            void pop(void);
     199            void remove(NotificationContainer* container);
    206200
    207201            void clear(void); //!< Clear the queue.
  • code/branches/notifications/src/modules/notifications/NotificationsPrereqs.h

    r7285 r7338  
    6868    class NotificationDispatcher;
    6969    class NotificationManager;
    70     class NotificationOverlay;
    7170    class NotificationQueue;
    7271   
Note: See TracChangeset for help on using the changeset viewer.