Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 29, 2011, 5:24:04 PM (13 years ago)
Author:
dafrick
Message:

Anotehr step towards networked notifications.

Location:
code/branches/presentation/src/modules/notifications
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/modules/notifications/NotificationQueue.cc

    r8656 r8662  
    5656        RegisterObject(NotificationQueue);
    5757
    58         this->initialize();
     58        this->size_ = 0;
     59        this->tickTime_ = 0.0f;
     60        this->maxSize_ = NotificationQueue::DEFAULT_SIZE;
     61        this->displayTime_ = NotificationQueue::DEFAULT_DISPLAY_TIME;
     62
     63        this->creationTime_ = std::time(0);
     64       
    5965        this->registerVariables();
    6066    }
     
    96102    /**
    97103    @brief
    98         Initializes the NotificationQueue.
    99     */
    100     void NotificationQueue::initialize(void)
    101     {
    102         this->size_ = 0;
    103         this->tickTime_ = 0.0f;
    104         this->maxSize_ = NotificationQueue::DEFAULT_SIZE;
    105         this->displayTime_ = NotificationQueue::DEFAULT_DISPLAY_TIME;
    106 
    107         this->creationTime_ = std::time(0);
     104        Is called when the name of the NotificationQueue has changed.
     105        Clears and re-creates the NotificationQueue.
     106    */
     107    void NotificationQueue::changedName(void)
     108    {
     109        SUPER(NotificationQueue, changedName);
     110
     111        if(this->isRegistered())
     112            this->clear();
     113           
     114        this->create();
     115
     116        this->targetsChanged();
     117        this->maxSizeChanged();
     118        this->displayTimeChanged();
    108119    }
    109120
     
    159170        XMLPortParam(NotificationQueue, "size", setMaxSize, getMaxSize, xmlelement, mode);
    160171        XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlelement, mode);
    161 
    162         this->create();
    163172    }
    164173   
  • code/branches/presentation/src/modules/notifications/NotificationQueue.h

    r8656 r8662  
    9999            virtual void tick(float dt); // To update from time to time.
    100100            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    101             void registerVariables();
     101
     102            virtual void changedName(void);
    102103           
    103104            void update(void); // Updates the NotificationQueue.
     
    159160           
    160161        protected:
     162            void registerVariables();
     163           
    161164            /**
    162165            @brief Is called when a notification was pushed.
     
    184187
    185188        private:
    186             void initialize(void); // Initializes the NotificationQueue.
    187 
    188             time_t creationTime_; // The time this NotificationQueue was created.
     189            time_t creationTime_; //!< The time this NotificationQueue was created.
    189190           
    190191            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
  • code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.cc

    r8659 r8662  
    6565    NotificationQueueCEGUI::~NotificationQueueCEGUI()
    6666    {
    67         if(GameMode::showsGraphics())
     67        if(this->isRegistered() && GameMode::showsGraphics())
    6868            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".removeQueue(\"" + this->getName() +  "\")");
    6969    }
     
    103103    }
    104104
     105    void NotificationQueueCEGUI::changedName(void)
     106    {
     107        SUPER(NotificationQueueCEGUI, changedName);
     108
     109        this->positionChanged();
     110        this->fontSizeChanged();
     111        this->fontColorChanged();
     112        this->alignmentChanged();
     113        this->displaySizeChanged();
     114    }
     115
    105116    /**
    106117    @brief
     
    113124    {
    114125        // Remove the NotificationQueue in lua.
    115         if(GameMode::showsGraphics() && !noGraphics)
     126        if(this->isRegistered() && GameMode::showsGraphics() && !noGraphics)
    116127            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".removeQueue(\"" + this->getName() +  "\")");
    117128
     
    151162    void NotificationQueueCEGUI::displaySizeChanged(void)
    152163    {
    153         if(GameMode::showsGraphics())
     164        if(this->isRegistered() && GameMode::showsGraphics())
    154165        {
    155166            if(this->displaySize_.z == 0.0 && this->displaySize_.w == 0.0)
     
    191202    void NotificationQueueCEGUI::positionChanged(void)
    192203    {
    193         if(GameMode::showsGraphics())
     204        if(this->isRegistered() && GameMode::showsGraphics())
    194205            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".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) + ")");
    195206    }
     
    218229    void NotificationQueueCEGUI::alignmentChanged(void)
    219230    {
    220         if(GameMode::showsGraphics())
     231        if(this->isRegistered() && GameMode::showsGraphics())
    221232            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueAlignment(\"" + this->getName() + "\", \"" + this->alignment_ + "\")");
    222233    }
     
    243254    void NotificationQueueCEGUI::fontSizeChanged(void)
    244255    {
    245         if(GameMode::showsGraphics())
     256        if(this->isRegistered() && GameMode::showsGraphics())
    246257            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueFontSize(\"" + this->getName() + "\", " + multi_cast<std::string>(this->fontSize_) + ")");
    247258    }
     
    274285        this->fontColorStr_ = stream.str();
    275286
    276         if(GameMode::showsGraphics())
     287        if(this->isRegistered() && GameMode::showsGraphics())
    277288            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueFontColor(\"" + this->getName() + "\", \"" + this->fontColorStr_ + "\")");
    278289    }
     
    303314    {
    304315         // Push the Notification to the GUI.
    305         if(GameMode::showsGraphics())
     316        if(this->isRegistered() && GameMode::showsGraphics())
    306317            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
    307318    }
     
    314325    {
    315326        // Pops the Notification from the GUI.
    316         if(GameMode::showsGraphics())
     327        if(this->isRegistered() && GameMode::showsGraphics())
    317328            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".popNotification(\"" + this->getName() + "\")");
    318329    }
     
    325336    {
    326337        // Removes the Notification from the GUI.
    327         if(GameMode::showsGraphics())
     338        if(this->isRegistered() && GameMode::showsGraphics())
    328339            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
    329340    }
     
    340351
    341352        // Clear the NotificationQueue in the GUI.
    342         if(GameMode::showsGraphics() && !noGraphics)
     353        if(this->isRegistered() && GameMode::showsGraphics() && !noGraphics)
    343354            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".clearQueue(\"" + this->getName() + "\")");
    344355    }
     
    350361    void NotificationQueueCEGUI::create(void)
    351362    {
     363        if(this->isRegistered() && GameMode::showsGraphics())
     364            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".removeQueue(\"" + this->getName() +  "\")");
     365       
    352366        this->NotificationQueue::create();
    353367       
  • code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.h

    r8656 r8662  
    7474
    7575            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    76             void registerVariables();
     76
     77            virtual void changedName(void);
    7778
    7879            void destroy(bool noGraphics = false); // Destroys the NotificationQueue.
     
    133134           
    134135        protected:
     136            void registerVariables();
     137           
    135138            virtual void create(void); // Creates the NotificationQueue in lua.
    136139           
Note: See TracChangeset for help on using the changeset viewer.