Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7354


Ignore:
Timestamp:
Sep 5, 2010, 12:42:54 PM (14 years ago)
Author:
dafrick
Message:

Started work on edit mode. ConsoleCommand is not yet working.
Some additional cleanup. All the NotificationQueues generated by the NotificationManager now are destroyed upon destruction of the NotificationManager.
Removed NotificationQueue from level files.

Location:
code/branches/notifications
Files:
12 edited

Legend:

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

    r7351 r7354  
    66P.nameList = {}
    77P.visible = nil
     8P.editMode = false
     9P.editList = {}
    810
    911function P.createQueue(name, size)
    1012    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    1113    local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name)
    12     queue:setProperty("BackgroundColor", "66FFFFFF")
     14    queue:setProperty("BackgroundColor", "00FFFFFF")
    1315    root:addChildWindow(queue)
    1416
     
    123125end
    124126
     127function P.enterEditMode()
     128    P.editMode = true
     129
     130    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
     131    --Replace all queues with FrameWindows
     132    for k,v in pairs(P.queueList) do
     133        if v ~= nil then
     134            root:removeChildWindow(v)
     135            local frame = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. P.nameList(k))
     136            frame:setArea(v:getArea())
     137            P.editList[k] = frame
     138        end
     139    end
     140end
     141
     142function P.leaveEditMode()
     143    P.editMode = false
     144
     145    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
     146    --Replace all queues with FrameWindows
     147    for k,v in pairs(P.queueList) do
     148        if v ~= nil then
     149            root:addChildWindow(v)
     150            v:setArea(P.editList[k]:getArea())
     151            winMgr:destroyWindow(P.editList[k])
     152            P.editList[k] = nil
     153        end
     154    end
     155end
     156
     157function P.onHide()
     158    if P.editMode then
     159        P.leaveEditMode()
     160    end
     161end
     162
    125163function P.nameToQueueHelper(name)
    126164    local queue = nil
  • code/branches/notifications/data/levels/Fight in our Back.oxw

    r7163 r7354  
    77    include("templates/spaceship_Transporter.oxt")
    88?>
    9 
    10 <NotificationQueue
    11     name     = "notification"
    12     position = "0.40, 0.05"
    13     font     = "VeraMono"
    14     textsize = 0.020
    15     length   = 3
    16     width    = 50
    17 />
    189
    1910<!--*****************************************************************************************************************************************************************************************-->
  • code/branches/notifications/data/levels/Quest_PirateAttack.oxw

    r7163 r7354  
    1919    dofile("includes/CuboidSpaceStation.lua")
    2020?>
    21 
    22 <NotificationQueue
    23      name     = "notification"
    24      position = "0.40, 0.05"
    25      font     = "VeraMono"
    26      textsize = 0.020
    27      length   = 3
    28      width    = 50
    29 />
    30    
    31    
    3221   
    3322<Level
  • code/branches/notifications/data/levels/old/princessaeryn.oxw

    r6417 r7354  
    88    dofile("includes/CuboidSpaceStation.lua")
    99?>
    10 
    11 <NotificationQueue
    12  name  = "notification"
    13  position = "1.0, 1.0"
    14  targets = "questsystem"
    15 />
    1610
    1711<Level
  • code/branches/notifications/data/levels/old/questsystem.oxw

    r6417 r7354  
    44  include("templates/spaceship_assff.oxt")
    55?>
    6 
    7 <NotificationQueue
    8  name  = "notification"
    9  position = "1.0, 1.0"
    10  targets = "all"
    11 />
    126
    137<Level
  • code/branches/notifications/data/levels/princessaeryn.oxw

    r7163 r7354  
    1414 description  = "The Tale of Princess Aeryn"
    1515>
    16 
    17   <NotificationQueue
    18    name   = "notification"
    19    position = "0.55, 0.05"
    20    font   = "VeraMono"
    21    textsize = 0.020
    22    length   = 3
    23    width  = 50
    24   />
    2516
    2617  <templates>
  • code/branches/notifications/data/levels/tutorial.oxw

    r7319 r7354  
    1313    <Template link=lodtemplate_default />
    1414  </templates>
    15 
    16   <NotificationQueue
    17    name   = "notification"
    18    position = "0.05, 0.05"
    19    font   = "VeraMono"
    20    textsize = 0.020
    21    length   = 3
    22    width  = 50
    23   />
    2415
    2516  <Scene
  • code/branches/notifications/src/modules/notifications/CMakeLists.txt

    r7338 r7354  
    1212  FIND_HEADER_FILES
    1313  TOLUA_FILES
     14    NotificationManager.h
    1415  PCH_FILE
    1516    NotificationsPrecompiledHeaders.h
  • code/branches/notifications/src/modules/notifications/NotificationManager.cc

    r7351 r7354  
    3434#include "NotificationManager.h"
    3535
     36#include "core/command/ConsoleCommand.h"
    3637#include "core/CoreIncludes.h"
    3738#include "core/GUIManager.h"
     39#include "core/LuaState.h"
    3840#include "util/ScopedSingletonManager.h"
    3941#include "interfaces/NotificationListener.h"
     
    4951    ManageScopedSingleton(NotificationManager, ScopeID::Graphics, false);
    5052
     53    //TODO: Make work.
     54    //SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode).description("Enter the NotificationLayer edit mode.");
     55
    5156    /**
    5257    @brief
     
    6469
    6570            // Create first queue:
    66             this->queue_ = new NotificationQueue("all");
     71            this->queues_.push_back(new NotificationQueue("all"));
    6772        }
    6873    }
     
    7479    NotificationManager::~NotificationManager()
    7580    {
    76         //this->queue_->destroy();
     81       
     82    }
     83
     84    void NotificationManager::preDestroy(void)
     85    {
     86        for(std::vector<NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++)
     87            (*it)->destroy();
     88        this->queues_.clear();
    7789    }
    7890
     
    291303    }
    292304
     305    void NotificationManager::createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime)
     306    {
     307        this->queues_.push_back(new NotificationQueue(name, targets, size, displayTime));
     308    }
     309
    293310}
  • code/branches/notifications/src/modules/notifications/NotificationManager.h

    r7349 r7354  
    4040#include <map>
    4141#include <string>
     42#include <vector>
    4243
    4344#include "util/Singleton.h"
    4445#include "core/OrxonoxClass.h"
    4546
    46 namespace orxonox
    47 {
     47namespace orxonox // tolua_export
     48{ // tolua_export
     49
    4850    /**
    4951    @brief
     
    5355        Damian 'Mozork' Frick
    5456    */
    55     class _NotificationsExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
    56     {
     57    class _NotificationsExport NotificationManager  // tolua_export
     58        : public Singleton<NotificationManager>, public OrxonoxClass
     59    { // tolua_export
    5760            friend class Singleton<NotificationManager>;
    5861        public:
    5962            NotificationManager();
    6063            virtual ~NotificationManager();
     64
     65            virtual void preDestroy(void);
     66
     67            static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export
    6168
    6269            static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.
     
    8087                { return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
    8188
     89            void enterEditMode(void);
     90
     91            void createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime); // tolua_export
     92
    8293        private:
    8394            static NotificationManager* singletonPtr_s;
    8495
    85             NotificationQueue* queue_; //!< Initial, first, NotificationQueue.
     96            std::vector<NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
    8697
    8798            int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
     
    94105            bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map.
    95106
    96     };
     107    }; // tolua_export
    97108
    98 }
     109} // tolua_export
    99110
    100111#endif /* _NotificationManager_H__ */
  • code/branches/notifications/src/modules/notifications/NotificationQueue.cc

    r7349 r7354  
    4545{
    4646
    47     const Vector2 NotificationQueue::DEFAULT_POSITION(0.0,0.0);
    48 
    4947    /**
    5048    @brief
    5149        Constructor. Creates and initializes the object.
    5250    */
    53     NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, const Vector2& position, unsigned int displayTime)
     51    NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime)
    5452    {
    5553        this->registered_ = false;
     
    6260        this->name_ = name;
    6361        this->maxSize_ = size;
    64         this->position_ = position;
    6562        this->setDisplayTime(displayTime);
    6663
    6764        this->create();
    68         this->positionChanged();
    6965
    7066        NotificationManager::getInstance().registerListener(this);
     
    245241        this->size_ = 0;
    246242        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
    247     }
    248 
    249     /**
    250     @brief
    251         Adjusts the NotificationQueue, when the position has changed.
    252     */
    253     void NotificationQueue::positionChanged(void)
    254     {
    255         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changePosition(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getPosition().x) + ", " + multi_cast<std::string>(this->getPosition().y) + ")");
    256243    }
    257244
  • code/branches/notifications/src/modules/notifications/NotificationQueue.h

    r7349 r7354  
    4343
    4444#include "tools/interfaces/Tickable.h"
    45 #include "util/Math.h"
    4645#include "interfaces/NotificationListener.h"
    4746#include "NotificationManager.h"
     
    7372
    7473        public:
    75             NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, const Vector2& position = NotificationQueue::DEFAULT_POSITION, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
     74            NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
    7675            virtual ~NotificationQueue();
    7776
     
    106105            inline float getDisplayTime() const
    107106                { return this->displayTime_; }
    108             /**
    109             @brief Returns the position of the NotificationQueue.
    110             @return Returns the position.
    111             */
    112             inline const Vector2 & getPosition() const
    113                 { return this->position_; }
    114107
    115108            /**
     
    121114            bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
    122115
    123             /**
    124             @brief Sets the position of the NotificationQueue.
    125             @param pos The position.
    126             */
    127             inline void setPosition(Vector2 pos)
    128                 { this->position_ = pos; this->positionChanged(); }
    129 
    130116        private:
    131117            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    132118            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
    133             static const Vector2 DEFAULT_POSITION; //!< the default position.
    134119
    135120            std::string name_; //!< The name of the NotificationQueue.
     
    137122            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
    138123            unsigned int size_; //!< The number of Notifications displayed.
    139             unsigned int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.
    140124            unsigned int displayTime_; //!< The time a Notification is displayed.
    141             Vector2 position_; //!< The position of the NotificationQueue.
    142125
    143126            std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
     
    161144            bool setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
    162145
    163             void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
    164146            void sizeChanged(void); //!< Adjusts the NotificationQueue, when the maximum size has changed.
    165147
Note: See TracChangeset for help on using the changeset viewer.