Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7343


Ignore:
Timestamp:
Sep 3, 2010, 11:30:24 PM (14 years ago)
Author:
dafrick
Message:

Some documenting and adjustment.

Location:
code/branches/notifications
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/notifications/data/gui/scripts/NotificationLayer.lua

    r7342 r7343  
    99    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    1010    local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name)
     11    queue:setProperty("Alpha", 0.3)
     12    queue:setProperty("InheritsAlpha", "setFalse")
    1113    root:addChildWindow(queue)
    1214
     
    3436        winMgr:destroyWindow(queue)
    3537    end
    36 end
    37 
    38 function P.changePosition(name, xPos, yPos)
    39     local queue = P.nameToQueueHelper(name)
    40     if queue == nil then
    41         cout(0, "Queue is nil!")
    42         return
    43     end
    44     queue:setPosition(CEGUI.UVector2(CEGUI.UDim(tonumber(xPos), 0), CEGUI.UDim(tonumber(yPos), 0)))
    4538end
    4639
     
    9083end
    9184
     85function P.changePosition(name, xPos, yPos)
     86    local queue = P.nameToQueueHelper(name)
     87    if queue == nil then
     88        cout(0, "Queue is nil!")
     89        return
     90    end
     91    queue:setPosition(CEGUI.UVector2(CEGUI.UDim(tonumber(xPos), 0), CEGUI.UDim(tonumber(yPos), 0)))
     92    queue:setWidth(CEGUI.UDim(1.0, -xPos))
     93end
     94
     95function P.changeSize(name, size)
     96    local queue = P.nameToQueueHelper(name)
     97    if queue == nil then
     98        cout(0, "Queue is nil!")
     99        return
     100    end
     101    queue:setHeight(CEGUI.UDim(0, P.queueHeightHelper(queue, size)))
     102end
     103
    92104function P.nameToQueueHelper(name)
    93105    local queue = nil
  • code/branches/notifications/src/modules/notifications/NotificationQueue.cc

    r7342 r7343  
    176176    /**
    177177    @brief
    178         Adds a Notification, to the queue.
     178        Adds a Notification to the NotificationQueue.
    179179        It inserts it into the storage containers, creates a corresponding container and pushes the Notification message to the GUI.
    180180    @param notification
     
    234234    /**
    235235    @brief
    236         Clears the queue by removing all containers.
     236        Clears the queue by removing all Notifications.
    237237    */
    238238    void NotificationQueue::clear(void)
     
    240240        this->ordering_.clear();
    241241        for(std::vector<NotificationContainer*>::iterator it = this->notifications_.begin(); it != this->notifications_.end(); it++)
    242         {
    243242            delete *it;
    244         }
     243
    245244        this->notifications_.clear();
    246245        this->size_ = 0;
     
    250249    /**
    251250    @brief
     251        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    }
     257
     258    /**
     259    @brief
    252260        Sets the name of the NotificationQueue.
    253261    @param name
     
    274282    {
    275283        this->maxSize_ = size;
     284        this->sizeChanged();
     285    }
     286
     287    /**
     288    @brief
     289        Adjusts the NotificationQueue, when the maximum size has changed.
     290    */
     291    void NotificationQueue::sizeChanged(void)
     292    {
     293        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeSize(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getSize()) + ")");
    276294        this->update();
    277295    }
     
    308326        string->clear();
    309327        bool first = true;
    310         for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) //!< Iterate through the set of targets.
     328        for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) // Iterate through the set of targets.
    311329        {
    312330            if(!first)
    313             {
    314331                *string += ',';
    315             }
    316332            else
    317             {
    318333                first = false;
    319             }
    320334            *string += *it;
    321335        }
     
    339353        std::string* pTemp;
    340354        unsigned int index = 0;
    341         while( index < targets.size() ) //!< Go through the string, character by character until the end is reached.
     355        while(index < targets.size()) // Go through the string, character by character until the end is reached.
    342356        {
    343357            pTemp = new std::string();
     
    354368    }
    355369
    356     /**
    357     @brief
    358         Aligns all the Notifications to the position of the NotificationQueue.
    359     */
    360     void NotificationQueue::positionChanged(void)
    361     {
    362         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changePosition(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getPosition().x) + ", " + multi_cast<std::string>(this->getPosition().y) + ")");
    363     }
    364 
    365370}
  • code/branches/notifications/src/modules/notifications/NotificationQueue.h

    r7342 r7343  
    2828
    2929/**
    30     @file
     30    @file NotificationQueue.h
    3131    @brief Definition of the NotificationQueue class.
    3232*/
     
    5555    struct NotificationContainer
    5656    {
    57         Notification* notification; //!< The Notification displayed by the overlay.
     57        Notification* notification; //!< The Notification displayed.
    5858        time_t time; //!< The time the Notification was sent and thus first displayed.
    5959    };
    6060
    61     //! Struct to allow ordering of NotificationOverlayContainers.
     61    //! Struct to allow ordering of NotificationContainers.
    6262    struct NotificationContainerCompare {
    6363        bool operator() (const NotificationContainer* const & a, const NotificationContainer* const & b) const
     
    7171        Damian 'Mozork' Frick
    7272    */
    73 
    7473    class _NotificationsExport NotificationQueue : public Tickable, public NotificationListener
    7574    {
     
    134133            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    135134            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
    136 
    137135            static const Vector2 DEFAULT_POSITION; //!< the default position.
    138136
     
    147145            std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
    148146
    149             std::multiset<NotificationContainer*, NotificationContainerCompare> ordering_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps. //TODO: Would set work as well?
    150             std::vector<NotificationContainer*> notifications_;
     147            std::multiset<NotificationContainer*, NotificationContainerCompare> ordering_; //!< The NotificationContainers ordered by the time they were registered. //TODO: Would set work as well?
     148            std::vector<NotificationContainer*> notifications_; //!< The NotificationContainers in the order they were added to the NotificationQueue.
    151149
    152             float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick.
     150            float tickTime_; //!< Helper variable, to not have to check for Notifications that have been displayed too long, every tick.
    153151            NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
    154152
     
    156154
    157155            void initialize(void); //!< Initializes the object.
    158             void create(void);
     156            void create(void); //!< Creates the NotificationQueue in lua.
    159157
    160158            bool setName(const std::string& name); //!< Sets the name of the NotificationQueue.
     
    163161            void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
    164162
    165             bool setTargets(const std::string & targets); //!< Set the targets of this queue.
     163            bool setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
    166164
    167165            void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
     166            void sizeChanged(void); //!< Adjusts the NotificationQueue, when the maximum size has changed.
    168167
    169             void push(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.
    170             void pop(void);
    171             void remove(NotificationContainer* container);
     168            void push(Notification* notification, const std::time_t & time); //!< Add a Notification to the NotificationQueue.
     169            void pop(void); //!< Removes the least recently added Notification form the NotificationQueue.
     170            void remove(NotificationContainer* container); //!< Removes the Notification that is stored in the input container.
    172171
    173             void clear(void); //!< Clear the queue.
     172            void clear(void); //!< Clears the queue by removing all Notifications.
    174173
    175174    };
Note: See TracChangeset for help on using the changeset viewer.