Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 24, 2010, 12:01:57 PM (15 years ago)
Author:
dafrick
Message:

Some more documentation.
Making NotificationManager Root scope, cleaning up, especially in Notification (now it's just a data structure anymore).

File:
1 edited

Legend:

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

    r7484 r7488  
    3838
    3939#include "core/CoreIncludes.h"
     40#include "core/GameMode.h"
    4041#include "core/GUIManager.h"
    4142#include "core/LuaState.h"
     
    112113        this->targets_.clear();
    113114
    114         if(this->registered_) // If the
    115         {
    116             this->clear();
     115        if(this->registered_) // If the NotificationQueue is registered.
     116        {
     117            this->clear(true);
    117118
    118119            // Unregister with the NotificationManager.
    119120            NotificationManager::getInstance().unregisterListener(this);
    120121            NotificationManager::getInstance().unregisterQueue(this);
    121 
    122             // Remove the NotificationQueue in lua.
     122        }
     123    }
     124
     125    /**
     126    @brief
     127        Destroys the NotificationQueue.
     128        Used in lua and NotificationManager.
     129    @param noGraphics
     130        If this is set to true (false is default), then the queue is not removed in lua. This is used to destroy the queue, after the GUIManager has been destroyed.
     131    */
     132    void NotificationQueue::destroy(bool noGraphics)
     133    {
     134        // Remove the NotificationQueue in lua.
     135        if(GameMode::showsGraphics() && !noGraphics)
    123136            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
    124         }
     137
     138        this->OrxonoxClass::destroy();
    125139    }
    126140
     
    131145    void NotificationQueue::create(void)
    132146    {
    133         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() +  "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
     147        if(GameMode::showsGraphics())
     148            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() +  "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
    134149    }
    135150
     
    226241
    227242        // Push the Notification to the GUI.
    228         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
     243        if(GameMode::showsGraphics())
     244            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
    229245    }
    230246
     
    254270
    255271        // Pops the Notification from the GUI.
    256         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")");
     272        if(GameMode::showsGraphics())
     273            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")");
    257274    }
    258275
     
    276293
    277294        // Removes the Notification from the GUI.
    278         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
     295        if(GameMode::showsGraphics())
     296            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
    279297    }
    280298
     
    282300    @brief
    283301        Clears the NotificationQueue by removing all NotificationContainers.
    284     */
    285     void NotificationQueue::clear(void)
     302    @param noGraphics
     303        If this is eset to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally.
     304    */
     305    void NotificationQueue::clear(bool noGraphics)
    286306    {
    287307        this->ordering_.clear();
     
    295315
    296316        // Clear the NotificationQueue in the GUI.
    297         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
     317        if(GameMode::showsGraphics() && !noGraphics)
     318            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
    298319    }
    299320
Note: See TracChangeset for help on using the changeset viewer.