[Orxonox-commit 3766] r8446 - in code/branches/tutoriallevel2: data/gui/scripts src/modules/notifications

dafrick at orxonox.net dafrick at orxonox.net
Wed May 11 12:21:33 CEST 2011


Author: dafrick
Date: 2011-05-11 12:21:32 +0200 (Wed, 11 May 2011)
New Revision: 8446

Added:
   code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.cc
   code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.h
Modified:
   code/branches/tutoriallevel2/data/gui/scripts/NotificationLayer.lua
   code/branches/tutoriallevel2/src/modules/notifications/CMakeLists.txt
   code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc
   code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h
   code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc
   code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h
Log:

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.


Modified: code/branches/tutoriallevel2/data/gui/scripts/NotificationLayer.lua
===================================================================
--- code/branches/tutoriallevel2/data/gui/scripts/NotificationLayer.lua	2011-05-10 21:37:22 UTC (rev 8445)
+++ code/branches/tutoriallevel2/data/gui/scripts/NotificationLayer.lua	2011-05-11 10:21:32 UTC (rev 8446)
@@ -3,7 +3,6 @@
 local P = createMenuSheet("NotificationLayer", true, TriBool.True, TriBool.True)
 
 P.queueList = {}
-P.editMode = false
 
 P.sampleWindow = nil
 
@@ -247,361 +246,6 @@
     end
 end
 
--- Enter the edit mode of the notification layer.
-function P.enterEditMode()
-    P.editMode = true
-
-    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
-
-    --Add control frame window.
-    local window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/ControlWindow")
-    local frame = tolua.cast(window, "CEGUI::FrameWindow")
-    frame:setCloseButtonEnabled(false)
-    frame:setText("NotificationLayer Control Window")
-    frame:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.2, 0)))
-    root:addChildWindow(window)
-    local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/ScrollingPane")
-    pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30)))
-    pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26)))
-    window:addChildWindow(pane)
-
-    vertOffset = 0
-    horzOffset = 0
-    -- Line to be able to create a new queue.
-    local newQueueTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueTitle")
-    newQueueTitle:setText("Create a new NotificationQueue:")
-    local size = getMinTextSize(newQueueTitle)
-    local textHeight = size[1]
-    newQueueTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
-    newQueueTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    pane:addChildWindow(newQueueTitle)
-    horzOffset = horzOffset + size[2] + 5
-    local newQueueName = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
-    newQueueName:setProperty("ReadOnly", "set:False")
-    newQueueName:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
-    newQueueName:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    horzOffset = horzOffset + size[2] + 5
-    pane:addChildWindow(newQueueName)
-    local create = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/CreateNewQueue")
-    create:setText("create")
-    P.sampleWindow:setText("create")
-    size = getMinTextSize(P.sampleWindow)
-    create:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight)))
-    create:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    orxonox.GUIManager:subscribeEventHelper(create, "Clicked", P.name .. ".createNewQueue_clicked")
-    pane:addChildWindow(create)
-    horzOffset = horzOffset + size[2]+20 + 5
-    vertOffset = vertOffset + textHeight + 5
-
-    horzOffset = 0
-    -- Button to leave the edit mode.
-    local leave = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/LeaveEditModeButton")
-    leave:setText("leave Edit Mode")
-    P.sampleWindow:setText("leave Edit Mode")
-    size = getMinTextSize(P.sampleWindow)
-    leave:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight)))
-    leave:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    orxonox.GUIManager:subscribeEventHelper(leave, "Clicked", P.name .. ".leaveEditMode_clicked")
-    pane:addChildWindow(leave)
-    horzOffset = horzOffset + size[2]+20 + 5
-    vertOffset = vertOffset + textHeight + 5
-
-    --Replace all queues with FrameWindows
-    for k,v in pairs(P.queueList) do
-        if v ~= nil then
-            local queue = P.queueList[k]
-            -- Remove the window that displays the queue from the root window such that it is no longer displayed.
-            root:removeChildWindow(v.window)
-
-            -- Create the frame window, with options to edit the queue, that is displayed instead of the queue.
-            local window = P.createQueueEditFrame(v.name)
-            window:setArea(v.window:getArea()) -- Set the frame window size and position to the same as the queue.
-
-            v.edit = window
-        end
-    end
-end
-
--- Helper function. Creates a frame for the input queue.
-function P.createQueueEditFrame(queueName)
-    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
-
-    window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. queueName)
-    local frame = tolua.cast(window, "CEGUI::FrameWindow")
-    frame:setCloseButtonEnabled(true)
-    orxonox.GUIManager:subscribeEventHelper(frame, "CloseClicked", P.name .. ".closeQueue_clicked")
-    frame:setText("NotificationQueue \"" .. queueName .. "\"")
-    root:addChildWindow(window)
-    local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/ScrollingPane")
-    pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30)))
-    pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26)))
-    window:addChildWindow(pane)
-
-    local horzOffset = 0
-    local vertOffset = 0
-
-    -- The line that lets you edit the targets of the queue.
-    local targetsTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/TargetsTitle")
-    targetsTitle:setText("Targets:")
-    local size = getMinTextSize(targetsTitle)
-    local textHeight = size[1]
-    targetsTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
-    targetsTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    pane:addChildWindow(targetsTitle)
-    horzOffset = horzOffset + size[2] + 5
-    local targets = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets")
-    targets:setProperty("ReadOnly", "set:False")
-    local targetsText = orxonox.NotificationManager:getInstance():getQueue(queueName):getTargets()
-    targets:setText(targetsText)
-    P.sampleWindow:setText(targetsText)
-    size = getMinTextSize(P.sampleWindow)
-    targets:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
-    targets:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    horzOffset = horzOffset + size[2]*2+20 + 5
-    pane:addChildWindow(targets)
-    local save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets/Save")
-    save:setText("save")
-    P.sampleWindow:setText("save")
-    size = getMinTextSize(P.sampleWindow)
-    local saveTextWidth = size[2]+20
-    save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
-    save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveTargets_clicked")
-    pane:addChildWindow(save)
-    horzOffset = horzOffset + saveTextWidth
-    vertOffset = vertOffset + textHeight + 5
-
-    horzOffset = 0
-    -- The line that lets you edit the size of the queue.
-    local sizeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/SizeTitle")
-    sizeTitle:setText("Size:")
-    size = getMinTextSize(sizeTitle)
-    sizeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
-    sizeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    pane:addChildWindow(sizeTitle)
-    horzOffset = horzOffset + size[2] + 5
-    local queueSize = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size")
-    queueSize:setProperty("ReadOnly", "set:False")
-    local maxSize = orxonox.NotificationManager:getInstance():getQueue(queueName):getMaxSize()
-    queueSize:setText(maxSize)
-    P.sampleWindow:setText(maxSize)
-    size = getMinTextSize(P.sampleWindow)
-    queueSize:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
-    queueSize:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    horzOffset = horzOffset + size[2]*2+20 + 5
-    pane:addChildWindow(queueSize)
-    save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size/Save")
-    save:setText("save")
-    P.sampleWindow:setText("save")
-    size = getMinTextSize(P.sampleWindow)
-    local saveTextWidth = size[2]+20
-    save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
-    save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveSize_clicked")
-    pane:addChildWindow(save)
-    horzOffset = horzOffset + saveTextWidth
-    vertOffset = vertOffset + textHeight + 5
-
-    horzOffset = 0
-    -- The line that lets you edit the display time of the queue.
-    local displayTimeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTimeTitle")
-    displayTimeTitle:setText("Display time:")
-    size = getMinTextSize(displayTimeTitle)
-    displayTimeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
-    displayTimeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    pane:addChildWindow(displayTimeTitle)
-    horzOffset = horzOffset + size[2] + 5
-    local displayTime = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime")
-    displayTime:setProperty("ReadOnly", "set:False")
-    local time = orxonox.NotificationManager:getInstance():getQueue(queueName):getDisplayTime()
-    displayTime:setText(time)
-    P.sampleWindow:setText(time)
-    size = getMinTextSize(P.sampleWindow)
-    displayTime:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
-    displayTime:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    horzOffset = horzOffset + size[2]*2+20 + 5
-    pane:addChildWindow(displayTime)
-    save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime/Save")
-    save:setText("save")
-    P.sampleWindow:setText("save")
-    size = getMinTextSize(P.sampleWindow)
-    local saveTextWidth = size[2]+20
-    save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
-    save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
-    orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveDisplayTime_clicked")
-    pane:addChildWindow(save)
-    horzOffset = horzOffset + saveTextWidth
-    vertOffset = vertOffset + textHeight + 5
-
-    return window
-end
-
--- Leave the edit mode.
-function P.leaveEditMode()
-    P.editMode = false
-
-    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
-    --Replace all queues with FrameWindows
-    for k,v in pairs(P.queueList) do
-        if v ~= nil then
-            -- Add the queue window to the root window to have it displayed again.
-            root:addChildWindow(v.window)
-            -- Set the size and position of the queue window to the size and position of the queue edit frame.
-            v.window:setArea(v.edit:getArea())
-            -- Destroy the edit frame.
-            winMgr:destroyWindow(v.edit)
-            v.edit = nil
-        end
-    end
-
-    --Remove control window
-    winMgr:destroyWindow(winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow"))
-end
-
--- Is called after the sheet has been hidden.
-function P.afterHide()
-    -- If we leave the edit mode we show the sheet again.
-    if P.editMode then
-        P.leaveEditMode()
-        showMenuSheet(P.name, false, true)
-    end
-end
-
--- If the button to save the targets of a queue has been clicked.
-function P.saveTargets_clicked(e)
-    local we = CEGUI.toWindowEventArgs(e)
-    local name = we.window:getName()
-
-    local match = string.gmatch(name, "EditMode/.*/Targets/Save")
-    local nameStr = match()
-    local queueName = string.sub(nameStr, 10, string.len(nameStr)-13)
-
-    local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets")
-    local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets/Save")
-    local width = window:getWidth():asAbsolute(1)
-
-    local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
-    -- Set the new targets.
-    queue:setTargets(window:getText())
-    local targets = queue:getTargets()
-
-    window:setText(targets)
-    P.sampleWindow:setText(targets)
-    local size = getMinTextSize(P.sampleWindow)
-    -- Adjust the width of the targets field.
-    window:setWidth(CEGUI.UDim(0, size[2]*2+20))
-    -- Adjust the position of the save button after the targets field.
-    save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
-end
-
--- If the button to save the size if a queue has been clicked.
-function P.saveSize_clicked(e)
-    local we = CEGUI.toWindowEventArgs(e)
-    local name = we.window:getName()
-
-    local match = string.gmatch(name, "EditMode/.*/Size/Save")
-    local nameStr = match()
-    local queueName = string.sub(nameStr, 10, string.len(nameStr)-10)
-
-    local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size")
-    local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size/Save")
-    local width = window:getWidth():asAbsolute(1)
-
-    local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
-    -- Set the new size.
-    queue:setMaxSize(tonumber(window:getText()))
-    local maxSize = queue:getMaxSize()
-
-    window:setText(maxSize)
-    P.sampleWindow:setText(maxSize)
-    local size = getMinTextSize(P.sampleWindow)
-    -- Adjust the width of the size field.
-    window:setWidth(CEGUI.UDim(0, size[2]*2+20))
-    -- Adjust the position of the save button after the size field.
-    save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
-end
-
--- If the button to save the display time if a queue has been clicked.
-function P.saveDisplayTime_clicked(e)
-    local we = CEGUI.toWindowEventArgs(e)
-    local name = we.window:getName()
-
-    local match = string.gmatch(name, "EditMode/.*/DisplayTime/Save")
-    local nameStr = match()
-    local queueName = string.sub(nameStr, 10, string.len(nameStr)-17)
-
-    local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime")
-    local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime/Save")
-    local width = window:getWidth():asAbsolute(1)
-
-    local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
-    -- Set the new display time.
-    queue:setDisplayTime(tonumber(window:getText()))
-    local time = queue:getDisplayTime()
-
-    window:setText(time)
-    P.sampleWindow:setText(time)
-    local size = getMinTextSize(P.sampleWindow)
-    -- Adjust the width of the display time field.
-    window:setWidth(CEGUI.UDim(0, size[2]*2+20))
-    -- Adjust the position of the save button after the display time field.
-    save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
-end
-
--- if the button to create a new queue has been clicked.
-function P.createNewQueue_clicked(e)
-    local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
-    local name = window:getText()
-
-    local queue = P.queueList[name]
-    -- Test if a queue with that name already exists.
-    if queue ~= nil then
-        window:setText("Queue with that name already exists.")
-        return
-    end
-
-    -- Creates the new queue.
-    orxonox.NotificationManager:getInstance():createQueue(name)
-
-    queue = P.queueList[name]
-    if queue == nil then
-        return
-    end
-
-    -- Create the frame that represents the queue in edit mode, since that's what we're in.
-    local frame = P.createQueueEditFrame(name)
-    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
-    -- Remove the queue window from the root window, since we're in edit mode.
-    root:removeChildWindow(queue.window)
-    -- Set the frame window size and position to that of the queue window.
-    frame:setArea(queue.window:getArea())
-    queue.edit = frame
-
-    -- Reset the text to create a new queue.
-    window:setText("")
-end
-
--- If the button to leave the edit mode has been clicked.
-function P.leaveEditMode_clicked(e)
-    hideMenuSheet(P.name)
-end
-
--- If the button to close the queue has been clicked.
-function P.closeQueue_clicked(e)
-    local we = CEGUI.toWindowEventArgs(e)
-    local name = we.window:getName()
-
-    local match = string.gmatch(name, "EditMode/.*")
-    local nameStr = match()
-    local queueName = string.sub(nameStr, 10, string.len(nameStr))
-
-    -- Destroy the frame window,
-    winMgr:destroyWindow(P.queueList[queueName].edit)
-    P.queueList[queueName].edit = nil
-    -- Destroy the queue.
-    orxonox.NotificationManager:getInstance():getQueue(queueName):destroy()
-end
-
 -- Helper function. Returns height a queue needs to have to display 'size' items.
 function P.queueHeightHelper(queue, size)
     --local listbox = CEGUI.toListbox(queue.window)

Modified: code/branches/tutoriallevel2/src/modules/notifications/CMakeLists.txt
===================================================================
--- code/branches/tutoriallevel2/src/modules/notifications/CMakeLists.txt	2011-05-10 21:37:22 UTC (rev 8445)
+++ code/branches/tutoriallevel2/src/modules/notifications/CMakeLists.txt	2011-05-11 10:21:32 UTC (rev 8446)
@@ -3,6 +3,7 @@
   NotificationDispatcher.cc
   NotificationManager.cc
   NotificationQueue.cc
+  NotificationQueueCEGUI.cc
 )
 
 ADD_SUBDIRECTORY(dispatchers)
@@ -12,7 +13,7 @@
   FIND_HEADER_FILES
   TOLUA_FILES
     NotificationManager.h
-    NotificationQueue.h
+    NotificationQueueCEGUI.h
   PCH_FILE
     NotificationsPrecompiledHeaders.h
   LINK_LIBRARIES

Modified: code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc	2011-05-10 21:37:22 UTC (rev 8445)
+++ code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc	2011-05-11 10:21:32 UTC (rev 8446)
@@ -45,6 +45,7 @@
 
 #include "Notification.h"
 #include "NotificationQueue.h"
+#include "NotificationQueueCEGUI.h"
 
 #include "ToluaBindNotifications.h"
 
@@ -56,9 +57,6 @@
 
     ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
 
-    // Setting console command to enter the edit mode.
-    SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode);
-
     /**
     @brief
         Constructor. Registers the Object.
@@ -67,8 +65,6 @@
     {
         RegisterRootObject(NotificationManager);
 
-        ModifyConsoleCommand("enterEditMode").setObject(this);
-
         COUT(3) << "NotificatioManager created." << std::endl;
     }
 
@@ -78,8 +74,6 @@
     */
     NotificationManager::~NotificationManager()
     {
-        ModifyConsoleCommand("enterEditMode").setObject(NULL);
-
         // Destroys all Notifications.
         for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++)
             it->second->destroy();
@@ -98,7 +92,7 @@
         std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin();
         while(it != this->queues_.end())
         {
-            it->second->destroy(true);
+            it->second->destroy();
             it = this->queues_.begin();
         }
 
@@ -312,20 +306,6 @@
 
     /**
     @brief
-        Enters the edit mode of the NotificationLayer.
-    */
-    void NotificationManager::enterEditMode(void)
-    {
-        if(GameMode::showsGraphics())
-        {
-            GUIManager::getInstance().hideGUI("NotificationLayer");
-            GUIManager::getInstance().showGUI("NotificationLayer", false, false);
-            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.enterEditMode()");
-        }
-    }
-
-    /**
-    @brief
         Registers a NotificationQueue.
         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.
     @param queue
@@ -408,11 +388,11 @@
     */
     void NotificationManager::loadQueues(void)
     {
-        NotificationQueue* allQueue = new NotificationQueue("all");
+        NotificationQueue* allQueue = new NotificationQueueCEGUI("all");
         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"all\", 0.5, 0, " + multi_cast<std::string>(allQueue->getMaxSize()) + ")");
         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)");
 
-        NotificationQueue* infoQueue = new NotificationQueue("info", NotificationListener::ALL, 1, -1);
+        NotificationQueue* infoQueue = new NotificationQueueCEGUI("info", NotificationListener::ALL, 1, -1);
         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"CCFFFF00\")");
         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")");
         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"info\", 0.2, 0, 0.8, 0)");

Modified: code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h
===================================================================
--- code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h	2011-05-10 21:37:22 UTC (rev 8445)
+++ code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h	2011-05-11 10:21:32 UTC (rev 8446)
@@ -49,9 +49,9 @@
 
     /**
     @brief
-        The Singleton NotificationManager functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationListener "NotificationListeners".
-        It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationListener "NotificationListeners".
-        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.
+        The Singleton NotificationManager is a NotificationListener and functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationQueues "NotificationQueues".
+        It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationLQueue "NotificationQueues".
+        It also works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer.
 
     @author
         Damian 'Mozork' Frick
@@ -94,8 +94,6 @@
 
             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.
 
-            void enterEditMode(void); // Enters the edit mode of the NotificationLayer.
-
             bool registerQueue(NotificationQueue* queue); // Registers a NotificationQueue.
             void unregisterQueue(NotificationQueue* queue); // Unregisters a NotificationQueue.
 

Modified: code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc
===================================================================
--- code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc	2011-05-10 21:37:22 UTC (rev 8445)
+++ code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc	2011-05-11 10:21:32 UTC (rev 8446)
@@ -37,10 +37,6 @@
 #include <sstream>
 
 #include "core/CoreIncludes.h"
-#include "core/GameMode.h"
-#include "core/GUIManager.h"
-#include "core/LuaState.h"
-#include "util/Convert.h"
 #include "util/SubString.h"
 
 #include "Notification.h"
@@ -87,8 +83,6 @@
             return;
         }
 
-        this->create(); // Creates the NotificationQueue in lua.
-
         COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
     }
 
@@ -107,38 +101,12 @@
             // Unregister with the NotificationManager.
             NotificationManager::getInstance().unregisterQueue(this);
         }
-    }
-
-    /**
-    @brief
-        Destroys the NotificationQueue.
-        Used in lua and NotificationManager.
-    @param noGraphics
-        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.
-    */
-    void NotificationQueue::destroy(bool noGraphics)
-    {
-        // Remove the NotificationQueue in lua.
-        if(GameMode::showsGraphics() && !noGraphics)
-            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
-
+        
         COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl;
-
-        this->OrxonoxClass::destroy();
     }
 
     /**
     @brief
-        Creates the NotificationQueue in lua.
-    */
-    void NotificationQueue::create(void)
-    {
-        if(GameMode::showsGraphics())
-            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() +  "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
-    }
-
-    /**
-    @brief
         Updates the queue from time to time.
     @param dt
         The time interval that has passed since the last tick.
@@ -235,9 +203,8 @@
         // Insert the Notification at the begin of the list (vector, actually).
         this->notifications_.insert(this->notifications_.begin(), container);
 
-        // Push the Notification to the GUI.
-        if(GameMode::showsGraphics())
-            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
+        // Inform that a Notification was pushed.
+        this->notificationPushed(notification);
 
         COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl;
     }
@@ -268,9 +235,8 @@
 
         delete container;
 
-        // Pops the Notification from the GUI.
-        if(GameMode::showsGraphics())
-            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")");
+        // Inform that a Notification was popped.
+        this->notificationPopped();
     }
 
     /**
@@ -294,9 +260,9 @@
 
         delete *containerIterator;
 
-        // Removes the Notification from the GUI.
-        if(GameMode::showsGraphics())
-            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
+        // TODO: index automatically cast?
+        // Inform that a Notification was removed.
+        this->notificationRemoved(index);
     }
 
     /**
@@ -315,10 +281,6 @@
 
         this->notifications_.clear();
         this->size_ = 0;
-
-        // Clear the NotificationQueue in the GUI.
-        if(GameMode::showsGraphics() && !noGraphics)
-            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
     }
 
     /**

Modified: code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h
===================================================================
--- code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h	2011-05-10 21:37:22 UTC (rev 8445)
+++ code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h	2011-05-11 10:21:32 UTC (rev 8446)
@@ -46,8 +46,8 @@
 
 #include "tools/interfaces/Tickable.h"
 
-namespace orxonox // tolua_export
-{ // tolua_export
+namespace orxonox
+{
 
     /**
     @brief
@@ -87,17 +87,13 @@
 
     @ingroup Notifications
     */
-    class _NotificationsExport NotificationQueue // tolua_export
-        : public Tickable
-    { // tolua_export
+    class _NotificationsExport NotificationQueue : public Tickable
+    {
 
         public:
-            NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
+            NotificationQueue(const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
             virtual ~NotificationQueue();
 
-            //! Destroys the NotificationQueue.
-            void destroy(bool noGraphics = false); // tolua_export
-
             virtual void tick(float dt); //!< To update from time to time.
 
             void update(void); //!< Updates the NotificationQueue.
@@ -142,18 +138,35 @@
             inline const std::set<std::string> & getTargetsSet()
                 { return this->targets_; }
 
-            // tolua_begin
             void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
             const std::string& getTargets(void) const; //!< Returns a string consisting of the concatenation of the targets.
-            // tolua_end
 
             void tidy(void);
-
-        private:
+            
+        protected:
             static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
             static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
             static const int INF = -1; //!< Constant denoting infinity.
+        
+            /**
+            @brief Is called when a notification was pushed.
+            @param notification The Notification that was pushed.
+            */
+            virtual void notificationPushed(Notification* notification) {}
+            /**
+            @brief Is called when a notification was popped.
+            */
+            virtual void notificationPopped(void) {}
+            /**
+            @brief Is called when a notification was removed.
+            @param index The index the removed notification was at.
+            */
+            virtual void notificationRemoved(unsigned int index) {}
+            
+            virtual void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
 
+
+        private:
             std::string name_; //!< The name of the NotificationQueue.
 
             unsigned int maxSize_; //!< The maximal number of Notifications displayed.
@@ -170,18 +183,14 @@
             float tickTime_; //!< Helper variable, to not have to check for Notifications that have been displayed too long, every tick.
             NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
 
-            void create(void); //!< Creates the NotificationQueue in lua.
-
             void setName(const std::string& name); //!< Sets the name of the NotificationQueue.
 
             void push(Notification* notification, const std::time_t & time); //!< Adds (pushes) a Notification to the NotificationQueue.
             void pop(void); //!< Removes (pops) the least recently added Notification form the NotificationQueue.
             void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer.
 
-            void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
+    };
 
-    }; // tolua_export
+}
 
-} // tolua_export
-
-#endif /* _NotificationOverlay_H__ */
+#endif /* _NotificationQueue_H__ */

Added: code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.cc
===================================================================
--- code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.cc	                        (rev 0)
+++ code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.cc	2011-05-11 10:21:32 UTC (rev 8446)
@@ -0,0 +1,137 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file NotificationQueueCEGUI.cc
+    @brief Implementation of the NotificationQueueCEGUI class.
+*/
+
+#include "NotificationQueueCEGUI.h"
+
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "core/GUIManager.h"
+#include "core/LuaState.h"
+#include "util/Convert.h"
+
+#include "Notification.h"
+
+namespace orxonox
+{
+
+    NotificationQueueCEGUI::NotificationQueueCEGUI(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime) : NotificationQueue(name, senders, size, displayTime)
+    {
+        RegisterObject(NotificationQueueCEGUI);
+        
+        // Create the NotificationQueueCEGUI in lua.
+        this->create();
+    }
+    
+    NotificationQueueCEGUI::~NotificationQueueCEGUI()
+    {
+        
+    }
+
+    /**
+    @brief
+        Destroys the NotificationQueueCEGUI.
+        Used in lua and NotificationManager.
+    @param noGraphics
+        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.
+    */
+    void NotificationQueueCEGUI::destroy(bool noGraphics)
+    {
+        // Remove the NotificationQueue in lua.
+        if(GameMode::showsGraphics() && !noGraphics)
+            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
+
+        NotificationQueue::destroy();
+    }
+    
+    /**
+    @brief
+        Is called by the NotificationQueue when a notification was pushed.
+    @param notification
+        The Notification that was pushed.
+    */
+    void NotificationQueueCEGUI::notificationPushed(Notification* notification)
+    {
+         // Push the Notification to the GUI.
+        if(GameMode::showsGraphics())
+            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
+    }
+    
+    /**
+    @brief
+        Is called by the NotificationQueue when a notification was popped.
+    */
+    void NotificationQueueCEGUI::notificationPopped(void)
+    {
+        // Pops the Notification from the GUI.
+        if(GameMode::showsGraphics())
+            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")");
+    }
+    
+    /**
+    @brief Is called when a notification was removed.
+    @param index The index the removed notification was at.
+    */
+    void NotificationQueueCEGUI::notificationRemoved(unsigned int index)
+    {
+        // Removes the Notification from the GUI.
+        if(GameMode::showsGraphics())
+            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
+    }
+    
+    /**
+    @brief
+        Clears the NotificationQueue by removing all NotificationContainers.
+    @param noGraphics
+        If this is set to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally.
+    */
+    void NotificationQueueCEGUI::clear(bool noGraphics)
+    {
+        NotificationQueue::clear(noGraphics);
+        
+        // Clear the NotificationQueue in the GUI.
+        if(GameMode::showsGraphics() && !noGraphics)
+            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
+    }
+    
+    /**
+    @brief
+        Creates the NotificationQueue in lua.
+    */
+    void NotificationQueueCEGUI::create(void)
+    {
+        if(GameMode::showsGraphics())
+            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() +  "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
+    }
+
+}
+

Added: code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.h
===================================================================
--- code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.h	                        (rev 0)
+++ code/branches/tutoriallevel2/src/modules/notifications/NotificationQueueCEGUI.h	2011-05-11 10:21:32 UTC (rev 8446)
@@ -0,0 +1,89 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file NotificationQueueCEGUI.h
+    @brief Definition of the NotificationQueueCEGUI class.
+    @ingroup Notifications
+*/
+
+#ifndef _NotificationOueueCEGUI_H__
+#define _NotificationOueueCEGUI_H__
+
+#include "notifications/NotificationsPrereqs.h"
+
+#include <string>
+
+#include "NotificationManager.h"
+#include "NotificationQueue.h"
+
+namespace orxonox // tolua_export
+{ // tolua_export
+
+    //TODO: Update.
+    /**
+    @brief
+        Displays @ref orxonox::Notification "Notifications" from specific senders.
+
+        There are quite some parameters that influence the behavior of the NotificationQueue:
+        - @b name The name of the NotificationQueue. It needs to be unique.
+        - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays.
+        - @b size The size of the NotificationQueue, it specifies how many @ref orxonox::Notification "Notifications" are displayed at once at the most.
+        - @b displayTime The time a @ref orxonox::Notification "Notification" is displayed with this NotificationQueue.
+
+    @author
+        Damian 'Mozork' Frick
+
+    @ingroup Notifications
+    */
+    class _NotificationsExport NotificationQueueCEGUI // tolua_export
+        : public NotificationQueue
+    { // tolua_export
+
+        public:
+            NotificationQueueCEGUI(const std::string& name, const std::string& senders = NotificationListener::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
+            virtual ~NotificationQueueCEGUI();
+
+            //! Destroys the NotificationQueue.
+            void destroy(bool noGraphics = false); // tolua_export
+            
+        protected:
+            virtual void notificationPushed(Notification* notification); // Is called by the NotificationQueue when a notification was pushed
+            virtual void notificationPopped(void); // Is called by the NotificationQueue when a notification was popped.
+            virtual void notificationRemoved(unsigned int index); // Is called when a notification was removed.
+            
+            virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
+            
+        private:
+            void create(void); // Creates the NotificationQueue in lua.            
+
+    }; // tolua_export
+
+} // tolua_export
+
+#endif /* _NotificationQueueCEGUI_H__ */




More information about the Orxonox-commit mailing list