Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8448 for code


Ignore:
Timestamp:
May 11, 2011, 10:45:56 PM (14 years ago)
Author:
dafrick
Message:

Extending NotificationQueueCEGUI.

Location:
code/branches/tutoriallevel2
Files:
10 edited

Legend:

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

    r8446 r8448  
    2727        ["window"]    = queue,
    2828        ["name"]      = name,
    29         ["edit"]      = nil,
     29        ["maxSize"]      = size,
    3030        ["visible"]   = false,
    3131        ["fontSize"]  = 12,
     
    183183-- Change the size of the queue.
    184184-- The parameters are (in order) 'name of the queue', 'relative width', 'absolute width in pixel', 'relative height', 'absolute heigth in pixel'.
    185 -- Additionally the last parameter can be ommitted and relativeHeight can be set to the size (i.e. the maximal number of notifications displayed) of the queue, which leads to the height being set such that all notifications can be displayed.
     185-- Additionally the last two parameters can be ommitted, which leads to the height being set such that all notifications can be displayed. using the size of the queue.
    186186function P.resizeQueue(queueName, relativeWidth, absoluteWidth, relativeHeight, absoluteHeigth)
    187     local queueWindow = P.queueList[queueName].window
     187    local queue = P.queueList[queueName]
     188    local queueWindow = queue.window
    188189    if queueWindow == nil then
    189190        return
    190191    end
    191192    if absoluteHeigth == nil then
    192         absoluteHeigth = P.queueHeightHelper(P.queueList[queueName], relativeHeight)
     193        absoluteHeigth = P.queueHeightHelper(queue, queue.maxSize)
    193194        relativeHeight = 0
    194195    end
     
    196197end
    197198
    198 -- Change the font size and font color of all notifications in a queueHeightHelper
    199 -- The parameters are (in order) 'name of the queue', 'font size', 'ARGB of the font color in hex notation'.
    200 function P.changeQueueFont(queueName, size, color)
    201     local queue = P.queueList[queueName]
    202     local queueWindow = queue.window
    203     if queueWindow == nil then
    204         return
    205     end
    206 
    207     queue.fontSize = size
    208     local changeColor = false
    209     if color ~= nil then
    210         queue.fontColor = color
    211         changeColor = true
    212     end
    213     for i=queue.first,queue.last-1 do
    214         P.setItemFontHelper(queue.items[i], queue, changeColor)
    215     end
    216 end
    217 
     199-- Change the horizontal alignment of the displayed notifications.
     200-- The parameters are the name of the queue and the alignment parameter,
    218201function P.changeQueueAlignment(queueName, alignment)
    219202    local queue = P.queueList[queueName]
     
    222205        return
    223206    end
    224    
     207
    225208    queue.alignment = alignment
    226209    local item = nil
     
    228211        item = queue.items[i]
    229212        item:setProperty("HorzFormatting", queue.alignment)
     213    end
     214end
     215
     216-- Change the font size  of all notifications in a queue.
     217-- The parameters are (in order) 'name of the queue', 'font size'.
     218function P.changeQueueFontSize(queueName, size)
     219    local queue = P.queueList[queueName]
     220    local queueWindow = queue.window
     221    if queueWindow == nil then
     222        return
     223    end
     224
     225    queue.fontSize = size
     226    for i=queue.first,queue.last-1 do
     227        P.setItemFontHelper(queue.items[i], queue, false)
     228    end
     229end
     230
     231-- Change the font color of all notifications in a queue.
     232-- The parameters are (in order) 'name of the queue', 'ARGB of the font color in hex notation'.
     233function P.changeQueueFontColor(queueName, color)
     234    local queue = P.queueList[queueName]
     235    local queueWindow = queue.window
     236    if queueWindow == nil then
     237        return
     238    end
     239
     240    queue.fontColor = color
     241    for i=queue.first,queue.last-1 do
     242        P.setItemFontHelper(queue.items[i], queue, true)
    230243    end
    231244end
  • code/branches/tutoriallevel2/src/modules/notifications/Notification.cc

    r8445 r8448  
    4747    @param sender
    4848        The sender of the Notification.
     49    @param type
     50        The type of the Notification.
    4951    */
    5052    Notification::Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type)
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc

    r8446 r8448  
    3636#include "core/command/ConsoleCommand.h"
    3737#include "core/CoreIncludes.h"
    38 #include "core/GameMode.h"
    39 #include "core/GUIManager.h"
    4038#include "core/LuaState.h"
    41 #include "util/Convert.h"
    4239#include "util/ScopedSingletonManager.h"
    4340
     
    4845#include "NotificationQueueCEGUI.h"
    4946
    50 #include "ToluaBindNotifications.h"
    51 
    5247namespace orxonox
    5348{
    54 
    55     // Register tolua_open function when loading the library.
    56     DeclareToluaInterface(Notifications);
    5749
    5850    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
     
    108100    @param sender
    109101        The name of the entity (of the collective) that sent the new Notification.
     102    @param type
     103        The type of the new Notification.
    110104    @return
    111105        Returns true if successful.
     
    126120    @param sender
    127121        The The name of the entity (of the collective) that sent the command.
     122    @return
     123        Returns true if the command was successfully executed.
    128124    */
    129125    bool NotificationManager::executeCommand(notificationCommand::Value command, const std::string& sender)
    130126    {
     127        bool commandExecuted = false;
    131128        if(command == notificationCommand::clear)
    132129        {
    133             this->commandClear(sender);
    134             return true;
    135         }
    136 
    137         return false;
     130            if(this->commandClear(sender))
     131                commandExecuted = true;
     132        }
     133
     134        if(commandExecuted)
     135            COUT(3) << "Notification command \"" << NotificationListener::command2Str(command) << "\" executed." << endl;
     136
     137        return commandExecuted;
    138138    }
    139139
     
    143143    @param sender
    144144        The sender of the clear command.
    145     */
    146     void NotificationManager::commandClear(const std::string& sender)
     145    @return
     146        Returns true if the command was successfully executed by at least one NotificationQueue, false if it was not executed.
     147    */
     148    bool NotificationManager::commandClear(const std::string& sender)
    147149    {
    148150        bool all = (sender == NotificationListener::ALL);
     151        bool executed = false;
    149152        // Clear all NotificationQueues that have the input sender as target.
    150153        for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.
     
    153156            // If either the sender is 'all', the NotificationQueue has as target all or the NotificationQueue has the input sender as a target.
    154157            if(all || set.find(NotificationListener::ALL) != set.end() || set.find(sender) != set.end())
    155                 it->second->tidy();
    156         }
     158                executed = it->second->tidy() || executed;
     159        }
     160
     161        return executed;
    157162    }
    158163   
     
    385390    /**
    386391    @brief
    387         Loads all the NotificationQueues that should exist.
    388     */
    389     void NotificationManager::loadQueues(void)
    390     {
    391         NotificationQueue* allQueue = new NotificationQueueCEGUI("all");
    392         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"all\", 0.5, 0, " + multi_cast<std::string>(allQueue->getMaxSize()) + ")");
    393         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)");
    394 
    395         NotificationQueue* infoQueue = new NotificationQueueCEGUI("info", NotificationListener::ALL, 1, -1);
    396         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"CCFFFF00\")");
    397         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")");
    398         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"info\", 0.2, 0, 0.8, 0)");
    399         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueAlignment(\"info\", \"HorzCentred\")");
    400     }
    401 
    402     /**
    403     @brief
    404         Creates a new NotificationQueue.
    405         This is used in lua.
    406     @param name
    407         The name of the new NotificationQueue.
    408     */
    409     void NotificationManager::createQueue(const std::string& name)
    410     {
    411         new NotificationQueue(name);
    412     }
    413 
    414     /**
    415     @brief
    416392        Get the NotificationQueue with the input name.
    417393    @param name
     
    430406    }
    431407
     408    /**
     409    @brief
     410        Loads all the NotificationQueues that should exist.
     411    */
     412    void NotificationManager::loadQueues(void)
     413    {
     414        NotificationQueueCEGUI* allQueue = new NotificationQueueCEGUI("all");
     415        allQueue->setDisplaySize(Vector2(0.5, 0));
     416        allQueue->setPosition(Vector4(0.0, 10, 0.3, 0));
     417
     418        NotificationQueueCEGUI* infoQueue = new NotificationQueueCEGUI("info", NotificationListener::ALL, 1, -1);
     419        infoQueue->setPosition(Vector4(0.2, 0, 0.8, 0));
     420        infoQueue->setFontSize(24);
     421        infoQueue->setFontColor(Vector4(1.0, 1.0, 0.0, 0.8));
     422        infoQueue->setAlignment("HorzCentred");
     423        infoQueue->setDisplaySize(Vector2(0.6, 0.0));
     424    }
     425
    432426}
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h

    r8446 r8448  
    5050    /**
    5151    @brief
    52         The Singleton NotificationManager is a NotificationListener and functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationQueues "NotificationQueues".
    53         It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationLQueue "NotificationQueues".
     52        The Singleton NotificationManager is a NotificationListener and functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationQueue "NotificationQueues".
     53        It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationQueue "NotificationQueues".
    5454        It also works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer.
    5555
     
    9898            void unregisterQueue(NotificationQueue* queue); // Unregisters a NotificationQueue.
    9999
    100             // tolua_begin
    101             void loadQueues(void); // Loads all the NotificationQueues that should exist.
    102             void createQueue(const std::string& name); // Creates a new NotificationQueue.
    103             orxonox::NotificationQueue* getQueue(const std::string & name); // Get the NotificationQueue with the input name.
    104             // tolua_end
     100            void loadQueues(void); // tolua_export // Loads all the NotificationQueues that should exist.
     101
     102            NotificationQueue* getQueue(const std::string & name); // Get the NotificationQueue with the input name.
    105103
    106104        private:
     
    115113           
    116114            // Commands
    117             void commandClear(const std::string& sender); // The clear command. Clears all NotificationQueues that have its sender as a target.
     115            bool commandClear(const std::string& sender); // The clear command. Clears all NotificationQueues that have its sender as a target.
    118116
    119117    }; // tolua_export
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc

    r8446 r8448  
    208208
    209209        COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl;
     210        COUT(3) << "NotificationQueue \"" << this->getName() << "\": " << notification->getMessage() << endl;
    210211    }
    211212
     
    374375        }
    375376    }
    376    
    377     void NotificationQueue::tidy(void)
     377
     378    /**
     379    @brief
     380        Pops all Notifications from the NotificationQueue.
     381    @return
     382        Returns true if successful, false if not.
     383    */
     384    bool NotificationQueue::tidy(void)
    378385    {
    379386        while(this->size_ > 0)
    380387            this->pop();
     388        return true;
    381389    }
    382390
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h

    r8446 r8448  
    142142            const std::string& getTargets(void) const; //!< Returns a string consisting of the concatenation of the targets.
    143143
    144             void tidy(void);
     144            bool tidy(void); // Pops all Notifications from the NotificationQueue.
    145145           
    146146        protected:
    147             static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    148             static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
    149             static const int INF = -1; //!< Constant denoting infinity.
    150        
    151147            /**
    152148            @brief Is called when a notification was pushed.
     
    166162            virtual void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
    167163
     164        protected:
     165            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
     166            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
     167            static const int INF = -1; //!< Constant denoting infinity.
    168168
    169169        private:
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.cc

    r8446 r8448  
    3333
    3434#include "NotificationQueueCEGUI.h"
     35
     36#include <sstream>
    3537
    3638#include "core/CoreIncludes.h"
     
    4244#include "Notification.h"
    4345
     46#include "ToluaBindNotifications.h"
     47
    4448namespace orxonox
    4549{
    4650
     51    // Register tolua_open function when loading the library.
     52    DeclareToluaInterface(Notifications);
     53
    4754    NotificationQueueCEGUI::NotificationQueueCEGUI(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime) : NotificationQueue(name, senders, size, displayTime)
    4855    {
    4956        RegisterObject(NotificationQueueCEGUI);
     57
     58        this->displaySize_ = Vector4(1.0, 0.0, 0.0, 0.0);
     59        this->position_ = Vector4(0.0, 0.0, 0.0, 0.0);
     60        this->alignment_ = "LeftAligned";
     61        this->fontSize_ = 12;
     62        this->fontColor_ = Vector4(1.0, 1.0, 1.0, 1.0);
     63        this->fontColorStr_ = "FFFFFFFF";
    5064       
    5165        // Create the NotificationQueueCEGUI in lua.
     
    7387        NotificationQueue::destroy();
    7488    }
    75    
     89
     90    /**
     91    @brief
     92        Set the size of the window that displays the NotificationQueue.
     93    @param size
     94        The size is a vector with components:
     95        - The relative width of the window. (A value between 0 and 1)
     96        - The absolute width in pixels. (Additional to the relative width, can be negative)
     97        - The relative height of the window. (A value between 0 and 1)
     98        - The absolute height in pixels. (Additional to the relative width, can be negative.)
     99        If both the 3rd and 4th component of size are set to 0 the height is set such that exactly as many Notifications fit as is the maximum size of the NotificationQueue (in terms of the number of Notifications).
     100    */
     101    void NotificationQueueCEGUI::setDisplaySize(const Vector4& size)
     102    {
     103        if(this->displaySize_ == size)
     104            return;
     105
     106        if(size.x < 0.0 || size.x > 1.0 || size.z < 0.0 || size.z > 1.0)
     107        {
     108            COUT(2) << "The display size of the NotificationQueueCEGUI " << this->getName() << " was trying to be set, but the relative size was not in [0,1]. Aborting..." << endl;
     109            return;
     110        }
     111
     112        this->displaySize_ = size;
     113        if(size.z == 0.0 && size.w == 0.0)
     114            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->displaySize_.x) + ", " + multi_cast<std::string>(this->displaySize_.y) + ")");
     115        else
     116            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->displaySize_.x) + ", " + multi_cast<std::string>(this->displaySize_.y) + ", " + multi_cast<std::string>(this->displaySize_.z) + ", " + multi_cast<std::string>(this->displaySize_.w) + ")");
     117    }
     118
     119    /**
     120    @brief
     121        Set the position of the window that displays the NotificationQueue.
     122    @param position
     123        The position is a vector with components:
     124        - The relative x-position of the window. (A value between 0 and 1)
     125        - The absolute x-position in pixels. (Additional to the relative x-position, can be negative)
     126        - The relative y-position of the window. (A value between 0 and 1)
     127        - The absolute y-position in pixels. (Additional to the relative y-position, can be negative.)
     128    */
     129    void NotificationQueueCEGUI::setPosition(const Vector4& position)
     130    {
     131        if(this->position_ == position)
     132            return;
     133
     134        if(position.x < 0.0 || position.x > 1.0 || position.z < 0.0 || position.z > 1.0)
     135        {
     136            COUT(2) << "The position the NotificationQueueCEGUI " << this->getName() << " was trying to be set, but the relative position was not in [0,1]. Aborting..." << endl;
     137            return;
     138        }
     139
     140        this->position_ = position;
     141        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->position_.x) + ", " + multi_cast<std::string>(this->position_.y) + ", " + multi_cast<std::string>(this->position_.z) + ", " + multi_cast<std::string>(this->position_.w) + ")");
     142    }
     143
     144    /**
     145    @brief
     146        Set the horizontal alignment of the Notifications text.
     147    @param alignment
     148        The alignment of the Notifications, they are the possible string that the CEGUI Falagard StaticText HorzFormatting property can take.
     149    @see http://cegui.org.uk/api_reference/classCEGUI_1_1FalagardStaticTextProperties_1_1HorzFormatting.html
     150    */
     151    void NotificationQueueCEGUI::setAlignment(const std::string& alignment)
     152    {
     153        if(this->alignment_ == alignment)
     154            return;
     155
     156        // TODO: Check whether the alignment string is correct?
     157        this->alignment_ = alignment;
     158        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueAlignment(\"" + this->getName() + "\", \"" + this->alignment_ + "\")");
     159    }
     160
     161    /**
     162    @brief
     163        Set the font size of the text displayed by this NotificationQueue.
     164    @param size
     165        The font size.
     166    */
     167    void NotificationQueueCEGUI::setFontSize(unsigned int size)
     168    {
     169        if(this->fontSize_ == size)
     170            return;
     171
     172        this->fontSize_ = size;
     173        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFontSize(\"" + this->getName() + "\", " + multi_cast<std::string>(this->fontSize_) + ")");
     174    }
     175
     176    /**
     177    @brief
     178        Set the font color if the text displayed by this NotificationQueue.
     179    @param color
     180        The color is a vector with the components being RGBA and taking values from 0 to 1.
     181    */
     182    void NotificationQueueCEGUI::setFontColor(const Vector4& color)
     183    {
     184        if(this->fontColor_ == color)
     185            return;
     186
     187        this->fontColor_ = color;
     188        // Convert to ARGB format.
     189        std::stringstream stream;
     190        for(unsigned int i = 0; i < 4; i++)
     191            stream << std::hex << std::setw(2) << std::setfill('0') << int(this->fontColor_[(i+3)%4]*255);
     192        this->fontColorStr_ = stream.str();
     193        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFontColor(\"" + this->getName() + "\", \"" + this->fontColorStr_ + "\")");
     194    }
     195
     196    /**
     197    @brief
     198        Get the NotificationQueueCEGUI with the input name.
     199    @param name
     200        The name of the NotificationQueueCEGUI to be got.
     201    @return
     202        Returns a pointer to the NotificationQueueCEGUI, or NULL if it doesn't exist.
     203    */
     204    /*static*/ NotificationQueueCEGUI* NotificationQueueCEGUI::getQueue(const std::string& name)
     205    {
     206        NotificationQueue* queue = NotificationManager::getInstance().getQueue(name);
     207        if(queue == NULL || !queue->isA(Class(NotificationQueueCEGUI)))
     208            return NULL;
     209        return static_cast<NotificationQueueCEGUI*>(queue);
     210    }
     211
    76212    /**
    77213    @brief
     
    86222            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
    87223    }
    88    
     224
    89225    /**
    90226    @brief
     
    97233            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")");
    98234    }
    99    
     235
    100236    /**
    101237    @brief Is called when a notification was removed.
     
    108244            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
    109245    }
    110    
     246
    111247    /**
    112248    @brief
     
    118254    {
    119255        NotificationQueue::clear(noGraphics);
    120        
     256
    121257        // Clear the NotificationQueue in the GUI.
    122258        if(GameMode::showsGraphics() && !noGraphics)
    123259            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
    124260    }
    125    
     261
    126262    /**
    127263    @brief
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.h

    r8446 r8448  
    3939
    4040#include <string>
     41#include "util/Math.h"
    4142
    4243#include "NotificationManager.h"
     44
    4345#include "NotificationQueue.h"
    4446
     
    4648{ // tolua_export
    4749
    48     //TODO: Update.
    4950    /**
    5051    @brief
    51         Displays @ref orxonox::Notification "Notifications" from specific senders.
     52        Displays @ref orxonox::Notification "Notifications" using CEGUI.
    5253
    53         There are quite some parameters that influence the behavior of the NotificationQueue:
    54         - @b name The name of the NotificationQueue. It needs to be unique.
    55         - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays.
    56         - @b size The size of the NotificationQueue, it specifies how many @ref orxonox::Notification "Notifications" are displayed at once at the most.
    57         - @b displayTime The time a @ref orxonox::Notification "Notification" is displayed with this NotificationQueue.
     54        Apart form the parameters inherited by the @ref orxonox::NotificationQueue "NotificationQueue", there are some more parameters that influence the behavior of the NotificationQueueCEGUI:
     55        - @b displaySize The size of the window that displays the NotificationQueue.
     56        - @b position The position if the window that displays the NotificationQueue.
     57        - @b alignment The horizontal alignment of the displayed Notifications.
     58        - @b fontSize The font size of the displayed Notifications.
     59        - @b fontColor The font color of the displayed Notifications.
    5860
    5961    @author
    6062        Damian 'Mozork' Frick
    6163
     64    @see NotificationQueue
    6265    @ingroup Notifications
    6366    */
     
    7073            virtual ~NotificationQueueCEGUI();
    7174
    72             //! Destroys the NotificationQueue.
    73             void destroy(bool noGraphics = false); // tolua_export
     75            void destroy(bool noGraphics = false); // Destroys the NotificationQueue.
     76
     77            /**
     78            @brief Set the size of the window that displays the NotificationQueue.
     79            @param size A vector whose first component is the relative width of the window (a value between 0 and 1) and whose second component is the absolute width in pixels (additional to the relative width, can be negative). The height is set such that exactly as many Notifications fit as is the maximum size of the NotificationQueue (in terms of the number of Notifications).
     80            */
     81            inline void setDisplaySize(const Vector2& size)
     82                { this->setDisplaySize(Vector4(size.x, size.y, 0.0, 0.0)); }
     83            void setDisplaySize(const Vector4& size); // Set the size of the window that displays the NotificationQueue.
     84            /**
     85            @brief Get the size of the window that displays the NotificationQueue.
     86            @return Returns a vector with the display size.
     87            */
     88            inline const Vector4& getDisplaySize(void) const
     89                { return this->displaySize_; }
     90
     91            void setPosition(const Vector4& position); // Set the position of the window that displays the NotificationQueue.
     92            /**
     93            @brief Get the position of the window that displays the NotificationQueue.
     94            @return Returns a vector with the position.
     95            */
     96            inline const Vector4& getPosition(void) const
     97                { return this->position_; }
     98
     99            void setAlignment(const std::string& alignment); // Set the horizontal alignment of the Notifications text.
     100            /**
     101            @brief Get the horizontal alignment of the Notifications text.
     102            @return Returns a string with the horizontal alignment property.
     103            */
     104            inline const std::string& getAlignment(void)
     105                { return this->alignment_; }
     106
     107            void setFontSize(unsigned int size); // Set the font size of the text displayed by this NotificationQueue.
     108            /**
     109            @brief Get the font size of the text displayed by this NotificationQueue.
     110            @return Returns the font size.
     111            */
     112            inline unsigned int getFontSize(void)
     113                { return this->fontSize_; }
     114
     115            void setFontColor(const Vector4& color); // Set the font color if the text displayed by this NotificationQueue.
     116            /**
     117            @brief Get the font color of the text displayed by this NotificationQueue.
     118            @return Returns a vector with the components being RGBA, with values from 0 to 1.
     119            */
     120            inline const Vector4& getFontColor(void) const
     121                { return this->fontColor_; }
     122            /**
     123            @brief Get the font color of the text displayed by this NotificationQueue.
     124            @return Returns a string with the ARGB values in hexadecimal format.
     125            */
     126            inline const std::string& getFontColorStr(void) const
     127                { return this->fontColorStr_; }
     128
     129            static NotificationQueueCEGUI* getQueue(const std::string& name); // tolua_export
    74130           
    75131        protected:
     
    81137           
    82138        private:
    83             void create(void); // Creates the NotificationQueue in lua.           
     139            Vector4 displaySize_; //!< The size of the window that displays the NotificationQueue.
     140            Vector4 position_; //!< The position of the window that displays the NotificationQueue.
     141            std::string alignment_; //!< The horizontal alignment of the Notifications text.
     142            unsigned int fontSize_; //!< The font size of the Notifications text.
     143            Vector4 fontColor_; //!< The font color of the Notifications text as a vector, in RGBA form, with values from 0 to 1.
     144            std::string fontColorStr_; //!< The font color of the Notifications text as a string with the ARGB hexadecimal values.
     145           
     146            void create(void); // Creates the NotificationQueue in lua.
    84147
    85148    }; // tolua_export
  • code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.cc

    r8445 r8448  
    4747    // Commands
    4848    /*static*/ const std::string NotificationListener::COMMAND_CLEAR("clear");
     49    /*static*/ const std::string NotificationListener::COMMAND_NONE("none");
    4950   
    5051    registerStaticNetworkFunction(NotificationListener::sendHelper);
     
    108109        {
    109110            // If the notification is a message.
    110             if(!isCommand && it->registerNotification(message, sender, notificationMessageType::Value(messageType)))
    111                 COUT(3) << "Notification \"" << message << "\" sent." << std::endl;
     111            if(!isCommand)
     112                it->registerNotification(message, sender, notificationMessageType::Value(messageType));
    112113
    113114            // If the notification is a command.
     
    115116            {
    116117                notificationCommand::Value command = str2Command(message);
    117                 if(command != notificationCommand::none && it->executeCommand(command, sender))
    118                     COUT(3) << "Command \"" << message << "\" executed." << std::endl;
     118                if(command != notificationCommand::none)
     119                    it->executeCommand(command, sender);
    119120            }
    120121        }
     
    138139        return command;
    139140    }
     141
     142    /**
     143    @brief
     144        Helper method. Converts a command enum into its corresponding string.
     145    @param command
     146        The command to be converted.
     147    @return
     148        Returns the corresponding string.
     149    */
     150    /*static*/ const std::string& NotificationListener::command2Str(notificationCommand::Value command)
     151    {
     152        switch(command)
     153        {
     154            case notificationCommand::clear:
     155                return NotificationListener::COMMAND_CLEAR;
     156            default:
     157                return NotificationListener::COMMAND_NONE;
     158        }
     159    }
    140160   
    141161}
  • code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.h

    r8445 r8448  
    108108            /**
    109109            @brief Sends a specified command to the specified client from the specified sender.
    110             @param message The command that should be sent (and later executed).
     110            @param command The command that should be sent (and later executed).
    111111            @param sender The sender that sent the notification. Default is 'none'.
    112112            @param sendMode The mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is notificationSendMode::local.
     
    138138            */
    139139            virtual bool executeCommand(notificationCommand::Value command, const std::string& sender) { return false; }
     140
     141        public:
    140142           
    141143            static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationQueues.
     
    144146            //! Commands
    145147            static const std::string COMMAND_CLEAR;
     148            static const std::string COMMAND_NONE;
    146149           
    147150        protected:
    148151            static void sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand = false, notificationMessageType::Value messageType = notificationMessageType::info); // Helper method to send both notifications and commands over the network.
    149            
     152
    150153            static notificationCommand::Value str2Command(const std::string& string); // Helper method. Converts a string into the enum for a command.
     154            static const std::string& command2Str(notificationCommand::Value command); // Helper method. Converts a command enum into its corresponding string.
    151155    };
    152156}
Note: See TracChangeset for help on using the changeset viewer.