Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8636


Ignore:
Timestamp:
May 28, 2011, 4:21:14 PM (13 years ago)
Author:
dafrick
Message:

Making NotificationQueue XML-loadable. Adding notifications to all levels.

Location:
code/branches/tutoriallevel3
Files:
1 added
42 edited

Legend:

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

    r8453 r8636  
    2727        ["window"]    = queue,
    2828        ["name"]      = name,
    29         ["maxSize"]      = size,
     29        ["maxSize"]   = size,
    3030        ["visible"]   = false,
    3131        ["fontSize"]  = 12,
     
    4949
    5050    if queue ~= nil then
     51        queue.window:getParent():removeChildWindow(queue.window)
    5152        winMgr:destroyWindow(queue.window)
    5253    end
  • code/branches/tutoriallevel3/data/levels/FPSTest.oxw

    r8079 r8636  
    2121    <Template link=lodtemplate_default />
    2222  </templates>
     23  <?lua include("includes/notifications.oxi") ?>
    2324
    2425  <Scene
  • code/branches/tutoriallevel3/data/levels/asteroids.oxw

    r8079 r8636  
    1414    <Template link=lodtemplate_default />
    1515  </templates>
     16  <?lua include("includes/notifications.oxi") ?>
    1617
    1718  <Scene
  • code/branches/tutoriallevel3/data/levels/dynamicMatch.oxw

    r8079 r8636  
    1616    <Template link=lodtemplate_default />
    1717  </templates>
     18  <?lua include("includes/notifications.oxi") ?>
    1819
    1920  <Scene
  • code/branches/tutoriallevel3/data/levels/earth.oxw

    r8438 r8636  
    1919    <Template link="lodtemplate_default" />
    2020  </templates>
     21  <?lua include("includes/notifications.oxi") ?>
    2122
    2223  <Scene
  • code/branches/tutoriallevel3/data/levels/emptyLevel.oxw

    r7679 r8636  
    2323    <Template link=lodtemplate_default />
    2424  </templates>
     25  <?lua include("includes/notifications.oxi") ?>
    2526
    2627  <Scene
  • code/branches/tutoriallevel3/data/levels/events.oxw

    r7679 r8636  
    2020    <Template link=lodtemplate_default />
    2121  </templates>
     22  <?lua include("includes/notifications.oxi") ?>
    2223
    2324  <Scene
  • code/branches/tutoriallevel3/data/levels/fightInOurBack.oxw

    r8213 r8636  
    6868    <Template link=lodtemplate_default />
    6969  </templates>
     70  <?lua include("includes/notifications.oxi") ?>
    7071
    7172    <!-- Ausgang: Szene ===> ambientlight/skybox -->
  • code/branches/tutoriallevel3/data/levels/lastManStanding.oxw

    r8178 r8636  
    2323    <Template link=lodtemplate_default />
    2424  </templates>
     25  <?lua include("includes/notifications.oxi") ?>
    2526
    2627  <Scene
  • code/branches/tutoriallevel3/data/levels/lastTeamStanding.oxw

    r8179 r8636  
    2727    skybox       = "Orxonox/skypanoramagen1"
    2828  >
     29  <?lua include("includes/notifications.oxi") ?>
    2930
    3031    <?lua
  • code/branches/tutoriallevel3/data/levels/lastTeamStandingII.oxw

    r8351 r8636  
    2222    <Template link=lodtemplate_default />
    2323  </templates>
     24  <?lua include("includes/notifications.oxi") ?>
    2425
    2526  <Scene
  • code/branches/tutoriallevel3/data/levels/notifications.oxw

    r7679 r8636  
    1919        <Template link=lodtemplate_default />
    2020    </templates>
     21    <?lua include("includes/notifications.oxi") ?>
    2122
    2223    <Scene
     
    2425        skybox       = "Orxonox/skypanoramagen1"
    2526    >
    26 
    27     <Script code="showGUI NotificationLayer false true" needsGraphics="true" />
    2827
    2928    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
  • code/branches/tutoriallevel3/data/levels/pickups.oxw

    r7679 r8636  
    2323    <Template link=lodtemplate_default />
    2424  </templates>
     25  <?lua include("includes/notifications.oxi") ?>
    2526
    2627  <Scene
  • code/branches/tutoriallevel3/data/levels/pirateAttack.oxw

    r8213 r8636  
    3535    <Template link=lodtemplate_default />
    3636  </templates>
     37  <?lua include("includes/notifications.oxi") ?>
    3738
    3839    <Scene
  • code/branches/tutoriallevel3/data/levels/planets.oxw

    r8438 r8636  
    1919    <Template link="lodtemplate_default" />
    2020  </templates>
     21  <?lua include("includes/notifications.oxi") ?>
    2122
    2223  <Scene
  • code/branches/tutoriallevel3/data/levels/pong.oxw

    r7865 r8636  
    5656    <Template link=lodtemplate_default />
    5757  </templates>
     58  <?lua include("includes/notifications.oxi") ?>
    5859
    5960  <WorldAmbientSound source="mainmenu.ogg" playOnLoad=true />
  • code/branches/tutoriallevel3/data/levels/presentation.oxw

    r7679 r8636  
    1919    <Template link=lodtemplate_default />
    2020  </templates>
     21  <?lua include("includes/notifications.oxi") ?>
    2122
    2223  <Scene
  • code/branches/tutoriallevel3/data/levels/presentation09.oxw

    r8079 r8636  
    2121    <Template link=lodtemplate_default />
    2222  </templates>
     23  <?lua include("includes/notifications.oxi") ?>
    2324
    2425  <Scene
  • code/branches/tutoriallevel3/data/levels/presentation09b.oxw

    r8079 r8636  
    2323    <Template link=lodtemplate_default />
    2424  </templates>
     25  <?lua include("includes/notifications.oxi") ?>
    2526
    2627  <Scene
  • code/branches/tutoriallevel3/data/levels/presentationDM.oxw

    r8079 r8636  
    2020    <Template link=lodtemplate_default />
    2121  </templates>
     22  <?lua include("includes/notifications.oxi") ?>
    2223
    2324  <Scene
  • code/branches/tutoriallevel3/data/levels/presentationFS10.oxw

    r7679 r8636  
    2626    <Template link=lodtemplate_default />
    2727  </templates>
     28  <?lua include("includes/notifications.oxi") ?>
    2829
    2930  <Scene
  • code/branches/tutoriallevel3/data/levels/presentationFS102.oxw

    r8079 r8636  
    2121    <Template link=lodtemplate_default />
    2222  </templates>
     23  <?lua include("includes/notifications.oxi") ?>
    2324
    2425  <Scene
  • code/branches/tutoriallevel3/data/levels/presentationFS10Ed.oxw

    r8079 r8636  
    2121    <Template link=lodtemplate_default />
    2222  </templates>
     23  <?lua include("includes/notifications.oxi") ?>
    2324
    2425  <Scene
  • code/branches/tutoriallevel3/data/levels/presentationHS09.oxw

    r8079 r8636  
    2424    <Template link=lodtemplate_default />
    2525  </templates>
     26  <?lua include("includes/notifications.oxi") ?>
    2627
    2728  <Scene
  • code/branches/tutoriallevel3/data/levels/presentationHS09b.oxw

    r8079 r8636  
    2929    <Template link=lodtemplate_default />
    3030  </templates>
     31  <?lua include("includes/notifications.oxi") ?>
    3132
    3233  <Scene
  • code/branches/tutoriallevel3/data/levels/princessAeryn.oxw

    r7679 r8636  
    2424    <Template link=lodtemplate_default />
    2525  </templates>
     26  <?lua include("includes/notifications.oxi") ?>
    2627
    2728  <Scene
  • code/branches/tutoriallevel3/data/levels/quests.oxw

    r8453 r8636  
    1919        <Template link=lodtemplate_default />
    2020    </templates>
     21    <?lua include("includes/notifications.oxi") ?>
    2122
    2223    <Scene
  • code/branches/tutoriallevel3/data/levels/screenshot.oxw

    r7679 r8636  
    2222    <Template link=lodtemplate_default />
    2323  </templates>
     24  <?lua include("includes/notifications.oxi") ?>
    2425
    2526  <Scene
  • code/branches/tutoriallevel3/data/levels/sound.oxw

    r7854 r8636  
    2323    <Template link=lodtemplate_default />
    2424  </templates>
     25  <?lua include("includes/notifications.oxi") ?>
    2526
    2627  <Scene
  • code/branches/tutoriallevel3/data/levels/teamBaseMatch.oxw

    r8079 r8636  
    2323    <Template link=lodtemplate_default />
    2424  </templates>
     25  <?lua include("includes/notifications.oxi") ?>
    2526
    2627  <Scene
  • code/branches/tutoriallevel3/data/levels/teamDeathMatch.oxw

    r7679 r8636  
    2222    <Template link=lodtemplate_default />
    2323  </templates>
     24  <?lua include("includes/notifications.oxi") ?>
    2425
    2526  <Scene
  • code/branches/tutoriallevel3/data/levels/testStars.oxw

    r7679 r8636  
    2323    <Template link=lodtemplate_default />
    2424  </templates>
     25  <?lua include("includes/notifications.oxi") ?>
    2526
    2627  <Scene
  • code/branches/tutoriallevel3/data/levels/testSwallow.oxw

    r8079 r8636  
    2222    <Template link=lodtemplate_default />
    2323  </templates>
     24  <?lua include("includes/notifications.oxi") ?>
    2425
    2526  <Scene
  • code/branches/tutoriallevel3/data/levels/theTimeMachine.oxw

    r8213 r8636  
    6868        <Template link=lodtemplate_default />
    6969    </templates>
     70    <?lua include("includes/notifications.oxi") ?>
     71   
    7072    <Scene
    7173        ambientlight="0.8,0.8,0.8"
  • code/branches/tutoriallevel3/data/levels/tutorial.oxw

    r7679 r8636  
    1919    <Template link=lodtemplate_default />
    2020  </templates>
     21  <?lua include("includes/notifications.oxi") ?>
    2122
    2223  <Scene
  • code/branches/tutoriallevel3/data/levels/underAttack.oxw

    r8079 r8636  
    1515    <Template link=lodtemplate_default />
    1616  </templates>
     17  <?lua include("includes/notifications.oxi") ?>
    1718
    1819  <Scene
  • code/branches/tutoriallevel3/data/levels/waypoints.oxw

    r7679 r8636  
    2121    <Template link=lodtemplate_default />
    2222  </templates>
     23  <?lua include("includes/notifications.oxi") ?>
    2324
    2425  <Scene
  • code/branches/tutoriallevel3/src/modules/notifications/NotificationManager.cc

    r8453 r8636  
    411411    void NotificationManager::loadQueues(void)
    412412    {
    413         NotificationQueueCEGUI* allQueue = new NotificationQueueCEGUI("all");
     413        /*NotificationQueueCEGUI* allQueue = new NotificationQueueCEGUI("all");
    414414        allQueue->setDisplaySize(Vector2(0.5, 0));
    415415        allQueue->setPosition(Vector4(0.0, 10, 0.3, 0));
     
    420420        infoQueue->setFontColor(Vector4(1.0, 1.0, 0.0, 0.8));
    421421        infoQueue->setAlignment("HorzCentred");
    422         infoQueue->setDisplaySize(Vector2(0.6, 0.0));
     422        infoQueue->setDisplaySize(Vector2(0.6, 0.0));*/
    423423    }
    424424
  • code/branches/tutoriallevel3/src/modules/notifications/NotificationQueue.cc

    r8453 r8636  
    3838
    3939#include "core/CoreIncludes.h"
     40#include "core/XMLPort.h"
    4041#include "util/SubString.h"
    4142
     
    4344{
    4445
    45     /**
    46     @brief
    47         Constructor. Creates and initializes the object.
     46    CreateFactory(NotificationQueue);
     47   
     48    /**
     49    @brief
     50        Default constructor. Registers and initializes the object.
     51    @param creator
     52        The creator of the NotificationQueue.
     53    */
     54    NotificationQueue::NotificationQueue(BaseObject* creator) : BaseObject(creator), registered_(false)
     55    {
     56        RegisterObject(NotificationQueue);
     57
     58        this->initialize();
     59    }
     60
     61    // TODO move to docu.
     62    /**
     63    @brief
     64        Constructor. Registers and initializes the object.
     65    @param creator
     66        The creator of the NotificationQueue
    4867    @param name
    4968        The name of the new NotificationQueue. It needs to be unique
    5069    @param senders
    5170        The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays.
    52         The senders need to be separated by commas.
     71        The senders need to be seperated by commas.
    5372    @param size
    5473        The size (the maximum number of displayed Notifications) of this NotificationQueue.
     
    5675        The time during which a Notification is (at most) displayed.
    5776    */
    58     NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime)
    59     {
    60         this->registered_ = false;
    61 
    62         RegisterRootObject(NotificationQueue);
    63 
    64         // Initialize.
     77
     78    /**
     79    @brief
     80        Destructor.
     81    */
     82    NotificationQueue::~NotificationQueue()
     83    {
     84        this->targets_.clear();
     85
     86        if(this->isRegistered()) // If the NotificationQueue is registered.
     87        {
     88            this->clear(true);
     89
     90            // Unregister with the NotificationManager.
     91            NotificationManager::getInstance().unregisterQueue(this);
     92        }
     93    }
     94
     95    /**
     96    @brief
     97        Initializes the NotificationQueue.
     98    */
     99    void NotificationQueue::initialize(void)
     100    {
    65101        this->size_ = 0;
    66102        this->tickTime_ = 0.0f;
    67 
    68         // Sets the input values.
    69         this->setTargets(senders);
    70         this->name_ = name;
    71         this->maxSize_ = size;
    72         this->setDisplayTime(displayTime);
    73 
     103        this->maxSize_ = NotificationQueue::DEFAULT_SIZE;
     104        this->displayTime_ = NotificationQueue::DEFAULT_DISPLAY_TIME;
     105
     106        this->creationTime_ = std::time(0);
     107    }
     108
     109    /**
     110    @brief
     111        Creates the NotificationQueue.
     112    */
     113    void NotificationQueue::create(void)
     114    {
    74115        // Register the NotificationQueue with the NotificationManager.
    75116        bool queueRegistered = NotificationManager::getInstance().registerQueue(this);
     
    87128    /**
    88129    @brief
    89         Destructor.
    90     */
    91     NotificationQueue::~NotificationQueue()
    92     {
    93         this->targets_.clear();
    94 
    95         if(this->registered_) // If the NotificationQueue is registered.
    96         {
    97             this->clear(true);
    98 
    99             // Unregister with the NotificationManager.
    100             NotificationManager::getInstance().unregisterQueue(this);
    101         }
    102        
    103         COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl;
    104     }
    105 
    106     /**
    107     @brief
    108130        Updates the queue from time to time.
    109131    @param dt
     
    115137        if(this->displayTime_ != INF && this->tickTime_ >= 1.0) // If the time counter is greater than 1s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
    116138        {
    117             this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containig the current time.
     139            this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containing the current time.
    118140
    119141            std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = this->ordering_.begin();
     
    129151    }
    130152
     153    void NotificationQueue::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     154    {
     155        SUPER(NotificationQueue, XMLPort, xmlelement, mode);
     156
     157        XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlelement, mode).defaultValues(NotificationListener::ALL);
     158        XMLPortParam(NotificationQueue, "size", setMaxSize, getMaxSize, xmlelement, mode);
     159        XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlelement, mode);
     160
     161        this->create();
     162    }
     163
    131164    /**
    132165    @brief
     
    148181        if(!notifications->empty())
    149182        {
    150             // Add all Notifications.
     183            // Add all Notifications that have been created after this NotificationQueue was created.
    151184            for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++)
    152                 this->push(it->second, it->first);
     185            {
     186                if(it->first >= this->creationTime_)
     187                    this->push(it->second, it->first);
     188            }
    153189        }
    154190
     
    305341            return;
    306342
     343        if(size == 0)
     344        {
     345            COUT(2) << "Trying to set maximal size of NotificationQueue '" << this->getName() << "' to 0. Ignoring..." << endl;
     346            return;
     347        }
     348       
    307349        this->maxSize_ = size;
    308350
    309         if(this->registered_)
     351        if(this->isRegistered())
    310352            this->update();
    311353    }
     
    322364            return;
    323365
     366        if(time != NotificationQueue::INF && time <= 0)
     367        {
     368            COUT(2) << "Trying to set display time of NotificationQueue '" << this->getName() << "' to non-positive value. Ignoring..." << endl;
     369        }
     370           
    324371        this->displayTime_ = time;
    325372
    326         if(this->registered_)
     373        if(this->isRegistered())
    327374            this->update();
    328375    }
     
    367414
    368415        // TODO: Why?
    369         if(this->registered_)
     416        if(this->isRegistered())
    370417        {
    371418            NotificationManager::getInstance().unregisterQueue(this);
  • code/branches/tutoriallevel3/src/modules/notifications/NotificationQueue.h

    r8453 r8636  
    4545#include "NotificationManager.h"
    4646
     47#include "core/BaseObject.h"
    4748#include "tools/interfaces/Tickable.h"
    4849
     
    8889    @ingroup Notifications
    8990    */
    90     class _NotificationsExport NotificationQueue : public Tickable
     91    class _NotificationsExport NotificationQueue : public BaseObject, public Tickable
    9192    {
    9293
    9394        public:
    94             NotificationQueue(const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
     95            NotificationQueue(BaseObject* creator);
     96            NotificationQueue(BaseObject* creator, const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
    9597            virtual ~NotificationQueue();
    9698
    97             virtual void tick(float dt); //!< To update from time to time.
    98 
    99             void update(void); //!< Updates the NotificationQueue.
    100             void update(Notification* notification, const std::time_t & time); //!< Updates the NotificationQueue by adding an new Notification.
     99            virtual void tick(float dt); // To update from time to time.
     100            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     101
     102            void update(void); // Updates the NotificationQueue.
     103            void update(Notification* notification, const std::time_t & time); // Updates the NotificationQueue by adding an new Notification.
    101104
    102105            // tolua_begin
     
    105108            @return Returns the name.
    106109            */
    107             inline const std::string& getName() const
    108                 { return this->name_; }
    109 
    110             void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
     110            inline const std::string& getName(void) const
     111                { return this->BaseObject::getName(); }
     112
     113            void setMaxSize(unsigned int size); // Sets the maximum number of displayed Notifications.
    111114            /**
    112115            @brief Returns the maximum number of Notifications displayed.
    113116            @return Returns maximum size.
    114117            */
    115             inline unsigned int getMaxSize() const
     118            inline unsigned int getMaxSize(void) const
    116119                { return this->maxSize_; }
    117120
    118             void setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
     121            void setDisplayTime(int time); // Sets the maximum number of seconds a Notification is displayed.
    119122            /**
    120123            @brief Returns the time interval the Notification is displayed.
    121124            @return Returns the display time.
    122125            */
    123             inline int getDisplayTime() const
     126            inline int getDisplayTime(void) const
    124127                { return this->displayTime_; }
    125128            // tolua_end
     
    129132            @return Returns the size of the NotificationQueue.
    130133            */
    131             inline unsigned int getSize() const
     134            inline unsigned int getSize(void) const
    132135                { return this->size_; }
    133136
     
    136139            @return Returns a set of strings holding the different targets.
    137140            */
    138             inline const std::set<std::string> & getTargetsSet()
     141            inline const std::set<std::string> & getTargetsSet(void)
    139142                { return this->targets_; }
    140143
    141             void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
    142             const std::string& getTargets(void) const; //!< Returns a string consisting of the concatenation of the targets.
     144            void setTargets(const std::string & targets); // Set the targets of this NotificationQueue.
     145            const std::string& getTargets(void) const; // Returns a string consisting of the concatenation of the targets.
     146
     147            /**
     148            @brief Check whether the NotificationQueue is registered with the NotificationManager.
     149            @return Returns true if it is registered, false if not.
     150            */
     151            inline bool isRegistered(void)
     152                { return this->registered_; }
    143153
    144154            bool tidy(void); // Pops all Notifications from the NotificationQueue.
     
    160170            virtual void notificationRemoved(unsigned int index) {}
    161171           
    162             virtual void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
     172            virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
    163173
    164174        protected:
     
    167177            static const int INF = -1; //!< Constant denoting infinity.
    168178
     179            virtual void create(void); // Creates the NotificationQueue.
     180
    169181        private:
    170             std::string name_; //!< The name of the NotificationQueue.
    171 
     182            void initialize(void); // Initializes the NotificationQueue.
     183
     184            time_t creationTime_; // The time this NotificationQueue was created.
     185           
    172186            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
    173187            unsigned int size_; //!< The number of Notifications displayed.
     
    186200            void setName(const std::string& name); //!< Sets the name of the NotificationQueue.
    187201
    188             void push(Notification* notification, const std::time_t & time); //!< Adds (pushes) a Notification to the NotificationQueue.
    189             void pop(void); //!< Removes (pops) the least recently added Notification form the NotificationQueue.
    190             void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer.
     202            void push(Notification* notification, const std::time_t & time); // Adds (pushes) a Notification to the NotificationQueue.
     203            void pop(void); // Removes (pops) the least recently added Notification form the NotificationQueue.
     204            void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); // Removes the Notification that is stored in the input NotificationContainer.
    191205
    192206    };
  • code/branches/tutoriallevel3/src/modules/notifications/NotificationQueueCEGUI.cc

    r8453 r8636  
    4747{
    4848
     49    CreateFactory(NotificationQueueCEGUI);
     50
    4951    // Register tolua_open function when loading the library.
    5052    DeclareToluaInterface(Notifications);
     
    5254    /*static*/ const std::string NotificationQueueCEGUI::NOTIFICATION_LAYER("NotificationLayer");
    5355
    54     NotificationQueueCEGUI::NotificationQueueCEGUI(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime) : NotificationQueue(name, senders, size, displayTime)
     56    NotificationQueueCEGUI::NotificationQueueCEGUI(BaseObject* creator) : NotificationQueue(creator)
    5557    {
    5658        RegisterObject(NotificationQueueCEGUI);
    5759
     60        this->initialize();
     61    }
     62   
     63    NotificationQueueCEGUI::~NotificationQueueCEGUI()
     64    {
     65        if(GameMode::showsGraphics())
     66            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".removeQueue(\"" + this->getName() +  "\")");
     67    }
     68
     69    /**
     70    @brief
     71        Initializes The NotificationQueueCEGUI.
     72    */
     73    void NotificationQueueCEGUI::initialize(void)
     74    {
    5875        this->displaySize_ = Vector4(1.0, 0.0, 0.0, 0.0);
    5976        this->position_ = Vector4(0.0, 0.0, 0.0, 0.0);
     
    6279        this->fontColor_ = Vector4(1.0, 1.0, 1.0, 1.0);
    6380        this->fontColorStr_ = "FFFFFFFF";
    64        
    65         // Create the NotificationQueueCEGUI in lua.
    66         this->create();
    67     }
    68    
    69     NotificationQueueCEGUI::~NotificationQueueCEGUI()
    70     {
    71        
     81    }
     82
     83    void NotificationQueueCEGUI::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     84    {
     85        SUPER(NotificationQueueCEGUI, XMLPort, xmlelement, mode);
     86
     87        XMLPortParam(NotificationQueueCEGUI, "position", setPosition, getPosition, xmlelement, mode);
     88        XMLPortParam(NotificationQueueCEGUI, "fontSize", setFontSize, getFontSize, xmlelement, mode);
     89        XMLPortParam(NotificationQueueCEGUI, "fontColor", setFontColor, getFontColor, xmlelement, mode);
     90        XMLPortParam(NotificationQueueCEGUI, "alignment", setAlignment, getAlignment, xmlelement, mode);
     91        XMLPortParam(NotificationQueueCEGUI, "displaySize", setDisplaySize, getDisplaySize, xmlelement, mode);
    7292    }
    7393
     
    266286    void NotificationQueueCEGUI::create(void)
    267287    {
    268         if(GameMode::showsGraphics())
     288        this->NotificationQueue::create();
     289       
     290        if(this->isRegistered() && GameMode::showsGraphics())
    269291            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".createQueue(\"" + this->getName() +  "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
    270292    }
  • code/branches/tutoriallevel3/src/modules/notifications/NotificationQueueCEGUI.h

    r8453 r8636  
    7070
    7171        public:
    72             NotificationQueueCEGUI(const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
     72            NotificationQueueCEGUI(BaseObject* creator);
    7373            virtual ~NotificationQueueCEGUI();
     74
     75            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    7476
    7577            void destroy(bool noGraphics = false); // Destroys the NotificationQueue.
    7678
    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)); }
    8379            void setDisplaySize(const Vector4& size); // Set the size of the window that displays the NotificationQueue.
     80           
    8481            /**
    8582            @brief Get the size of the window that displays the NotificationQueue.
     
    130127           
    131128        protected:
     129            virtual void create(void); // Creates the NotificationQueue in lua.
     130           
    132131            virtual void notificationPushed(Notification* notification); // Is called by the NotificationQueue when a notification was pushed
    133132            virtual void notificationPopped(void); // Is called by the NotificationQueue when a notification was popped.
     
    146145            Vector4 fontColor_; //!< The font color of the Notifications text as a vector, in RGBA form, with values from 0 to 1.
    147146            std::string fontColorStr_; //!< The font color of the Notifications text as a string with the ARGB hexadecimal values.
    148            
    149             void create(void); // Creates the NotificationQueue in lua.
     147
     148            void initialize(void); // Initializes The NotificationQueueCEGUI.
    150149
    151150    }; // tolua_export
Note: See TracChangeset for help on using the changeset viewer.