Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 11, 2011, 12:21:32 PM (13 years ago)
Author:
dafrick
Message:

Removing editMode stuff, since that doesn't work anymore and that won't change for quite some time.
Seperating CEGUI from NotificationQueue stuff by introducing a new NotificationQueue called the NotificationQueueCEGUI.

Location:
code/branches/tutoriallevel2/src/modules/notifications
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel2/src/modules/notifications/CMakeLists.txt

    r7403 r8446  
    44  NotificationManager.cc
    55  NotificationQueue.cc
     6  NotificationQueueCEGUI.cc
    67)
    78
     
    1314  TOLUA_FILES
    1415    NotificationManager.h
    15     NotificationQueue.h
     16    NotificationQueueCEGUI.h
    1617  PCH_FILE
    1718    NotificationsPrecompiledHeaders.h
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc

    r8445 r8446  
    4646#include "Notification.h"
    4747#include "NotificationQueue.h"
     48#include "NotificationQueueCEGUI.h"
    4849
    4950#include "ToluaBindNotifications.h"
     
    5758    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
    5859
    59     // Setting console command to enter the edit mode.
    60     SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode);
    61 
    6260    /**
    6361    @brief
     
    6866        RegisterRootObject(NotificationManager);
    6967
    70         ModifyConsoleCommand("enterEditMode").setObject(this);
    71 
    7268        COUT(3) << "NotificatioManager created." << std::endl;
    7369    }
     
    7975    NotificationManager::~NotificationManager()
    8076    {
    81         ModifyConsoleCommand("enterEditMode").setObject(NULL);
    82 
    8377        // Destroys all Notifications.
    8478        for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++)
     
    9993        while(it != this->queues_.end())
    10094        {
    101             it->second->destroy(true);
     95            it->second->destroy();
    10296            it = this->queues_.begin();
    10397        }
     
    313307    /**
    314308    @brief
    315         Enters the edit mode of the NotificationLayer.
    316     */
    317     void NotificationManager::enterEditMode(void)
    318     {
    319         if(GameMode::showsGraphics())
    320         {
    321             GUIManager::getInstance().hideGUI("NotificationLayer");
    322             GUIManager::getInstance().showGUI("NotificationLayer", false, false);
    323             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.enterEditMode()");
    324         }
    325     }
    326 
    327     /**
    328     @brief
    329309        Registers a NotificationQueue.
    330310        This makes sure that the NotificationQueue can be accessed through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.
     
    409389    void NotificationManager::loadQueues(void)
    410390    {
    411         NotificationQueue* allQueue = new NotificationQueue("all");
     391        NotificationQueue* allQueue = new NotificationQueueCEGUI("all");
    412392        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"all\", 0.5, 0, " + multi_cast<std::string>(allQueue->getMaxSize()) + ")");
    413393        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)");
    414394
    415         NotificationQueue* infoQueue = new NotificationQueue("info", NotificationListener::ALL, 1, -1);
     395        NotificationQueue* infoQueue = new NotificationQueueCEGUI("info", NotificationListener::ALL, 1, -1);
    416396        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"CCFFFF00\")");
    417397        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")");
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h

    r8445 r8446  
    5050    /**
    5151    @brief
    52         The Singleton NotificationManager functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationListener "NotificationListeners".
    53         It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationListener "NotificationListeners".
    54         It also provides a static function to send @ref orxonox::Notification "Notifications" and works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer.
     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".
     54        It also works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer.
    5555
    5656    @author
     
    9595            void getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications); // Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map.
    9696
    97             void enterEditMode(void); // Enters the edit mode of the NotificationLayer.
    98 
    9997            bool registerQueue(NotificationQueue* queue); // Registers a NotificationQueue.
    10098            void unregisterQueue(NotificationQueue* queue); // Unregisters a NotificationQueue.
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc

    r8445 r8446  
    3838
    3939#include "core/CoreIncludes.h"
    40 #include "core/GameMode.h"
    41 #include "core/GUIManager.h"
    42 #include "core/LuaState.h"
    43 #include "util/Convert.h"
    4440#include "util/SubString.h"
    4541
     
    8884        }
    8985
    90         this->create(); // Creates the NotificationQueue in lua.
    91 
    9286        COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
    9387    }
     
    108102            NotificationManager::getInstance().unregisterQueue(this);
    109103        }
    110     }
    111 
    112     /**
    113     @brief
    114         Destroys the NotificationQueue.
    115         Used in lua and NotificationManager.
    116     @param noGraphics
    117         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.
    118     */
    119     void NotificationQueue::destroy(bool noGraphics)
    120     {
    121         // Remove the NotificationQueue in lua.
    122         if(GameMode::showsGraphics() && !noGraphics)
    123             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
    124 
     104       
    125105        COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl;
    126 
    127         this->OrxonoxClass::destroy();
    128     }
    129 
    130     /**
    131     @brief
    132         Creates the NotificationQueue in lua.
    133     */
    134     void NotificationQueue::create(void)
    135     {
    136         if(GameMode::showsGraphics())
    137             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() +  "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
    138106    }
    139107
     
    236204        this->notifications_.insert(this->notifications_.begin(), container);
    237205
    238         // Push the Notification to the GUI.
    239         if(GameMode::showsGraphics())
    240             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
     206        // Inform that a Notification was pushed.
     207        this->notificationPushed(notification);
    241208
    242209        COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl;
     
    269236        delete container;
    270237
    271         // Pops the Notification from the GUI.
    272         if(GameMode::showsGraphics())
    273             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")");
     238        // Inform that a Notification was popped.
     239        this->notificationPopped();
    274240    }
    275241
     
    295261        delete *containerIterator;
    296262
    297         // Removes the Notification from the GUI.
    298         if(GameMode::showsGraphics())
    299             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
     263        // TODO: index automatically cast?
     264        // Inform that a Notification was removed.
     265        this->notificationRemoved(index);
    300266    }
    301267
     
    316282        this->notifications_.clear();
    317283        this->size_ = 0;
    318 
    319         // Clear the NotificationQueue in the GUI.
    320         if(GameMode::showsGraphics() && !noGraphics)
    321             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
    322284    }
    323285
  • code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h

    r8445 r8446  
    4747#include "tools/interfaces/Tickable.h"
    4848
    49 namespace orxonox // tolua_export
    50 { // tolua_export
     49namespace orxonox
     50{
    5151
    5252    /**
     
    8888    @ingroup Notifications
    8989    */
    90     class _NotificationsExport NotificationQueue // tolua_export
    91         : public Tickable
    92     { // tolua_export
     90    class _NotificationsExport NotificationQueue : public Tickable
     91    {
    9392
    9493        public:
    95             NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
     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);
    9695            virtual ~NotificationQueue();
    97 
    98             //! Destroys the NotificationQueue.
    99             void destroy(bool noGraphics = false); // tolua_export
    10096
    10197            virtual void tick(float dt); //!< To update from time to time.
     
    143139                { return this->targets_; }
    144140
    145             // tolua_begin
    146141            void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
    147142            const std::string& getTargets(void) const; //!< Returns a string consisting of the concatenation of the targets.
    148             // tolua_end
    149143
    150144            void tidy(void);
    151 
    152         private:
     145           
     146        protected:
    153147            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    154148            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
    155149            static const int INF = -1; //!< Constant denoting infinity.
     150       
     151            /**
     152            @brief Is called when a notification was pushed.
     153            @param notification The Notification that was pushed.
     154            */
     155            virtual void notificationPushed(Notification* notification) {}
     156            /**
     157            @brief Is called when a notification was popped.
     158            */
     159            virtual void notificationPopped(void) {}
     160            /**
     161            @brief Is called when a notification was removed.
     162            @param index The index the removed notification was at.
     163            */
     164            virtual void notificationRemoved(unsigned int index) {}
     165           
     166            virtual void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
    156167
     168
     169        private:
    157170            std::string name_; //!< The name of the NotificationQueue.
    158171
     
    171184            NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
    172185
    173             void create(void); //!< Creates the NotificationQueue in lua.
    174 
    175186            void setName(const std::string& name); //!< Sets the name of the NotificationQueue.
    176187
     
    179190            void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer.
    180191
    181             void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
     192    };
    182193
    183     }; // tolua_export
     194}
    184195
    185 } // tolua_export
    186 
    187 #endif /* _NotificationOverlay_H__ */
     196#endif /* _NotificationQueue_H__ */
Note: See TracChangeset for help on using the changeset viewer.