Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7395


Ignore:
Timestamp:
Sep 9, 2010, 10:59:01 PM (14 years ago)
Author:
dafrick
Message:

Finished EditMode, needs some polish (no not the language…) though.
Took better advantage of lua tables in NotificationLayer.lua
Fixed a lot of bugs, it really is a miracle that the Notifications worked as well as they did.

Location:
code/branches/notifications
Files:
10 edited

Legend:

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

    r6748 r7395  
    4040end
    4141
     42-- Override this function if you need to do work just after the sheet has been hidden
     43function P:afterHide()
     44end
     45
    4246function P:load()
    4347    -- Load the layout that describes the sheet
  • code/branches/notifications/data/gui/scripts/MiscConfigMenu.lua

    r7284 r7395  
    5151    table.insert(P.nameList, "Number of Bots")
    5252    table.insert(P.nameList, "UnderAttack: game time")
    53     table.insert(P.nameList, "TeamDeathmatch: Numer of teams")
     53    table.insert(P.nameList, "TeamDeathmatch: Number of teams")
    5454    table.insert(P.nameList, "Playername")
    5555    table.insert(P.nameList, "Chat: display time")
  • code/branches/notifications/data/gui/scripts/NotificationLayer.lua

    r7362 r7395  
    11-- NotificationLayer.lua
    22
    3 local P = createMenuSheet("NotificationLayer")
     3local P = createMenuSheet("NotificationLayer", true, TriBool.True, TriBool.True)
    44
    55P.queueList = {}
    6 P.nameList = {}
    7 P.visible = nil
    86P.editMode = false
    9 P.editList = {}
     7
     8P.sampleWindow = nil
     9
     10function P.onLoad()
     11    orxonox.NotificationManager:getInstance():loadQueues()
     12    P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/SampleWindow")
     13end
    1014
    1115function P.createQueue(name, size)
     
    1822    queue:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, 0), CEGUI.UDim(0, P.queueHeightHelper(queue, size))))
    1923
    20     P.setVisible(queue, false)
    21 
    22     table.insert(P.queueList, queue)
    23     table.insert(P.nameList, name)
    24     --TODO: Check name for uniqueness.
     24    local queueTuple =
     25    {
     26        ["window"]  = queue,
     27        ["name"]    = name,
     28        ["edit"]    = nil,
     29        ["visible"] = false
     30    }
     31
     32    P.queueList[name] = queueTuple -- name access
     33    P.setVisible(queueTuple, false)
    2534end
    2635
    2736function P.removeQueue(name)
    28     local queue = nil
    29 
    30     for k,v in pairs(P.nameList) do
    31         if v == name then
    32             P.nameList[k] = nil
    33             queue = P.queueList[k]
    34             P.queueList[k] = nil
    35             break
    36         end
    37     end
     37    local queue = P.queueList[name]
    3838
    3939    if queue ~= nil then
    40         winMgr:destroyWindow(queue)
    41     end
     40        winMgr:destroyWindow(queue.window)
     41    end
     42    queue = nil
    4243end
    4344
    4445function P.pushNotification(queueName, notification)
    45     local queue = P.nameToQueueHelper(queueName)
    46     if queue == nil then
    47         cout(0, "Queue is nil!")
     46    local queue = P.queueList[queueName]
     47    if queue == nil then
     48        cout(0, "0Queue is nil! " .. queueName)
    4849        return
    4950    end
    5051    item = CEGUI.createListboxTextItem(notification)
    51     local listbox = CEGUI.toListbox(queue)
     52    local listbox = CEGUI.toListbox(queue.window)
    5253    if listbox:getItemCount() == 0 then
    5354        listbox:addItem(item)
     
    5657    end
    5758
    58     if P.visible == false then
     59    if queue.visible == false then
    5960        P.setVisible(queue, true)
    6061    end
     
    6263
    6364function P.popNotification(queueName)
    64     local queue = P.nameToQueueHelper(queueName)
    65     if queue == nil then
    66         cout(0, "Queue is nil!")
    67         return
    68     end
    69     local listbox = CEGUI.toListbox(queue)
     65    local queue = P.queueList[queueName]
     66    if queue == nil then
     67        cout(0, "1Queue is nil! " .. queueName)
     68        return
     69    end
     70    local listbox = CEGUI.toListbox(queue.window)
    7071    listbox:removeItem(listbox:getListboxItemFromIndex(listbox:getItemCount()-1))
    7172
     
    7677
    7778function P.removeNotification(queueName, index)
    78     local queue = P.nameToQueueHelper(queueName)
    79     if queue == nil then
    80         cout(0, "Queue is nil!")
    81         return
    82     end
    83     local listbox = CEGUI.toListbox(queue)
     79    local queue = P.queueList[queueName]
     80    if queue == nil then
     81        cout(0, "2Queue is nil! " .. queueName)
     82        return
     83    end
     84    local listbox = CEGUI.toListbox(queue.window)
    8485    listbox:removeItem(listbox:getListboxItemFromIndex(tonumber(index)))
    8586
     
    9091
    9192function P.clearQueue(name)
    92     local queue = P.nameToQueueHelper(name)
    93     if queue == nil then
    94         cout(0, "Queue is nil!")
    95         return
    96     end
    97     local listbox = CEGUI.toListbox(queue)
    98     CEGUI.toListbox(queue):resetList()
     93    local queue = P.queueList[name]
     94    if queue == nil then
     95        cout(0, "3Queue is nil! " .. name)
     96        return
     97    end
     98    local listbox = CEGUI.toListbox(queue.window)
     99    CEGUI.toListbox(queue.window):resetList()
    99100
    100101    P.setVisible(queue, false)
    101102end
    102103
    103 function P.changePosition(name, xPos, yPos)
    104     local queue = P.nameToQueueHelper(name)
    105     if queue == nil then
    106         cout(0, "Queue is nil!")
    107         return
    108     end
    109     queue:setPosition(CEGUI.UVector2(CEGUI.UDim(tonumber(xPos), 0), CEGUI.UDim(tonumber(yPos), 0)))
    110     queue:setWidth(CEGUI.UDim(1.0, -xPos))
    111 end
    112 
    113104function P.changeSize(name, size)
    114     local queue = P.nameToQueueHelper(name)
    115     if queue == nil then
    116         cout(0, "Queue is nil!")
    117         return
    118     end
    119     queue:setHeight(CEGUI.UDim(0, P.queueHeightHelper(queue, size)))
     105    local queue = P.queueList[name]
     106    if queue == nil then
     107        cout(0, "5Queue is nil! " .. name)
     108        return
     109    end
     110    queue.window:setHeight(CEGUI.UDim(0, P.queueHeightHelper(queue.window, size)))
    120111end
    121112
    122113function P.setVisible(queue, visible)
    123     queue:setVisible(visible)
    124     P.visible = visible
     114    if queue == nil then
     115        cout(0, "6Queue is nil! " .. queue.name)
     116        return
     117    end
     118    queue.window:setVisible(visible)
     119    queue.visible = visible
    125120end
    126121
    127122function P.enterEditMode()
    128123    P.editMode = true
     124
     125    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
     126
     127    --Add control frame window.
     128    local window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/ControlWindow")
     129    local frame = tolua.cast(window, "CEGUI::FrameWindow")
     130    frame:setCloseButtonEnabled(false)
     131    frame:setText("NotificationLayer Control Window")
     132    frame:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.2, 0)))
     133    root:addChildWindow(window)
     134    local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/ScrollingPane")
     135    pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30)))
     136    pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26)))
     137    window:addChildWindow(pane)
     138
     139    vertOffset = 0
     140    horzOffset = 0
     141    local newQueueTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueTitle")
     142    newQueueTitle:setText("Create a new NotificationQueue:")
     143    local size = getMinTextSize(newQueueTitle)
     144    local textHeight = size[1]
     145    newQueueTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
     146    newQueueTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     147    pane:addChildWindow(newQueueTitle)
     148    horzOffset = horzOffset + size[2] + 5
     149    local newQueueName = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
     150    newQueueName:setProperty("ReadOnly", "set:False")
     151    newQueueName:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
     152    newQueueName:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     153    horzOffset = horzOffset + size[2] + 5
     154    pane:addChildWindow(newQueueName)
     155    local create = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/CreateNewQueue")
     156    create:setText("create")
     157    P.sampleWindow:setText("create")
     158    size = getMinTextSize(P.sampleWindow)
     159    create:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight)))
     160    create:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     161    orxonox.GUIManager:subscribeEventHelper(create, "Clicked", P.name .. ".createNewQueue_clicked")
     162    pane:addChildWindow(create)
     163    horzOffset = horzOffset + size[2]+20 + 5
     164    vertOffset = vertOffset + textHeight + 5
     165
     166    horzOffset = 0
     167    local leave = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/LeaveEditModeButton")
     168    leave:setText("leave Edit Mode")
     169    P.sampleWindow:setText("leave Edit Mode")
     170    size = getMinTextSize(P.sampleWindow)
     171    leave:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight)))
     172    leave:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     173    orxonox.GUIManager:subscribeEventHelper(leave, "Clicked", P.name .. ".leaveEditMode_clicked")
     174    pane:addChildWindow(leave)
     175    horzOffset = horzOffset + size[2]+20 + 5
     176    vertOffset = vertOffset + textHeight + 5
     177
     178    --Replace all queues with FrameWindows
     179    for k,v in pairs(P.queueList) do
     180        if v ~= nil then
     181            local queue = P.queueList[k]
     182            root:removeChildWindow(queue.window)
     183           
     184            local window = P.createQueueEditFrame(queue.name)
     185            window:setArea(queue.window:getArea())
     186           
     187            queue.edit = window
     188        end
     189    end
     190end
     191
     192function P.createQueueEditFrame(name)
     193    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
     194    window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. name)
     195    local frame = tolua.cast(window, "CEGUI::FrameWindow")
     196    frame:setCloseButtonEnabled(false)
     197    frame:setText("NotificationQueue \"" .. name .. "\"")
     198    root:addChildWindow(window)
     199    local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/ScrollingPane")
     200    pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30)))
     201    pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26)))
     202    window:addChildWindow(pane)
     203
     204    local horzOffset = 0
     205    local vertOffset = 0
     206
     207    local targetsTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/TargetsTitle")
     208    targetsTitle:setText("Targets:")
     209    local size = getMinTextSize(targetsTitle)
     210    local textHeight = size[1]
     211    targetsTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
     212    targetsTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     213    pane:addChildWindow(targetsTitle)
     214    horzOffset = horzOffset + size[2] + 5
     215    local targets = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/Targets")
     216    targets:setProperty("ReadOnly", "set:False")
     217    local targetsText = orxonox.NotificationManager:getInstance():getQueue(name):getTargets()
     218    targets:setText(targetsText)
     219    P.sampleWindow:setText(targetsText)
     220    size = getMinTextSize(P.sampleWindow)
     221    targets:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
     222    targets:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     223    cout(0, horzOffset .. "|" .. targets:getXPosition():asAbsolute(1) .. "|" .. size[2]*2+20)
     224    horzOffset = horzOffset + size[2]*2+20 + 5
     225    pane:addChildWindow(targets)
     226    local save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/Targets/Save")
     227    save:setText("save")
     228    P.sampleWindow:setText("save")
     229    size = getMinTextSize(P.sampleWindow)
     230    local saveTextWidth = size[2]+20
     231    save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
     232    save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     233    cout(0, horzOffset .. "|" .. save:getXPosition():asAbsolute(1))
     234    orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveTargets_clicked")
     235    pane:addChildWindow(save)
     236    horzOffset = horzOffset + saveTextWidth
     237    vertOffset = vertOffset + textHeight + 5
     238
     239    horzOffset = 0
     240    local sizeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/SizeTitle")
     241    sizeTitle:setText("Size:")
     242    size = getMinTextSize(sizeTitle)
     243    sizeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
     244    sizeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     245    pane:addChildWindow(sizeTitle)
     246    horzOffset = horzOffset + size[2] + 5
     247    local queueSize = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/Size")
     248    queueSize:setProperty("ReadOnly", "set:False")
     249    local maxSize = orxonox.NotificationManager:getInstance():getQueue(name):getMaxSize()
     250    queueSize:setText(maxSize)
     251    P.sampleWindow:setText(maxSize)
     252    size = getMinTextSize(P.sampleWindow)
     253    queueSize:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
     254    queueSize:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     255    horzOffset = horzOffset + size[2]*2+20 + 5
     256    pane:addChildWindow(queueSize)
     257    save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/Size/Save")
     258    save:setText("save")
     259    P.sampleWindow:setText("save")
     260    size = getMinTextSize(P.sampleWindow)
     261    local saveTextWidth = size[2]+20
     262    save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
     263    save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     264    orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveSize_clicked")
     265    pane:addChildWindow(save)
     266    horzOffset = horzOffset + saveTextWidth
     267    vertOffset = vertOffset + textHeight + 5
     268
     269    horzOffset = 0
     270    local displayTimeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/DisplayTimeTitle")
     271    displayTimeTitle:setText("Display time:")
     272    size = getMinTextSize(displayTimeTitle)
     273    displayTimeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
     274    displayTimeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     275    pane:addChildWindow(displayTimeTitle)
     276    horzOffset = horzOffset + size[2] + 5
     277    local displayTime = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/DisplayTime")
     278    displayTime:setProperty("ReadOnly", "set:False")
     279    local time = orxonox.NotificationManager:getInstance():getQueue(name):getDisplayTime()
     280    displayTime:setText(time)
     281    P.sampleWindow:setText(time)
     282    size = getMinTextSize(P.sampleWindow)
     283    displayTime:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
     284    displayTime:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     285    horzOffset = horzOffset + size[2]*2+20 + 5
     286    pane:addChildWindow(displayTime)
     287    save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/DisplayTime/Save")
     288    save:setText("save")
     289    P.sampleWindow:setText("save")
     290    size = getMinTextSize(P.sampleWindow)
     291    local saveTextWidth = size[2]+20
     292    save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
     293    save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
     294    orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveDisplayTime_clicked")
     295    pane:addChildWindow(save)
     296    horzOffset = horzOffset + saveTextWidth
     297    vertOffset = vertOffset + textHeight + 5
     298
     299    return window
     300end
     301
     302function P.leaveEditMode()
     303    P.editMode = false
    129304
    130305    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
     
    132307    for k,v in pairs(P.queueList) do
    133308        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             root:addChildWindow(frame)
    138             P.editList[k] = frame
     309            root:addChildWindow(v.window)
     310            v.window:setArea(v.edit:getArea())
     311            winMgr:destroyWindow(v.edit)
     312            v.edit = nil
    139313        end
    140314    end
    141 end
    142 
    143 function P.leaveEditMode()
    144     P.editMode = false
    145 
    146     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    147     --Replace all queues with FrameWindows
    148     for k,v in pairs(P.queueList) do
    149         if v ~= nil then
    150             root:addChildWindow(v)
    151             v:setArea(P.editList[k]:getArea())
    152             winMgr:destroyWindow(P.editList[k])
    153             P.editList[k] = nil
    154         end
    155     end
    156 
    157     showMenuSheet(P.name, false, true)
    158 end
    159 
    160 function P.onHide()
     315
     316    --Remove control window
     317    winMgr:destroyWindow(winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow"))
     318end
     319
     320function P.afterHide()
    161321    if P.editMode then
    162322        P.leaveEditMode()
    163     end
    164 end
    165 
    166 function P.nameToQueueHelper(name)
    167     local queue = nil
    168     for k,v in pairs(P.nameList) do
    169         if v == name then
    170             queue = P.queueList[k]
    171             break
    172         end
    173     end
    174     return queue
     323        showMenuSheet(P.name, false, true)
     324    end
     325end
     326
     327function P. saveTargets_clicked(e)
     328    local we = CEGUI.toWindowEventArgs(e)
     329    local name = we.window:getName()
     330
     331    local match = string.gmatch(name, "EditMode/.*/Targets/Save")
     332    local nameStr = match()
     333    local queueName = string.sub(nameStr, 10, string.len(nameStr)-13)
     334
     335    local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets")
     336    local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets/Save")
     337    local width = window:getXPosition():asAbsolute(1)
     338
     339    local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
     340    queue:setTargets(window:getText())
     341    local targets = queue:getTargets()
     342
     343    window:setText(targets)
     344    P.sampleWindow:setText(targets)
     345    local size = getMinTextSize(P.sampleWindow)
     346    window:setWidth(CEGUI.UDim(0, size[2]*2+20))
     347    cout(0, width .. "|" .. size[2]*2+20 .. "|" .. window:getWidth():asAbsolute(1) .. "|" .. save:getXPosition():asAbsolute(1))
     348    save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
     349end
     350
     351function P. saveSize_clicked(e)
     352    local we = CEGUI.toWindowEventArgs(e)
     353    local name = we.window:getName()
     354
     355    local match = string.gmatch(name, "EditMode/.*/Size/Save")
     356    local nameStr = match()
     357    local queueName = string.sub(nameStr, 10, string.len(nameStr)-10)
     358
     359    local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size")
     360    local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size/Save")
     361    local width = window:getXPosition():asAbsolute(1)
     362
     363    local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
     364    queue:setMaxSize(tonumber(window:getText()))
     365    local maxSize = queue:getMaxSize()
     366
     367    window:setText(maxSize)
     368    P.sampleWindow:setText(maxSize)
     369    local size = getMinTextSize(P.sampleWindow)
     370    window:setWidth(CEGUI.UDim(0, size[2]*2+20))
     371    save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
     372end
     373
     374function P. saveDisplayTime_clicked(e)
     375    local we = CEGUI.toWindowEventArgs(e)
     376    local name = we.window:getName()
     377
     378    local match = string.gmatch(name, "EditMode/.*/DisplayTime/Save")
     379    local nameStr = match()
     380    local queueName = string.sub(nameStr, 10, string.len(nameStr)-17)
     381
     382    local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime")
     383    local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime/Save")
     384    local width = window:getXPosition():asAbsolute(1)
     385
     386    local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
     387    queue:setDisplayTime(tonumber(window:getText()))
     388    local time = queue:getDisplayTime()
     389
     390    window:setText(time)
     391    P.sampleWindow:setText(time)
     392    local size = getMinTextSize(P.sampleWindow)
     393    window:setWidth(CEGUI.UDim(0, size[2]*2+20))
     394    save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
     395end
     396
     397function P.createNewQueue_clicked(e)
     398    local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
     399    local name = window:getText()
     400    orxonox.NotificationManager:getInstance():createQueue(name)
     401
     402    local queue = P.queueList[name]
     403    if queue == nil then
     404        cout(0, "7Queue is nil! " .. name)
     405        return
     406    end
     407   
     408    local frame = P.createQueueEditFrame(name)
     409    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
     410    root:removeChildWindow(queue.window)
     411    frame:setArea(queue.window:getArea())
     412    queue.edit = frame
     413   
     414    window:setText("")
     415end
     416
     417function P.leaveEditMode_clicked(e)
     418    hideMenuSheet(P.name)
    175419end
    176420
     
    188432
    189433return P
    190 
  • code/branches/notifications/data/gui/scripts/SheetManager.lua

    r7342 r7395  
    185185        hideCursor()
    186186    end
     187
     188    sheetTuple.sheet:afterHide()
    187189end
    188190
  • code/branches/notifications/src/modules/notifications/CMakeLists.txt

    r7354 r7395  
    1313  TOLUA_FILES
    1414    NotificationManager.h
     15    NotificationQueue.h
    1516  PCH_FILE
    1617    NotificationsPrecompiledHeaders.h
  • code/branches/notifications/src/modules/notifications/NotificationManager.cc

    r7362 r7395  
    2828
    2929/**
    30     @file
     30    @file NotificationManager.cc
    3131    @brief Implementation of the NotificationManager class.
    3232*/
     
    4343#include "NotificationQueue.h"
    4444
     45#include "ToluaBindNotifications.h"
     46
    4547namespace orxonox
    4648{
     
    4951    const std::string NotificationManager::NONE("none");
    5052
     53    // Register tolua_open function when loading the library.
     54    DeclareToluaInterface(Notifications);
     55
    5156    ManageScopedSingleton(NotificationManager, ScopeID::Graphics, false);
    5257
     
    6570
    6671        ModifyConsoleCommand("enterEditMode").setObject(this);
    67 
    68         if(GameMode::showsGraphics())
    69         {
    70             GUIManager::getInstance().loadGUI("NotificationLayer");
    71 
    72             // Create first queue:
    73             this->queues_.push_back(new NotificationQueue("all"));
    74         }
     72       
     73        COUT(3) << "NotificatioManager created." << std::endl;
    7574    }
    7675
     
    8281    {
    8382        ModifyConsoleCommand("enterEditMode").setObject(NULL);
     83
     84        for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
     85            it->second->destroy();
     86       
     87        COUT(3) << "NotificationManager destroyed." << std::endl;
    8488    }
    8589
    8690    void NotificationManager::preDestroy(void)
    8791    {
    88         for(std::vector<NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++)
    89             (*it)->destroy();
     92        for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); )
     93        {
     94            NotificationQueue* queue = (*it).second;
     95            it++;
     96            queue->destroy();
     97        }
    9098        this->queues_.clear();
    9199    }
     
    101109    bool NotificationManager::registerNotification(Notification* notification)
    102110    {
    103 
    104         if(notification == NULL) //!< A NULL-Notification cannot be registered.
     111        if(notification == NULL) // A NULL-Notification cannot be registered.
    105112            return false;
    106113
    107114        std::time_t time = std::time(0); //TODO: Doesn't this expire? //!< Get current time.
    108115
    109         this->allNotificationsList_.insert(std::pair<std::time_t,Notification*>(time,notification));
    110 
    111         if(notification->getSender() == NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
     116        this->allNotificationsList_.insert(std::pair<std::time_t, Notification*>(time, notification));
     117
     118        if(notification->getSender() == NotificationManager::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
    112119            return true;
    113120
    114121        bool all = false;
    115         if(notification->getSender() == ALL) // If all are the sender, then the Notifications is added to every NotificationListener.
     122        if(notification->getSender() == NotificationManager::ALL) // If all are the sender, then the Notifications is added to every NotificationListener.
    116123            all = true;
    117124
     
    119126        for(std::map<NotificationListener*,int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) // Iterate through all listeners.
    120127        {
    121             std::set<std::string> set = it->first->getTargetsSet();
    122             if(all || set.find(notification->getSender()) != set.end() || set.find(ALL) != set.end()) //TODO: Make sure this works.
     128            std::set<std::string, NotificationListenerStringCompare> set = it->first->getTargetsSet();
     129            bool bAll = set.find(NotificationManager::ALL) != set.end();
     130            if(all || bAll || set.find(notification->getSender()) != set.end()) //TODO: Make sure this works.
    123131            {
    124                 this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); // Insert the Notification in the Notifications list of the current NotificationListener.
     132                if(!bAll)
     133                {
     134                    this->notificationLists_[it->second]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the Notifications list of the current NotificationListener.
     135                }
    125136                it->first->update(notification, time); // Update the listener.
    126137                std::map<Notification*, unsigned int>::iterator counterIt = this->listenerCounter_.find(notification);
     
    132143        }
    133144
    134         COUT(4) << "Notification registered with the NotificationManager." << std::endl;
     145        COUT(4) << "Notification (&" << notification << ") registered with the NotificationManager." << std::endl;
    135146
    136147        return true;
     
    154165            this->listenerCounter_[notification] = this->listenerCounter_[notification] - 1;
    155166
    156         // If the Notification is no longer present in any of the NotificationListeners it can be removed from the map of all Notifications and be destroyed.
    157         if(this->listenerCounter_[notification] == (unsigned int) 0)
    158         {
    159             this->removeNotification(notification, this->allNotificationsList_);
    160             this->listenerCounter_.erase(notification);
    161             notification->destroy();
    162         }
    163 
    164         COUT(4) << "Notification unregistered with the NotificationManager." << std::endl;
     167        COUT(4) << "Notification (&" << notification << ")unregistered with the NotificationManager from listener (&" << listener << ")" << std::endl;
    165168    }
    166169
     
    175178        Returns true if successful.
    176179    */
    177     //TODO: Needed?
    178180    bool NotificationManager::removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map)
    179181    {
     
    206208        this->listenerList_[listener] = index; // Add the NotificationListener to the list of listeners.
    207209
    208         std::set<std::string> set = listener->getTargetsSet(); //TODO: Does this work?
     210        std::set<std::string, NotificationListenerStringCompare> set = listener->getTargetsSet();
    209211
    210212        // If all senders are the target of the listener, then the list of notification for that specific listener is te same as the list of all Notifications.
    211         if(set.find(ALL) != set.end())
    212         {
     213        bool bAll = set.find(NotificationManager::ALL) != set.end();
     214        std::multimap<std::time_t, Notification*> map;
     215        if(bAll)
    213216            this->notificationLists_[index] = &this->allNotificationsList_;
    214             COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl;
    215             return true;
    216         }
    217 
    218         this->notificationLists_[index] = new std::multimap<std::time_t,Notification*>;
    219         std::multimap<std::time_t,Notification*> map = *this->notificationLists_[index];
     217        else
     218        {
     219            this->notificationLists_[index] = new std::multimap<std::time_t, Notification*>;
     220            map = *this->notificationLists_[index];
     221        }
    220222
    221223        // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener.
    222         for(std::multimap<std::time_t,Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
    223         {
    224             if(set.find(it->second->getSender()) != set.end()) // Checks whether the overlay has the sender of the current notification as target.
     224        for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
     225        {
     226            if(bAll || set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current notification as target.
    225227            {
    226                 map.insert(std::pair<std::time_t, Notification*>(it->first, it->second));
     228                if(!bAll)
     229                    map.insert(std::pair<std::time_t, Notification*>(it->first, it->second));
    227230                std::map<Notification*, unsigned int>::iterator counterIt = this->listenerCounter_.find(it->second);
    228231                if(counterIt == this->listenerCounter_.end())
     
    288291            return false;
    289292
    290         std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // The Notifications for the input NotificationListener.
    291 
    292         if(notifications == NULL) // Returns NULL, if there are no Notifications.
    293             return true;
     293        std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // The Notifications for the input NotificationListener.
     294
     295        if(notifications == NULL) // Returns false, if there are no Notifications.
     296            return false;
    294297
    295298        std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
    296299        itLowest = notifications->lower_bound(timeFrameStart);
    297         itHighest = notifications->upper_bound(timeFrameStart);
     300        itHighest = notifications->upper_bound(timeFrameEnd);
    298301
    299302        for(it = itLowest; it != itHighest; it++) // Iterate through the Notifications from the start of the time Frame to the end of it.
    300         {
    301             map->insert(std::pair<std::time_t,Notification*>(it->first,it->second)); // Add the found Notifications to the map.
    302         }
     303            map->insert(std::pair<std::time_t, Notification*>(it->first,it->second)); // Add the found Notifications to the map.
    303304
    304305        return true;
    305306    }
    306307
    307     void NotificationManager::createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime)
    308     {
    309         this->queues_.push_back(new NotificationQueue(name, targets, size, displayTime));
     308    void NotificationManager::loadQueues(void)
     309    {
     310        new NotificationQueue("all");
     311    }
     312
     313    void NotificationManager::createQueue(const std::string& name)
     314    {
     315        new NotificationQueue(name);
     316    }
     317
     318    NotificationQueue* NotificationManager::getQueue(const std::string & name)
     319    {
     320        std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.find(name);
     321        if(it == this->queues_.end())
     322            return NULL;
     323
     324        return (*it).second;
     325    }
     326
     327    bool NotificationManager::registerQueue(NotificationQueue* queue)
     328    {
     329        return this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;
     330    }
     331   
     332    void NotificationManager::unregisterQueue(NotificationQueue* queue)
     333    {
     334        this->queues_.erase(queue->getName());
    310335    }
    311336
  • code/branches/notifications/src/modules/notifications/NotificationManager.h

    r7354 r7395  
    2828
    2929/**
    30     @file
     30    @file NotificationManager.h
    3131    @brief Definition of the NotificationManager class.
    3232*/
     
    4040#include <map>
    4141#include <string>
    42 #include <vector>
    4342
    4443#include "util/Singleton.h"
     
    5554        Damian 'Mozork' Frick
    5655    */
    57     class _NotificationsExport NotificationManager  // tolua_export
     56    class _NotificationsExport NotificationManager // tolua_export
    5857        : public Singleton<NotificationManager>, public OrxonoxClass
    5958    { // tolua_export
     
    7574            void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager.
    7675
    77             bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationListener in a specified timeframe.
     76            bool getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationListener in a specified timeframe.
    7877
    7978            /**
     
    8483            @return Returns true if successful.
    8584            */
    86             bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, int timeDelay)
     85            bool getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int timeDelay)
    8786                { return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
    8887
    8988            void enterEditMode(void);
    9089
    91             void createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime); // tolua_export
     90            // tolua_begin
     91            void loadQueues(void);
     92           
     93            void createQueue(const std::string& name);
     94            orxonox::NotificationQueue* getQueue(const std::string & name);
     95            // tolua_end
     96
     97            bool registerQueue(NotificationQueue* queue);
     98            void unregisterQueue(NotificationQueue* queue);
    9299
    93100        private:
    94101            static NotificationManager* singletonPtr_s;
    95102
    96             std::vector<NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
     103            std::map<const std::string, NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
    97104
    98105            int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
    99106
    100             std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored.
    101             std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
    102             std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
     107            std::multimap<std::time_t, Notification*> allNotificationsList_; //!< Container where all notifications are stored.
     108            std::map<NotificationListener*, int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
     109            std::map<int,std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
    103110            std::map<Notification*, unsigned int> listenerCounter_; //!< A container to store the number of NotificationListeners a Notification is registered with.
    104111
  • code/branches/notifications/src/modules/notifications/NotificationQueue.cc

    r7354 r7395  
    3535
    3636#include <map>
     37#include <sstream>
    3738
    3839#include "core/CoreIncludes.h"
     
    6263        this->setDisplayTime(displayTime);
    6364
     65        bool queueRegistered = NotificationManager::getInstance().registerQueue(this);
     66        this->registered_ = true;
     67        if(!queueRegistered)
     68        {
     69            this->registered_ = false;
     70            COUT(1) << "Error: Notification Queue '" << this->getName() << "' could not be registered." << std::endl;
     71            return;
     72        }
     73
    6474        this->create();
    65 
    66         NotificationManager::getInstance().registerListener(this);
    67         this->registered_ = true;
     75       
     76        bool listenerRegistered = NotificationManager::getInstance().registerListener(this);
     77        if(!listenerRegistered)
     78        {
     79            this->registered_ = false;
     80            NotificationManager::getInstance().unregisterQueue(this);
     81            COUT(1) << "Error: Notification Queue '" << this->getName() << "' could not be registered." << std::endl;
     82            return;
     83        }
    6884
    6985        COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
     
    7793    {
    7894        this->targets_.clear();
    79         this->clear();
    8095
    8196        if(this->registered_)
     97        {
     98            this->clear();
     99           
    82100            NotificationManager::getInstance().unregisterListener(this);
     101            NotificationManager::getInstance().unregisterQueue(this);
     102        }
    83103    }
    84104
     
    100120    void NotificationQueue::create(void)
    101121    {
    102         GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
     122        GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() +  "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
    103123    }
    104124
     
    144164        }
    145165
    146         if(notifications->empty())
    147             return;
    148 
    149         for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) // Add all Notifications.
    150             this->push(it->second, it->first);
     166        if(!notifications->empty())
     167        {
     168            for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) // Add all Notifications.
     169            {
     170                this->push(it->second, it->first);
     171            }
     172        }
    151173
    152174        delete notifications;
    153175
    154         COUT(4) << "NotificationQueue '" << this->getName() << "' updated." << std::endl;
     176        COUT(3) << "NotificationQueue '" << this->getName() << "' updated." << std::endl; //TODO: Level 4.
    155177    }
    156178
     
    167189        this->push(notification, time);
    168190
    169         COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notification has been added." << std::endl;
     191        COUT(3) << "NotificationQueue '" << this->getName() << "' updated. A new Notification has been added." << std::endl; //TODO: Level 4.
    170192    }
    171193
     
    253275    bool NotificationQueue::setName(const std::string& name)
    254276    {
    255         //TODO: Test uniqueness of name.
    256277        this->name_ = name;
    257278        return true;
     
    268289    void NotificationQueue::setMaxSize(unsigned int size)
    269290    {
     291        if(this->maxSize_ == size)
     292            return;
     293       
    270294        this->maxSize_ = size;
    271295        this->sizeChanged();
     
    292316    void NotificationQueue::setDisplayTime(unsigned int time)
    293317    {
     318        if(this->displayTime_ == time)
     319            return;
     320
    294321        this->displayTime_ = time;
    295         this->update();
     322
     323        if(this->registered_)
     324            this->update();
    296325    }
    297326
     
    299328    @brief
    300329        Produces all targets concatinated as string, with kommas (',') as seperators.
    301     @param string
    302         Pointer to a string which will be used by the method to fill with the concatination of the targets.
    303     @return
    304         Returns true if successful.
    305     */
    306     bool NotificationQueue::getTargets(std::string* string) const
    307     {
    308         if(string == NULL)
    309         {
    310             COUT(4) << "Input string must have memory allocated." << std::endl;
    311             return false;
    312         }
    313         string->clear();
     330    @return
     331        Returns the targets as a string.
     332    */
     333    const std::string& NotificationQueue::getTargets(void) const
     334    {
     335        std::stringstream stream;
    314336        bool first = true;
    315         for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) // Iterate through the set of targets.
     337        for(std::set<std::string, NotificationListenerStringCompare>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) // Iterate through the set of targets.
    316338        {
    317339            if(!first)
    318                 *string += ',';
     340                stream << ',';
    319341            else
    320342                first = false;
    321             *string += *it;
    322         }
    323 
    324         return true;
     343            stream << *it;
     344        }
     345
     346        return *(new std::string(stream.str()));
    325347    }
    326348
     
    352374        }
    353375
     376        if(this->registered_)
     377        {
     378            NotificationManager::getInstance().unregisterListener(this);
     379            NotificationManager::getInstance().registerListener(this);
     380        }
     381
    354382        return true;
    355383    }
  • code/branches/notifications/src/modules/notifications/NotificationQueue.h

    r7354 r7395  
    4646#include "NotificationManager.h"
    4747
    48 namespace orxonox
    49 {
     48namespace orxonox // tolua_export
     49{ // tolua_export
    5050
    5151    //! Container to allow easy handling.
     
    6868        Damian 'Mozork' Frick
    6969    */
    70     class _NotificationsExport NotificationQueue : public Tickable, public NotificationListener
    71     {
     70    class _NotificationsExport NotificationQueue // tolua_export
     71        : public Tickable, public NotificationListener
     72    { // tolua_export
    7273
    7374        public:
     
    8081            void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue.
    8182
     83            // tolua_begin
    8284            /**
    8385            @brief Get the name of the NotificationQueue.
     
    8789                { return this->name_; }
    8890
     91            void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
    8992            /**
    9093            @brief Returns the maximum number of Notifications displayed.
     
    9396            inline unsigned int getMaxSize() const
    9497                { return this->maxSize_; }
     98
     99            void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
     100            /**
     101            @brief Returns the time interval the Notification is displayed.
     102            @return Returns the display time.
     103            */
     104            inline float getDisplayTime() const
     105                { return this->displayTime_; }
     106            // tolua_end
     107
    95108            /**
    96109            @brief Returns the current number of Notifications displayed.
     
    99112            inline unsigned int getSize() const
    100113                { return this->size_; }
    101             /**
    102             @brief Returns the time interval the Notification is displayed.
    103             @return Returns the display time.
    104             */
    105             inline float getDisplayTime() const
    106                 { return this->displayTime_; }
    107114
    108115            /**
     
    110117            @return Retuns a set of string holding the different targets.
    111118            */
    112             inline const std::set<std::string> & getTargetsSet()
     119            inline const std::set<std::string, NotificationListenerStringCompare> & getTargetsSet()
    113120                { return this->targets_; }
    114             bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
     121
     122            // tolua_begin
     123            bool setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
     124            const std::string& getTargets(void) const; //!< Returns a string consisting of the concatination of the targets.
     125            // tolua_end
    115126
    116127        private:
     
    124135            unsigned int displayTime_; //!< The time a Notification is displayed.
    125136
    126             std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
     137            std::set<std::string, NotificationListenerStringCompare> targets_; //!< The targets the Queue displays Notifications of.
    127138
    128139            std::multiset<NotificationContainer*, NotificationContainerCompare> ordering_; //!< The NotificationContainers ordered by the time they were registered. //TODO: Would set work as well?
     
    139150            bool setName(const std::string& name); //!< Sets the name of the NotificationQueue.
    140151
    141             void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
    142             void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
    143 
    144             bool setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
    145 
    146152            void sizeChanged(void); //!< Adjusts the NotificationQueue, when the maximum size has changed.
    147153
     
    152158            void clear(void); //!< Clears the queue by removing all Notifications.
    153159
    154     };
     160    }; // tolua_export
    155161
    156 }
     162} // tolua_export
    157163
    158164#endif /* _NotificationOverlay_H__ */
  • code/branches/notifications/src/orxonox/interfaces/NotificationListener.h

    r7163 r7395  
    4949    /**
    5050    @brief
     51        Struct that overloads the compare operation between two PickupIdentifier pointers.
     52    */
     53    //TODO:
     54    struct NotificationListenerStringCompare
     55    {
     56        bool operator() (const std::string& lhs, const std::string& rhs) const
     57            { return lhs.compare(rhs) < 0; }
     58    };
     59
     60    /**
     61    @brief
    5162        NotificationListener interface.
    5263    @author
     
    5970            virtual ~NotificationListener() {}
    6071
    61             virtual const std::set<std::string> & getTargetsSet() = 0;
     72            virtual const std::set<std::string, NotificationListenerStringCompare> & getTargetsSet() = 0;
    6273            virtual void update(void) = 0;
    6374            virtual void update(Notification* notification, const std::time_t & time) = 0;
Note: See TracChangeset for help on using the changeset viewer.