[Orxonox-commit 2690] r7395 - in code/branches/notifications: data/gui/scripts src/modules/notifications src/orxonox/interfaces
dafrick at orxonox.net
dafrick at orxonox.net
Thu Sep 9 22:59:01 CEST 2010
Author: dafrick
Date: 2010-09-09 22:59:01 +0200 (Thu, 09 Sep 2010)
New Revision: 7395
Modified:
code/branches/notifications/data/gui/scripts/GUISheet.lua
code/branches/notifications/data/gui/scripts/MiscConfigMenu.lua
code/branches/notifications/data/gui/scripts/NotificationLayer.lua
code/branches/notifications/data/gui/scripts/SheetManager.lua
code/branches/notifications/src/modules/notifications/CMakeLists.txt
code/branches/notifications/src/modules/notifications/NotificationManager.cc
code/branches/notifications/src/modules/notifications/NotificationManager.h
code/branches/notifications/src/modules/notifications/NotificationQueue.cc
code/branches/notifications/src/modules/notifications/NotificationQueue.h
code/branches/notifications/src/orxonox/interfaces/NotificationListener.h
Log:
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.
Modified: code/branches/notifications/data/gui/scripts/GUISheet.lua
===================================================================
--- code/branches/notifications/data/gui/scripts/GUISheet.lua 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/data/gui/scripts/GUISheet.lua 2010-09-09 20:59:01 UTC (rev 7395)
@@ -39,6 +39,10 @@
function P:onHide()
end
+-- Override this function if you need to do work just after the sheet has been hidden
+function P:afterHide()
+end
+
function P:load()
-- Load the layout that describes the sheet
self.window = winMgr:loadWindowLayout(self.name .. ".layout")
Modified: code/branches/notifications/data/gui/scripts/MiscConfigMenu.lua
===================================================================
--- code/branches/notifications/data/gui/scripts/MiscConfigMenu.lua 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/data/gui/scripts/MiscConfigMenu.lua 2010-09-09 20:59:01 UTC (rev 7395)
@@ -50,7 +50,7 @@
table.insert(P.nameList, "Autostart")
table.insert(P.nameList, "Number of Bots")
table.insert(P.nameList, "UnderAttack: game time")
- table.insert(P.nameList, "TeamDeathmatch: Numer of teams")
+ table.insert(P.nameList, "TeamDeathmatch: Number of teams")
table.insert(P.nameList, "Playername")
table.insert(P.nameList, "Chat: display time")
Modified: code/branches/notifications/data/gui/scripts/NotificationLayer.lua
===================================================================
--- code/branches/notifications/data/gui/scripts/NotificationLayer.lua 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/data/gui/scripts/NotificationLayer.lua 2010-09-09 20:59:01 UTC (rev 7395)
@@ -1,13 +1,17 @@
-- NotificationLayer.lua
-local P = createMenuSheet("NotificationLayer")
+local P = createMenuSheet("NotificationLayer", true, TriBool.True, TriBool.True)
P.queueList = {}
-P.nameList = {}
-P.visible = nil
P.editMode = false
-P.editList = {}
+P.sampleWindow = nil
+
+function P.onLoad()
+ orxonox.NotificationManager:getInstance():loadQueues()
+ P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/SampleWindow")
+end
+
function P.createQueue(name, size)
local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name)
@@ -17,56 +21,53 @@
queue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
queue:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, 0), CEGUI.UDim(0, P.queueHeightHelper(queue, size))))
- P.setVisible(queue, false)
+ local queueTuple =
+ {
+ ["window"] = queue,
+ ["name"] = name,
+ ["edit"] = nil,
+ ["visible"] = false
+ }
- table.insert(P.queueList, queue)
- table.insert(P.nameList, name)
- --TODO: Check name for uniqueness.
+ P.queueList[name] = queueTuple -- name access
+ P.setVisible(queueTuple, false)
end
function P.removeQueue(name)
- local queue = nil
+ local queue = P.queueList[name]
- for k,v in pairs(P.nameList) do
- if v == name then
- P.nameList[k] = nil
- queue = P.queueList[k]
- P.queueList[k] = nil
- break
- end
- end
-
if queue ~= nil then
- winMgr:destroyWindow(queue)
+ winMgr:destroyWindow(queue.window)
end
+ queue = nil
end
function P.pushNotification(queueName, notification)
- local queue = P.nameToQueueHelper(queueName)
+ local queue = P.queueList[queueName]
if queue == nil then
- cout(0, "Queue is nil!")
+ cout(0, "0Queue is nil! " .. queueName)
return
end
item = CEGUI.createListboxTextItem(notification)
- local listbox = CEGUI.toListbox(queue)
+ local listbox = CEGUI.toListbox(queue.window)
if listbox:getItemCount() == 0 then
listbox:addItem(item)
else
listbox:insertItem(item, listbox:getListboxItemFromIndex(0))
end
- if P.visible == false then
+ if queue.visible == false then
P.setVisible(queue, true)
end
end
function P.popNotification(queueName)
- local queue = P.nameToQueueHelper(queueName)
+ local queue = P.queueList[queueName]
if queue == nil then
- cout(0, "Queue is nil!")
+ cout(0, "1Queue is nil! " .. queueName)
return
end
- local listbox = CEGUI.toListbox(queue)
+ local listbox = CEGUI.toListbox(queue.window)
listbox:removeItem(listbox:getListboxItemFromIndex(listbox:getItemCount()-1))
if listbox:getItemCount() == 0 then
@@ -75,12 +76,12 @@
end
function P.removeNotification(queueName, index)
- local queue = P.nameToQueueHelper(queueName)
+ local queue = P.queueList[queueName]
if queue == nil then
- cout(0, "Queue is nil!")
+ cout(0, "2Queue is nil! " .. queueName)
return
end
- local listbox = CEGUI.toListbox(queue)
+ local listbox = CEGUI.toListbox(queue.window)
listbox:removeItem(listbox:getListboxItemFromIndex(tonumber(index)))
if listbox:getItemCount() == 0 then
@@ -89,57 +90,215 @@
end
function P.clearQueue(name)
- local queue = P.nameToQueueHelper(name)
+ local queue = P.queueList[name]
if queue == nil then
- cout(0, "Queue is nil!")
+ cout(0, "3Queue is nil! " .. name)
return
end
- local listbox = CEGUI.toListbox(queue)
- CEGUI.toListbox(queue):resetList()
+ local listbox = CEGUI.toListbox(queue.window)
+ CEGUI.toListbox(queue.window):resetList()
P.setVisible(queue, false)
end
-function P.changePosition(name, xPos, yPos)
- local queue = P.nameToQueueHelper(name)
+function P.changeSize(name, size)
+ local queue = P.queueList[name]
if queue == nil then
- cout(0, "Queue is nil!")
+ cout(0, "5Queue is nil! " .. name)
return
end
- queue:setPosition(CEGUI.UVector2(CEGUI.UDim(tonumber(xPos), 0), CEGUI.UDim(tonumber(yPos), 0)))
- queue:setWidth(CEGUI.UDim(1.0, -xPos))
+ queue.window:setHeight(CEGUI.UDim(0, P.queueHeightHelper(queue.window, size)))
end
-function P.changeSize(name, size)
- local queue = P.nameToQueueHelper(name)
+function P.setVisible(queue, visible)
if queue == nil then
- cout(0, "Queue is nil!")
+ cout(0, "6Queue is nil! " .. queue.name)
return
end
- queue:setHeight(CEGUI.UDim(0, P.queueHeightHelper(queue, size)))
+ queue.window:setVisible(visible)
+ queue.visible = visible
end
-function P.setVisible(queue, visible)
- queue:setVisible(visible)
- P.visible = visible
-end
-
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
+ 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
+ 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
- root:removeChildWindow(v)
- local frame = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. P.nameList[k])
- frame:setArea(v:getArea())
- root:addChildWindow(frame)
- P.editList[k] = frame
+ local queue = P.queueList[k]
+ root:removeChildWindow(queue.window)
+
+ local window = P.createQueueEditFrame(queue.name)
+ window:setArea(queue.window:getArea())
+
+ queue.edit = window
end
end
end
+function P.createQueueEditFrame(name)
+ local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
+ window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. name)
+ local frame = tolua.cast(window, "CEGUI::FrameWindow")
+ frame:setCloseButtonEnabled(false)
+ frame:setText("NotificationQueue \"" .. name .. "\"")
+ root:addChildWindow(window)
+ local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/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
+
+ local targetsTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/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/" .. name .. "/Targets")
+ targets:setProperty("ReadOnly", "set:False")
+ local targetsText = orxonox.NotificationManager:getInstance():getQueue(name):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)))
+ cout(0, horzOffset .. "|" .. targets:getXPosition():asAbsolute(1) .. "|" .. size[2]*2+20)
+ horzOffset = horzOffset + size[2]*2+20 + 5
+ pane:addChildWindow(targets)
+ local save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/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)))
+ cout(0, horzOffset .. "|" .. save:getXPosition():asAbsolute(1))
+ orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveTargets_clicked")
+ pane:addChildWindow(save)
+ horzOffset = horzOffset + saveTextWidth
+ vertOffset = vertOffset + textHeight + 5
+
+ horzOffset = 0
+ local sizeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/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/" .. name .. "/Size")
+ queueSize:setProperty("ReadOnly", "set:False")
+ local maxSize = orxonox.NotificationManager:getInstance():getQueue(name):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/" .. name .. "/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
+ local displayTimeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. name .. "/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/" .. name .. "/DisplayTime")
+ displayTime:setProperty("ReadOnly", "set:False")
+ local time = orxonox.NotificationManager:getInstance():getQueue(name):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/" .. name .. "/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
+
function P.leaveEditMode()
P.editMode = false
@@ -147,33 +306,118 @@
--Replace all queues with FrameWindows
for k,v in pairs(P.queueList) do
if v ~= nil then
- root:addChildWindow(v)
- v:setArea(P.editList[k]:getArea())
- winMgr:destroyWindow(P.editList[k])
- P.editList[k] = nil
+ root:addChildWindow(v.window)
+ v.window:setArea(v.edit:getArea())
+ winMgr:destroyWindow(v.edit)
+ v.edit = nil
end
end
- showMenuSheet(P.name, false, true)
+ --Remove control window
+ winMgr:destroyWindow(winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow"))
end
-function P.onHide()
+function P.afterHide()
if P.editMode then
P.leaveEditMode()
+ showMenuSheet(P.name, false, true)
end
end
-function P.nameToQueueHelper(name)
- local queue = nil
- for k,v in pairs(P.nameList) do
- if v == name then
- queue = P.queueList[k]
- break
- end
+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:getXPosition():asAbsolute(1)
+
+ local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
+ queue:setTargets(window:getText())
+ local targets = queue:getTargets()
+
+ window:setText(targets)
+ P.sampleWindow:setText(targets)
+ local size = getMinTextSize(P.sampleWindow)
+ window:setWidth(CEGUI.UDim(0, size[2]*2+20))
+ cout(0, width .. "|" .. size[2]*2+20 .. "|" .. window:getWidth():asAbsolute(1) .. "|" .. save:getXPosition():asAbsolute(1))
+ save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
+end
+
+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:getXPosition():asAbsolute(1)
+
+ local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
+ queue:setMaxSize(tonumber(window:getText()))
+ local maxSize = queue:getMaxSize()
+
+ window:setText(maxSize)
+ P.sampleWindow:setText(maxSize)
+ local size = getMinTextSize(P.sampleWindow)
+ window:setWidth(CEGUI.UDim(0, size[2]*2+20))
+ save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
+end
+
+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:getXPosition():asAbsolute(1)
+
+ local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
+ queue:setDisplayTime(tonumber(window:getText()))
+ local time = queue:getDisplayTime()
+
+ window:setText(time)
+ P.sampleWindow:setText(time)
+ local size = getMinTextSize(P.sampleWindow)
+ window:setWidth(CEGUI.UDim(0, size[2]*2+20))
+ save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
+end
+
+function P.createNewQueue_clicked(e)
+ local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
+ local name = window:getText()
+ orxonox.NotificationManager:getInstance():createQueue(name)
+
+ local queue = P.queueList[name]
+ if queue == nil then
+ cout(0, "7Queue is nil! " .. name)
+ return
end
- return queue
+
+ local frame = P.createQueueEditFrame(name)
+ local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
+ root:removeChildWindow(queue.window)
+ frame:setArea(queue.window:getArea())
+ queue.edit = frame
+
+ window:setText("")
end
+function P.leaveEditMode_clicked(e)
+ hideMenuSheet(P.name)
+end
+
function P.queueHeightHelper(queue, size)
local listbox = CEGUI.toListbox(queue)
local item = CEGUI.createListboxTextItem("Text")
@@ -187,4 +431,3 @@
end
return P
-
Modified: code/branches/notifications/data/gui/scripts/SheetManager.lua
===================================================================
--- code/branches/notifications/data/gui/scripts/SheetManager.lua 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/data/gui/scripts/SheetManager.lua 2010-09-09 20:59:01 UTC (rev 7395)
@@ -184,6 +184,8 @@
orxonox.HumanController:resumeControl()
hideCursor()
end
+
+ sheetTuple.sheet:afterHide()
end
-- Hides all menu GUI sheets
Modified: code/branches/notifications/src/modules/notifications/CMakeLists.txt
===================================================================
--- code/branches/notifications/src/modules/notifications/CMakeLists.txt 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/src/modules/notifications/CMakeLists.txt 2010-09-09 20:59:01 UTC (rev 7395)
@@ -12,6 +12,7 @@
FIND_HEADER_FILES
TOLUA_FILES
NotificationManager.h
+ NotificationQueue.h
PCH_FILE
NotificationsPrecompiledHeaders.h
LINK_LIBRARIES
Modified: code/branches/notifications/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationManager.cc 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/src/modules/notifications/NotificationManager.cc 2010-09-09 20:59:01 UTC (rev 7395)
@@ -27,7 +27,7 @@
*/
/**
- @file
+ @file NotificationManager.cc
@brief Implementation of the NotificationManager class.
*/
@@ -42,12 +42,17 @@
#include "Notification.h"
#include "NotificationQueue.h"
+#include "ToluaBindNotifications.h"
+
namespace orxonox
{
const std::string NotificationManager::ALL("all");
const std::string NotificationManager::NONE("none");
+ // Register tolua_open function when loading the library.
+ DeclareToluaInterface(Notifications);
+
ManageScopedSingleton(NotificationManager, ScopeID::Graphics, false);
//TODO: Make work.
@@ -64,14 +69,8 @@
this->highestIndex_ = 0;
ModifyConsoleCommand("enterEditMode").setObject(this);
-
- if(GameMode::showsGraphics())
- {
- GUIManager::getInstance().loadGUI("NotificationLayer");
-
- // Create first queue:
- this->queues_.push_back(new NotificationQueue("all"));
- }
+
+ COUT(3) << "NotificatioManager created." << std::endl;
}
/**
@@ -81,12 +80,21 @@
NotificationManager::~NotificationManager()
{
ModifyConsoleCommand("enterEditMode").setObject(NULL);
+
+ for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
+ it->second->destroy();
+
+ COUT(3) << "NotificationManager destroyed." << std::endl;
}
void NotificationManager::preDestroy(void)
{
- for(std::vector<NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++)
- (*it)->destroy();
+ for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); )
+ {
+ NotificationQueue* queue = (*it).second;
+ it++;
+ queue->destroy();
+ }
this->queues_.clear();
}
@@ -100,28 +108,31 @@
*/
bool NotificationManager::registerNotification(Notification* notification)
{
-
- if(notification == NULL) //!< A NULL-Notification cannot be registered.
+ if(notification == NULL) // A NULL-Notification cannot be registered.
return false;
std::time_t time = std::time(0); //TODO: Doesn't this expire? //!< Get current time.
- this->allNotificationsList_.insert(std::pair<std::time_t,Notification*>(time,notification));
+ this->allNotificationsList_.insert(std::pair<std::time_t, Notification*>(time, notification));
- if(notification->getSender() == NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
+ if(notification->getSender() == NotificationManager::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
return true;
bool all = false;
- if(notification->getSender() == ALL) // If all are the sender, then the Notifications is added to every NotificationListener.
+ if(notification->getSender() == NotificationManager::ALL) // If all are the sender, then the Notifications is added to every NotificationListener.
all = true;
// Insert the notification in all listeners that have its sender as target.
for(std::map<NotificationListener*,int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) // Iterate through all listeners.
{
- std::set<std::string> set = it->first->getTargetsSet();
- if(all || set.find(notification->getSender()) != set.end() || set.find(ALL) != set.end()) //TODO: Make sure this works.
+ std::set<std::string, NotificationListenerStringCompare> set = it->first->getTargetsSet();
+ bool bAll = set.find(NotificationManager::ALL) != set.end();
+ if(all || bAll || set.find(notification->getSender()) != set.end()) //TODO: Make sure this works.
{
- this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); // Insert the Notification in the Notifications list of the current NotificationListener.
+ if(!bAll)
+ {
+ this->notificationLists_[it->second]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the Notifications list of the current NotificationListener.
+ }
it->first->update(notification, time); // Update the listener.
std::map<Notification*, unsigned int>::iterator counterIt = this->listenerCounter_.find(notification);
if(counterIt == this->listenerCounter_.end())
@@ -131,7 +142,7 @@
}
}
- COUT(4) << "Notification registered with the NotificationManager." << std::endl;
+ COUT(4) << "Notification (&" << notification << ") registered with the NotificationManager." << std::endl;
return true;
}
@@ -153,15 +164,7 @@
if(this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second)))
this->listenerCounter_[notification] = this->listenerCounter_[notification] - 1;
- // 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.
- if(this->listenerCounter_[notification] == (unsigned int) 0)
- {
- this->removeNotification(notification, this->allNotificationsList_);
- this->listenerCounter_.erase(notification);
- notification->destroy();
- }
-
- COUT(4) << "Notification unregistered with the NotificationManager." << std::endl;
+ COUT(4) << "Notification (&" << notification << ")unregistered with the NotificationManager from listener (&" << listener << ")" << std::endl;
}
/**
@@ -174,7 +177,6 @@
@return
Returns true if successful.
*/
- //TODO: Needed?
bool NotificationManager::removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map)
{
// Iterates through all items in the map until the Notification is found.
@@ -205,25 +207,26 @@
this->listenerList_[listener] = index; // Add the NotificationListener to the list of listeners.
- std::set<std::string> set = listener->getTargetsSet(); //TODO: Does this work?
+ std::set<std::string, NotificationListenerStringCompare> set = listener->getTargetsSet();
// 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.
- if(set.find(ALL) != set.end())
+ bool bAll = set.find(NotificationManager::ALL) != set.end();
+ std::multimap<std::time_t, Notification*> map;
+ if(bAll)
+ this->notificationLists_[index] = &this->allNotificationsList_;
+ else
{
- this->notificationLists_[index] = &this->allNotificationsList_;
- COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl;
- return true;
+ this->notificationLists_[index] = new std::multimap<std::time_t, Notification*>;
+ map = *this->notificationLists_[index];
}
- this->notificationLists_[index] = new std::multimap<std::time_t,Notification*>;
- std::multimap<std::time_t,Notification*> map = *this->notificationLists_[index];
-
// Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener.
- for(std::multimap<std::time_t,Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
+ for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
{
- if(set.find(it->second->getSender()) != set.end()) // Checks whether the overlay has the sender of the current notification as target.
+ if(bAll || set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current notification as target.
{
- map.insert(std::pair<std::time_t, Notification*>(it->first, it->second));
+ if(!bAll)
+ map.insert(std::pair<std::time_t, Notification*>(it->first, it->second));
std::map<Notification*, unsigned int>::iterator counterIt = this->listenerCounter_.find(it->second);
if(counterIt == this->listenerCounter_.end())
this->listenerCounter_[it->second] = 1;
@@ -287,28 +290,50 @@
if(listener == NULL || map == NULL)
return false;
- std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // The Notifications for the input NotificationListener.
+ std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // The Notifications for the input NotificationListener.
- if(notifications == NULL) // Returns NULL, if there are no Notifications.
- return true;
+ if(notifications == NULL) // Returns false, if there are no Notifications.
+ return false;
std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
itLowest = notifications->lower_bound(timeFrameStart);
- itHighest = notifications->upper_bound(timeFrameStart);
+ itHighest = notifications->upper_bound(timeFrameEnd);
for(it = itLowest; it != itHighest; it++) // Iterate through the Notifications from the start of the time Frame to the end of it.
- {
- map->insert(std::pair<std::time_t,Notification*>(it->first,it->second)); // Add the found Notifications to the map.
- }
+ map->insert(std::pair<std::time_t, Notification*>(it->first,it->second)); // Add the found Notifications to the map.
return true;
}
- void NotificationManager::createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime)
+ void NotificationManager::loadQueues(void)
{
- this->queues_.push_back(new NotificationQueue(name, targets, size, displayTime));
+ new NotificationQueue("all");
}
+ void NotificationManager::createQueue(const std::string& name)
+ {
+ new NotificationQueue(name);
+ }
+
+ NotificationQueue* NotificationManager::getQueue(const std::string & name)
+ {
+ std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.find(name);
+ if(it == this->queues_.end())
+ return NULL;
+
+ return (*it).second;
+ }
+
+ bool NotificationManager::registerQueue(NotificationQueue* queue)
+ {
+ return this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;
+ }
+
+ void NotificationManager::unregisterQueue(NotificationQueue* queue)
+ {
+ this->queues_.erase(queue->getName());
+ }
+
void NotificationManager::enterEditMode(void)
{
GUIManager::getInstance().hideGUI("NotificationLayer");
Modified: code/branches/notifications/src/modules/notifications/NotificationManager.h
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationManager.h 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/src/modules/notifications/NotificationManager.h 2010-09-09 20:59:01 UTC (rev 7395)
@@ -27,7 +27,7 @@
*/
/**
- @file
+ @file NotificationManager.h
@brief Definition of the NotificationManager class.
*/
@@ -39,7 +39,6 @@
#include <ctime>
#include <map>
#include <string>
-#include <vector>
#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
@@ -54,7 +53,7 @@
@author
Damian 'Mozork' Frick
*/
- class _NotificationsExport NotificationManager // tolua_export
+ class _NotificationsExport NotificationManager // tolua_export
: public Singleton<NotificationManager>, public OrxonoxClass
{ // tolua_export
friend class Singleton<NotificationManager>;
@@ -74,7 +73,7 @@
bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager.
void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager.
- 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.
+ 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.
/**
@brief Fetches the Notifications for a specific NotificationListener starting at a specified timespan before now.
@@ -83,23 +82,31 @@
@param timeDelay The timespan.
@return Returns true if successful.
*/
- bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, int timeDelay)
+ bool getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int timeDelay)
{ return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
void enterEditMode(void);
- void createQueue(const std::string& name, const std::string& targets, unsigned int size, unsigned int displayTime); // tolua_export
+ // tolua_begin
+ void loadQueues(void);
+
+ void createQueue(const std::string& name);
+ orxonox::NotificationQueue* getQueue(const std::string & name);
+ // tolua_end
+ bool registerQueue(NotificationQueue* queue);
+ void unregisterQueue(NotificationQueue* queue);
+
private:
static NotificationManager* singletonPtr_s;
- std::vector<NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
+ std::map<const std::string, NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
- std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored.
- std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
- std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
+ std::multimap<std::time_t, Notification*> allNotificationsList_; //!< Container where all notifications are stored.
+ std::map<NotificationListener*, int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
+ std::map<int,std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
std::map<Notification*, unsigned int> listenerCounter_; //!< A container to store the number of NotificationListeners a Notification is registered with.
bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map.
Modified: code/branches/notifications/src/modules/notifications/NotificationQueue.cc
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationQueue.cc 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/src/modules/notifications/NotificationQueue.cc 2010-09-09 20:59:01 UTC (rev 7395)
@@ -34,6 +34,7 @@
#include "NotificationQueue.h"
#include <map>
+#include <sstream>
#include "core/CoreIncludes.h"
#include "core/GUIManager.h"
@@ -61,11 +62,26 @@
this->maxSize_ = size;
this->setDisplayTime(displayTime);
+ bool queueRegistered = NotificationManager::getInstance().registerQueue(this);
+ this->registered_ = true;
+ if(!queueRegistered)
+ {
+ this->registered_ = false;
+ COUT(1) << "Error: Notification Queue '" << this->getName() << "' could not be registered." << std::endl;
+ return;
+ }
+
this->create();
+
+ bool listenerRegistered = NotificationManager::getInstance().registerListener(this);
+ if(!listenerRegistered)
+ {
+ this->registered_ = false;
+ NotificationManager::getInstance().unregisterQueue(this);
+ COUT(1) << "Error: Notification Queue '" << this->getName() << "' could not be registered." << std::endl;
+ return;
+ }
- NotificationManager::getInstance().registerListener(this);
- this->registered_ = true;
-
COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
}
@@ -76,10 +92,14 @@
NotificationQueue::~NotificationQueue()
{
this->targets_.clear();
- this->clear();
if(this->registered_)
+ {
+ this->clear();
+
NotificationManager::getInstance().unregisterListener(this);
+ NotificationManager::getInstance().unregisterQueue(this);
+ }
}
/**
@@ -99,7 +119,7 @@
*/
void NotificationQueue::create(void)
{
- GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
+ GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() + "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
}
/**
@@ -143,15 +163,17 @@
return;
}
- if(notifications->empty())
- return;
+ if(!notifications->empty())
+ {
+ for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) // Add all Notifications.
+ {
+ this->push(it->second, it->first);
+ }
+ }
- for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++) // Add all Notifications.
- this->push(it->second, it->first);
-
delete notifications;
- COUT(4) << "NotificationQueue '" << this->getName() << "' updated." << std::endl;
+ COUT(3) << "NotificationQueue '" << this->getName() << "' updated." << std::endl; //TODO: Level 4.
}
/**
@@ -166,7 +188,7 @@
{
this->push(notification, time);
- COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notification has been added." << std::endl;
+ COUT(3) << "NotificationQueue '" << this->getName() << "' updated. A new Notification has been added." << std::endl; //TODO: Level 4.
}
/**
@@ -252,7 +274,6 @@
*/
bool NotificationQueue::setName(const std::string& name)
{
- //TODO: Test uniqueness of name.
this->name_ = name;
return true;
}
@@ -267,6 +288,9 @@
*/
void NotificationQueue::setMaxSize(unsigned int size)
{
+ if(this->maxSize_ == size)
+ return;
+
this->maxSize_ = size;
this->sizeChanged();
}
@@ -291,37 +315,35 @@
*/
void NotificationQueue::setDisplayTime(unsigned int time)
{
+ if(this->displayTime_ == time)
+ return;
+
this->displayTime_ = time;
- this->update();
+
+ if(this->registered_)
+ this->update();
}
/**
@brief
Produces all targets concatinated as string, with kommas (',') as seperators.
- @param string
- Pointer to a string which will be used by the method to fill with the concatination of the targets.
@return
- Returns true if successful.
+ Returns the targets as a string.
*/
- bool NotificationQueue::getTargets(std::string* string) const
+ const std::string& NotificationQueue::getTargets(void) const
{
- if(string == NULL)
- {
- COUT(4) << "Input string must have memory allocated." << std::endl;
- return false;
- }
- string->clear();
+ std::stringstream stream;
bool first = true;
- for(std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) // Iterate through the set of targets.
+ for(std::set<std::string, NotificationListenerStringCompare>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++) // Iterate through the set of targets.
{
if(!first)
- *string += ',';
+ stream << ',';
else
first = false;
- *string += *it;
+ stream << *it;
}
- return true;
+ return *(new std::string(stream.str()));
}
/**
@@ -351,6 +373,12 @@
this->targets_.insert(*pTemp);
}
+ if(this->registered_)
+ {
+ NotificationManager::getInstance().unregisterListener(this);
+ NotificationManager::getInstance().registerListener(this);
+ }
+
return true;
}
Modified: code/branches/notifications/src/modules/notifications/NotificationQueue.h
===================================================================
--- code/branches/notifications/src/modules/notifications/NotificationQueue.h 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/src/modules/notifications/NotificationQueue.h 2010-09-09 20:59:01 UTC (rev 7395)
@@ -45,8 +45,8 @@
#include "interfaces/NotificationListener.h"
#include "NotificationManager.h"
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
//! Container to allow easy handling.
struct NotificationContainer
@@ -67,8 +67,9 @@
@author
Damian 'Mozork' Frick
*/
- class _NotificationsExport NotificationQueue : public Tickable, public NotificationListener
- {
+ class _NotificationsExport NotificationQueue // tolua_export
+ : public Tickable, public NotificationListener
+ { // tolua_export
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);
@@ -79,6 +80,7 @@
void update(void); //!< Updates the queue.
void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue.
+ // tolua_begin
/**
@brief Get the name of the NotificationQueue.
@return Returns the name.
@@ -86,33 +88,42 @@
inline const std::string& getName() const
{ return this->name_; }
+ void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
/**
@brief Returns the maximum number of Notifications displayed.
@return Returns maximum size.
*/
inline unsigned int getMaxSize() const
{ return this->maxSize_; }
+
+ void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
/**
- @brief Returns the current number of Notifications displayed.
- @return Returns the size of the queue.
- */
- inline unsigned int getSize() const
- { return this->size_; }
- /**
@brief Returns the time interval the Notification is displayed.
@return Returns the display time.
*/
inline float getDisplayTime() const
{ return this->displayTime_; }
+ // tolua_end
/**
+ @brief Returns the current number of Notifications displayed.
+ @return Returns the size of the queue.
+ */
+ inline unsigned int getSize() const
+ { return this->size_; }
+
+ /**
@brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.
@return Retuns a set of string holding the different targets.
*/
- inline const std::set<std::string> & getTargetsSet()
+ inline const std::set<std::string, NotificationListenerStringCompare> & getTargetsSet()
{ return this->targets_; }
- bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
+ // tolua_begin
+ bool setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
+ const std::string& getTargets(void) const; //!< Returns a string consisting of the concatination of the targets.
+ // tolua_end
+
private:
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.
@@ -123,7 +134,7 @@
unsigned int size_; //!< The number of Notifications displayed.
unsigned int displayTime_; //!< The time a Notification is displayed.
- std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
+ std::set<std::string, NotificationListenerStringCompare> targets_; //!< The targets the Queue displays Notifications of.
std::multiset<NotificationContainer*, NotificationContainerCompare> ordering_; //!< The NotificationContainers ordered by the time they were registered. //TODO: Would set work as well?
std::vector<NotificationContainer*> notifications_; //!< The NotificationContainers in the order they were added to the NotificationQueue.
@@ -138,11 +149,6 @@
bool setName(const std::string& name); //!< Sets the name of the NotificationQueue.
- void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
- void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
-
- bool setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
-
void sizeChanged(void); //!< Adjusts the NotificationQueue, when the maximum size has changed.
void push(Notification* notification, const std::time_t & time); //!< Add a Notification to the NotificationQueue.
@@ -151,8 +157,8 @@
void clear(void); //!< Clears the queue by removing all Notifications.
- };
+ }; // tolua_export
-}
+} // tolua_export
#endif /* _NotificationOverlay_H__ */
Modified: code/branches/notifications/src/orxonox/interfaces/NotificationListener.h
===================================================================
--- code/branches/notifications/src/orxonox/interfaces/NotificationListener.h 2010-09-09 18:44:25 UTC (rev 7394)
+++ code/branches/notifications/src/orxonox/interfaces/NotificationListener.h 2010-09-09 20:59:01 UTC (rev 7395)
@@ -48,6 +48,17 @@
/**
@brief
+ Struct that overloads the compare operation between two PickupIdentifier pointers.
+ */
+ //TODO:
+ struct NotificationListenerStringCompare
+ {
+ bool operator() (const std::string& lhs, const std::string& rhs) const
+ { return lhs.compare(rhs) < 0; }
+ };
+
+ /**
+ @brief
NotificationListener interface.
@author
Fabian 'x3n' Landau
@@ -58,7 +69,7 @@
NotificationListener();
virtual ~NotificationListener() {}
- virtual const std::set<std::string> & getTargetsSet() = 0;
+ virtual const std::set<std::string, NotificationListenerStringCompare> & getTargetsSet() = 0;
virtual void update(void) = 0;
virtual void update(Notification* notification, const std::time_t & time) = 0;
};
More information about the Orxonox-commit
mailing list