Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 29, 2011, 11:24:31 AM (14 years ago)
Author:
dafrick
Message:

Adding network callbacks. Still doesn't work yet, though.

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

Legend:

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

    r8651 r8656  
    136136    {
    137137        this->tickTime_ += dt; // Add the time interval that has passed to the time counter.
    138         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.
     138        if(this->displayTime_ != INF && this->tickTime_ >= 1.0) // If the time counter is greater than 1 s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
    139139        {
    140140            this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containing the current time.
     
    171171    void NotificationQueue::registerVariables()
    172172    {
    173         registerVariable( this->maxSize_, VariableDirection::ToClient );
    174         registerVariable( this->targets_, VariableDirection::ToClient );
    175         registerVariable( this->displayTime_, VariableDirection::ToClient );
     173        registerVariable( this->maxSize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::maxSizeChanged));
     174        registerVariable( this->targets_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::targetsChanged));
     175        registerVariable( this->displayTime_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::displayTimeChanged));
    176176    }
    177177
     
    229229    @brief
    230230        Adds (pushes) a Notification to the NotificationQueue.
    231         It inserts it into the storage containers, creates a corresponding container and pushes the Notification message to the GUI.
     231        It inserts it into the storage containers, creates a corresponding container and pushes the notification message to the GUI.
    232232    @param notification
    233233        The Notification to be pushed.
     
    363363       
    364364        this->maxSize_ = size;
    365 
     365        this->maxSizeChanged();
     366    }
     367
     368    /**
     369    @brief
     370        Is called when the maximum number of displayed Notifications has changed.
     371    */
     372    void NotificationQueue::maxSizeChanged(void)
     373    {
    366374        if(this->isRegistered())
    367375            this->update();
     
    385393           
    386394        this->displayTime_ = time;
    387 
     395        this->displayTimeChanged();
     396    }
     397
     398    /**
     399    @brief
     400        Is called when the maximum number of seconds a Notification is displayed has changed.
     401    */
     402    void NotificationQueue::displayTimeChanged(void)
     403    {
    388404        if(this->isRegistered())
    389405            this->update();
     
    428444            this->targets_.insert(string[i]);
    429445
     446        this->targetsChanged();
     447    }
     448
     449    /**
     450    @brief
     451        Is called when the NotificationQueue's targets have changed.
     452    */
     453    void NotificationQueue::targetsChanged(void)
     454    {
    430455        // TODO: Why?
    431456        if(this->isRegistered())
  • code/branches/presentation/src/modules/notifications/NotificationQueue.h

    r8651 r8656  
    9595        public:
    9696            NotificationQueue(BaseObject* creator);
    97             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);
    9897            virtual ~NotificationQueue();
    9998
     
    129128                { return this->displayTime_; }
    130129            // tolua_end
     130            void maxSizeChanged(void); // Is called when the maximum number of displayed Notifications has changed.
     131            void displayTimeChanged(void);
    131132
    132133            /**
     
    146147            void setTargets(const std::string & targets); // Set the targets of this NotificationQueue.
    147148            const std::string& getTargets(void) const; // Returns a string consisting of the concatenation of the targets.
     149            void targetsChanged(void); // Is called when the NotificationQueue's targets have changed.
    148150
    149151            /**
  • code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.cc

    r8651 r8656  
    9595    void NotificationQueueCEGUI::registerVariables()
    9696    {
    97         registerVariable( this->position_, VariableDirection::ToClient );
    98         registerVariable( this->fontSize_, VariableDirection::ToClient );
    99         registerVariable( this->fontColor_, VariableDirection::ToClient );
    100         registerVariable( this->alignment_, VariableDirection::ToClient );
    101         registerVariable( this->displaySize_, VariableDirection::ToClient );
     97        registerVariable( this->position_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::positionChanged));
     98        registerVariable( this->fontSize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::fontSizeChanged));
     99        registerVariable( this->fontColor_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::fontColorChanged));
     100        registerVariable( this->alignment_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::alignmentChanged));
     101        registerVariable( this->displaySize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueueCEGUI>(this, &NotificationQueueCEGUI::displaySizeChanged));
    102102    }
    103103
     
    141141
    142142        this->displaySize_ = size;
     143        this->displaySizeChanged();
     144    }
     145
     146    /**
     147    @brief
     148        Is called when the display size has changed.
     149    */
     150    void NotificationQueueCEGUI::displaySizeChanged(void)
     151    {
    143152        if(GameMode::showsGraphics())
    144153        {
    145             if(size.z == 0.0 && size.w == 0.0)
     154            if(this->displaySize_.z == 0.0 && this->displaySize_.w == 0.0)
    146155                GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".resizeQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->displaySize_.x) + ", " + multi_cast<std::string>(this->displaySize_.y) + ")");
    147156            else
     
    172181
    173182        this->position_ = position;
     183        this->positionChanged();
     184    }
     185
     186    /**
     187    @brief
     188        Is called when the NotificationQueue's position has changed.
     189    */
     190    void NotificationQueueCEGUI::positionChanged(void)
     191    {
    174192        if(GameMode::showsGraphics())
    175193            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) + ")");
     
    190208        // TODO: Check whether the alignment string is correct?
    191209        this->alignment_ = alignment;
     210        this->alignmentChanged();
     211    }
     212
     213    /**
     214    @brief
     215        Is called when the horizontal alignment of the Notifications text has changed.
     216    */
     217    void NotificationQueueCEGUI::alignmentChanged(void)
     218    {
    192219        if(GameMode::showsGraphics())
    193220            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueAlignment(\"" + this->getName() + "\", \"" + this->alignment_ + "\")");
     
    206233
    207234        this->fontSize_ = size;
     235        this->fontSizeChanged();
     236    }
     237
     238    /**
     239    @brief
     240        Is called when the font size of the text displayed by this NotificationQueue has changed.
     241    */
     242    void NotificationQueueCEGUI::fontSizeChanged(void)
     243    {
    208244        if(GameMode::showsGraphics())
    209245            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueFontSize(\"" + this->getName() + "\", " + multi_cast<std::string>(this->fontSize_) + ")");
     
    222258
    223259        this->fontColor_ = color;
     260        this->fontColorChanged();
     261    }
     262
     263    /**
     264    @brief
     265        Is called when the font color if the text displayed by this NotificationQueue.
     266    */
     267    void NotificationQueueCEGUI::fontColorChanged(void)
     268    {
    224269        // Convert to ARGB format.
    225270        std::stringstream stream;
     
    227272            stream << std::hex << std::setw(2) << std::setfill('0') << int(this->fontColor_[(i+3)%4]*255);
    228273        this->fontColorStr_ = stream.str();
     274
    229275        if(GameMode::showsGraphics())
    230276            GUIManager::getInstance().getLuaState()->doString(NotificationQueueCEGUI::NOTIFICATION_LAYER + ".changeQueueFontColor(\"" + this->getName() + "\", \"" + this->fontColorStr_ + "\")");
     
    249295    /**
    250296    @brief
    251         Is called by the NotificationQueue when a notification was pushed.
     297        Is called by the NotificationQueue when a Notification was pushed.
    252298    @param notification
    253299        The Notification that was pushed.
     
    262308    /**
    263309    @brief
    264         Is called by the NotificationQueue when a notification was popped.
     310        Is called by the NotificationQueue when a Notification was popped.
    265311    */
    266312    void NotificationQueueCEGUI::notificationPopped(void)
     
    273319    /**
    274320    @brief Is called when a notification was removed.
    275     @param index The index the removed notification was at.
     321    @param index The index the removed Notification was at.
    276322    */
    277323    void NotificationQueueCEGUI::notificationRemoved(unsigned int index)
  • code/branches/presentation/src/modules/notifications/NotificationQueueCEGUI.h

    r8651 r8656  
    8686            inline const Vector4& getDisplaySize(void) const
    8787                { return this->displaySize_; }
     88            void displaySizeChanged(void); // Is called when the display size has changed.
    8889
    8990            void setPosition(const Vector4& position); // Set the position of the window that displays the NotificationQueue.
     
    9495            inline const Vector4& getPosition(void) const
    9596                { return this->position_; }
     97            void positionChanged(void); // Is called when the NotificationQueue's position has changed.
    9698
    9799            void setAlignment(const std::string& alignment); // Set the horizontal alignment of the Notifications text.
     
    102104            inline const std::string& getAlignment(void)
    103105                { return this->alignment_; }
     106            void alignmentChanged(void); // Is called when the horizontal alignment of the Notifications text has changed.
    104107
    105108            void setFontSize(unsigned int size); // Set the font size of the text displayed by this NotificationQueue.
     
    110113            inline unsigned int getFontSize(void)
    111114                { return this->fontSize_; }
     115            void fontSizeChanged(void); // Is called when the font size of the text displayed by this NotificationQueue has changed.
    112116
    113117            void setFontColor(const Vector4& color); // Set the font color if the text displayed by this NotificationQueue.
     
    124128            inline const std::string& getFontColorStr(void) const
    125129                { return this->fontColorStr_; }
     130            void fontColorChanged(void); // Is called when the font color if the text displayed by this NotificationQueue has changed.
    126131
    127132            static NotificationQueueCEGUI* getQueue(const std::string& name); // tolua_export // Get the NotificationQueueCEGUI with the input name.
     
    130135            virtual void create(void); // Creates the NotificationQueue in lua.
    131136           
    132             virtual void notificationPushed(Notification* notification); // Is called by the NotificationQueue when a notification was pushed
    133             virtual void notificationPopped(void); // Is called by the NotificationQueue when a notification was popped.
    134             virtual void notificationRemoved(unsigned int index); // Is called when a notification was removed.
     137            virtual void notificationPushed(Notification* notification); // Is called by the NotificationQueue when a Notification was pushed
     138            virtual void notificationPopped(void); // Is called by the NotificationQueue when a Notification was popped.
     139            virtual void notificationRemoved(unsigned int index); // Is called when a Notification was removed.
    135140           
    136141            virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
Note: See TracChangeset for help on using the changeset viewer.