Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8446 for code/branches


Ignore:
Timestamp:
May 11, 2011, 12:21:32 PM (14 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
Files:
2 added
6 edited

Legend:

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

    r8378 r8446  
    44
    55P.queueList = {}
    6 P.editMode = false
    76
    87P.sampleWindow = nil
     
    248247end
    249248
    250 -- Enter the edit mode of the notification layer.
    251 function P.enterEditMode()
    252     P.editMode = true
    253 
    254     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    255 
    256     --Add control frame window.
    257     local window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/ControlWindow")
    258     local frame = tolua.cast(window, "CEGUI::FrameWindow")
    259     frame:setCloseButtonEnabled(false)
    260     frame:setText("NotificationLayer Control Window")
    261     frame:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.2, 0)))
    262     root:addChildWindow(window)
    263     local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/ScrollingPane")
    264     pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30)))
    265     pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26)))
    266     window:addChildWindow(pane)
    267 
    268     vertOffset = 0
    269     horzOffset = 0
    270     -- Line to be able to create a new queue.
    271     local newQueueTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueTitle")
    272     newQueueTitle:setText("Create a new NotificationQueue:")
    273     local size = getMinTextSize(newQueueTitle)
    274     local textHeight = size[1]
    275     newQueueTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    276     newQueueTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    277     pane:addChildWindow(newQueueTitle)
    278     horzOffset = horzOffset + size[2] + 5
    279     local newQueueName = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
    280     newQueueName:setProperty("ReadOnly", "set:False")
    281     newQueueName:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    282     newQueueName:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    283     horzOffset = horzOffset + size[2] + 5
    284     pane:addChildWindow(newQueueName)
    285     local create = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/CreateNewQueue")
    286     create:setText("create")
    287     P.sampleWindow:setText("create")
    288     size = getMinTextSize(P.sampleWindow)
    289     create:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight)))
    290     create:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    291     orxonox.GUIManager:subscribeEventHelper(create, "Clicked", P.name .. ".createNewQueue_clicked")
    292     pane:addChildWindow(create)
    293     horzOffset = horzOffset + size[2]+20 + 5
    294     vertOffset = vertOffset + textHeight + 5
    295 
    296     horzOffset = 0
    297     -- Button to leave the edit mode.
    298     local leave = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/LeaveEditModeButton")
    299     leave:setText("leave Edit Mode")
    300     P.sampleWindow:setText("leave Edit Mode")
    301     size = getMinTextSize(P.sampleWindow)
    302     leave:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight)))
    303     leave:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    304     orxonox.GUIManager:subscribeEventHelper(leave, "Clicked", P.name .. ".leaveEditMode_clicked")
    305     pane:addChildWindow(leave)
    306     horzOffset = horzOffset + size[2]+20 + 5
    307     vertOffset = vertOffset + textHeight + 5
    308 
    309     --Replace all queues with FrameWindows
    310     for k,v in pairs(P.queueList) do
    311         if v ~= nil then
    312             local queue = P.queueList[k]
    313             -- Remove the window that displays the queue from the root window such that it is no longer displayed.
    314             root:removeChildWindow(v.window)
    315 
    316             -- Create the frame window, with options to edit the queue, that is displayed instead of the queue.
    317             local window = P.createQueueEditFrame(v.name)
    318             window:setArea(v.window:getArea()) -- Set the frame window size and position to the same as the queue.
    319 
    320             v.edit = window
    321         end
    322     end
    323 end
    324 
    325 -- Helper function. Creates a frame for the input queue.
    326 function P.createQueueEditFrame(queueName)
    327     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    328 
    329     window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. queueName)
    330     local frame = tolua.cast(window, "CEGUI::FrameWindow")
    331     frame:setCloseButtonEnabled(true)
    332     orxonox.GUIManager:subscribeEventHelper(frame, "CloseClicked", P.name .. ".closeQueue_clicked")
    333     frame:setText("NotificationQueue \"" .. queueName .. "\"")
    334     root:addChildWindow(window)
    335     local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/ScrollingPane")
    336     pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30)))
    337     pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26)))
    338     window:addChildWindow(pane)
    339 
    340     local horzOffset = 0
    341     local vertOffset = 0
    342 
    343     -- The line that lets you edit the targets of the queue.
    344     local targetsTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/TargetsTitle")
    345     targetsTitle:setText("Targets:")
    346     local size = getMinTextSize(targetsTitle)
    347     local textHeight = size[1]
    348     targetsTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    349     targetsTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    350     pane:addChildWindow(targetsTitle)
    351     horzOffset = horzOffset + size[2] + 5
    352     local targets = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets")
    353     targets:setProperty("ReadOnly", "set:False")
    354     local targetsText = orxonox.NotificationManager:getInstance():getQueue(queueName):getTargets()
    355     targets:setText(targetsText)
    356     P.sampleWindow:setText(targetsText)
    357     size = getMinTextSize(P.sampleWindow)
    358     targets:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
    359     targets:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    360     horzOffset = horzOffset + size[2]*2+20 + 5
    361     pane:addChildWindow(targets)
    362     local save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets/Save")
    363     save:setText("save")
    364     P.sampleWindow:setText("save")
    365     size = getMinTextSize(P.sampleWindow)
    366     local saveTextWidth = size[2]+20
    367     save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
    368     save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    369     orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveTargets_clicked")
    370     pane:addChildWindow(save)
    371     horzOffset = horzOffset + saveTextWidth
    372     vertOffset = vertOffset + textHeight + 5
    373 
    374     horzOffset = 0
    375     -- The line that lets you edit the size of the queue.
    376     local sizeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/SizeTitle")
    377     sizeTitle:setText("Size:")
    378     size = getMinTextSize(sizeTitle)
    379     sizeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    380     sizeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    381     pane:addChildWindow(sizeTitle)
    382     horzOffset = horzOffset + size[2] + 5
    383     local queueSize = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size")
    384     queueSize:setProperty("ReadOnly", "set:False")
    385     local maxSize = orxonox.NotificationManager:getInstance():getQueue(queueName):getMaxSize()
    386     queueSize:setText(maxSize)
    387     P.sampleWindow:setText(maxSize)
    388     size = getMinTextSize(P.sampleWindow)
    389     queueSize:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
    390     queueSize:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    391     horzOffset = horzOffset + size[2]*2+20 + 5
    392     pane:addChildWindow(queueSize)
    393     save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size/Save")
    394     save:setText("save")
    395     P.sampleWindow:setText("save")
    396     size = getMinTextSize(P.sampleWindow)
    397     local saveTextWidth = size[2]+20
    398     save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
    399     save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    400     orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveSize_clicked")
    401     pane:addChildWindow(save)
    402     horzOffset = horzOffset + saveTextWidth
    403     vertOffset = vertOffset + textHeight + 5
    404 
    405     horzOffset = 0
    406     -- The line that lets you edit the display time of the queue.
    407     local displayTimeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTimeTitle")
    408     displayTimeTitle:setText("Display time:")
    409     size = getMinTextSize(displayTimeTitle)
    410     displayTimeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    411     displayTimeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    412     pane:addChildWindow(displayTimeTitle)
    413     horzOffset = horzOffset + size[2] + 5
    414     local displayTime = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime")
    415     displayTime:setProperty("ReadOnly", "set:False")
    416     local time = orxonox.NotificationManager:getInstance():getQueue(queueName):getDisplayTime()
    417     displayTime:setText(time)
    418     P.sampleWindow:setText(time)
    419     size = getMinTextSize(P.sampleWindow)
    420     displayTime:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
    421     displayTime:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    422     horzOffset = horzOffset + size[2]*2+20 + 5
    423     pane:addChildWindow(displayTime)
    424     save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime/Save")
    425     save:setText("save")
    426     P.sampleWindow:setText("save")
    427     size = getMinTextSize(P.sampleWindow)
    428     local saveTextWidth = size[2]+20
    429     save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
    430     save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    431     orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveDisplayTime_clicked")
    432     pane:addChildWindow(save)
    433     horzOffset = horzOffset + saveTextWidth
    434     vertOffset = vertOffset + textHeight + 5
    435 
    436     return window
    437 end
    438 
    439 -- Leave the edit mode.
    440 function P.leaveEditMode()
    441     P.editMode = false
    442 
    443     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    444     --Replace all queues with FrameWindows
    445     for k,v in pairs(P.queueList) do
    446         if v ~= nil then
    447             -- Add the queue window to the root window to have it displayed again.
    448             root:addChildWindow(v.window)
    449             -- Set the size and position of the queue window to the size and position of the queue edit frame.
    450             v.window:setArea(v.edit:getArea())
    451             -- Destroy the edit frame.
    452             winMgr:destroyWindow(v.edit)
    453             v.edit = nil
    454         end
    455     end
    456 
    457     --Remove control window
    458     winMgr:destroyWindow(winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow"))
    459 end
    460 
    461 -- Is called after the sheet has been hidden.
    462 function P.afterHide()
    463     -- If we leave the edit mode we show the sheet again.
    464     if P.editMode then
    465         P.leaveEditMode()
    466         showMenuSheet(P.name, false, true)
    467     end
    468 end
    469 
    470 -- If the button to save the targets of a queue has been clicked.
    471 function P.saveTargets_clicked(e)
    472     local we = CEGUI.toWindowEventArgs(e)
    473     local name = we.window:getName()
    474 
    475     local match = string.gmatch(name, "EditMode/.*/Targets/Save")
    476     local nameStr = match()
    477     local queueName = string.sub(nameStr, 10, string.len(nameStr)-13)
    478 
    479     local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets")
    480     local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets/Save")
    481     local width = window:getWidth():asAbsolute(1)
    482 
    483     local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
    484     -- Set the new targets.
    485     queue:setTargets(window:getText())
    486     local targets = queue:getTargets()
    487 
    488     window:setText(targets)
    489     P.sampleWindow:setText(targets)
    490     local size = getMinTextSize(P.sampleWindow)
    491     -- Adjust the width of the targets field.
    492     window:setWidth(CEGUI.UDim(0, size[2]*2+20))
    493     -- Adjust the position of the save button after the targets field.
    494     save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
    495 end
    496 
    497 -- If the button to save the size if a queue has been clicked.
    498 function P.saveSize_clicked(e)
    499     local we = CEGUI.toWindowEventArgs(e)
    500     local name = we.window:getName()
    501 
    502     local match = string.gmatch(name, "EditMode/.*/Size/Save")
    503     local nameStr = match()
    504     local queueName = string.sub(nameStr, 10, string.len(nameStr)-10)
    505 
    506     local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size")
    507     local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size/Save")
    508     local width = window:getWidth():asAbsolute(1)
    509 
    510     local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
    511     -- Set the new size.
    512     queue:setMaxSize(tonumber(window:getText()))
    513     local maxSize = queue:getMaxSize()
    514 
    515     window:setText(maxSize)
    516     P.sampleWindow:setText(maxSize)
    517     local size = getMinTextSize(P.sampleWindow)
    518     -- Adjust the width of the size field.
    519     window:setWidth(CEGUI.UDim(0, size[2]*2+20))
    520     -- Adjust the position of the save button after the size field.
    521     save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
    522 end
    523 
    524 -- If the button to save the display time if a queue has been clicked.
    525 function P.saveDisplayTime_clicked(e)
    526     local we = CEGUI.toWindowEventArgs(e)
    527     local name = we.window:getName()
    528 
    529     local match = string.gmatch(name, "EditMode/.*/DisplayTime/Save")
    530     local nameStr = match()
    531     local queueName = string.sub(nameStr, 10, string.len(nameStr)-17)
    532 
    533     local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime")
    534     local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime/Save")
    535     local width = window:getWidth():asAbsolute(1)
    536 
    537     local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
    538     -- Set the new display time.
    539     queue:setDisplayTime(tonumber(window:getText()))
    540     local time = queue:getDisplayTime()
    541 
    542     window:setText(time)
    543     P.sampleWindow:setText(time)
    544     local size = getMinTextSize(P.sampleWindow)
    545     -- Adjust the width of the display time field.
    546     window:setWidth(CEGUI.UDim(0, size[2]*2+20))
    547     -- Adjust the position of the save button after the display time field.
    548     save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
    549 end
    550 
    551 -- if the button to create a new queue has been clicked.
    552 function P.createNewQueue_clicked(e)
    553     local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
    554     local name = window:getText()
    555 
    556     local queue = P.queueList[name]
    557     -- Test if a queue with that name already exists.
    558     if queue ~= nil then
    559         window:setText("Queue with that name already exists.")
    560         return
    561     end
    562 
    563     -- Creates the new queue.
    564     orxonox.NotificationManager:getInstance():createQueue(name)
    565 
    566     queue = P.queueList[name]
    567     if queue == nil then
    568         return
    569     end
    570 
    571     -- Create the frame that represents the queue in edit mode, since that's what we're in.
    572     local frame = P.createQueueEditFrame(name)
    573     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    574     -- Remove the queue window from the root window, since we're in edit mode.
    575     root:removeChildWindow(queue.window)
    576     -- Set the frame window size and position to that of the queue window.
    577     frame:setArea(queue.window:getArea())
    578     queue.edit = frame
    579 
    580     -- Reset the text to create a new queue.
    581     window:setText("")
    582 end
    583 
    584 -- If the button to leave the edit mode has been clicked.
    585 function P.leaveEditMode_clicked(e)
    586     hideMenuSheet(P.name)
    587 end
    588 
    589 -- If the button to close the queue has been clicked.
    590 function P.closeQueue_clicked(e)
    591     local we = CEGUI.toWindowEventArgs(e)
    592     local name = we.window:getName()
    593 
    594     local match = string.gmatch(name, "EditMode/.*")
    595     local nameStr = match()
    596     local queueName = string.sub(nameStr, 10, string.len(nameStr))
    597 
    598     -- Destroy the frame window,
    599     winMgr:destroyWindow(P.queueList[queueName].edit)
    600     P.queueList[queueName].edit = nil
    601     -- Destroy the queue.
    602     orxonox.NotificationManager:getInstance():getQueue(queueName):destroy()
    603 end
    604 
    605249-- Helper function. Returns height a queue needs to have to display 'size' items.
    606250function P.queueHeightHelper(queue, size)
  • 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.