[7338] | 1 | -- NotificationLayer.lua |
---|
| 2 | |
---|
[7395] | 3 | local P = createMenuSheet("NotificationLayer", true, TriBool.True, TriBool.True) |
---|
[7338] | 4 | |
---|
| 5 | P.queueList = {} |
---|
[7354] | 6 | P.editMode = false |
---|
[7338] | 7 | |
---|
[7395] | 8 | P.sampleWindow = nil |
---|
| 9 | |
---|
| 10 | function P.onLoad() |
---|
| 11 | orxonox.NotificationManager:getInstance():loadQueues() |
---|
| 12 | P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/SampleWindow") |
---|
| 13 | end |
---|
| 14 | |
---|
[7338] | 15 | function P.createQueue(name, size) |
---|
| 16 | local root = winMgr:getWindow("orxonox/NotificationLayer/Root") |
---|
| 17 | local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name) |
---|
[7354] | 18 | queue:setProperty("BackgroundColor", "00FFFFFF") |
---|
[7342] | 19 | root:addChildWindow(queue) |
---|
| 20 | |
---|
[7338] | 21 | queue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0))) |
---|
[7342] | 22 | queue:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, 0), CEGUI.UDim(0, P.queueHeightHelper(queue, size)))) |
---|
| 23 | |
---|
[7395] | 24 | local queueTuple = |
---|
| 25 | { |
---|
| 26 | ["window"] = queue, |
---|
| 27 | ["name"] = name, |
---|
| 28 | ["edit"] = nil, |
---|
| 29 | ["visible"] = false |
---|
| 30 | } |
---|
[7351] | 31 | |
---|
[7395] | 32 | P.queueList[name] = queueTuple -- name access |
---|
| 33 | P.setVisible(queueTuple, false) |
---|
[7338] | 34 | end |
---|
| 35 | |
---|
| 36 | function P.removeQueue(name) |
---|
[7395] | 37 | local queue = P.queueList[name] |
---|
[7338] | 38 | |
---|
| 39 | if queue ~= nil then |
---|
[7395] | 40 | winMgr:destroyWindow(queue.window) |
---|
[7338] | 41 | end |
---|
[7395] | 42 | queue = nil |
---|
[7338] | 43 | end |
---|
| 44 | |
---|
| 45 | function P.pushNotification(queueName, notification) |
---|
[7395] | 46 | local queue = P.queueList[queueName] |
---|
[7338] | 47 | if queue == nil then |
---|
[7395] | 48 | cout(0, "0Queue is nil! " .. queueName) |
---|
[7338] | 49 | return |
---|
| 50 | end |
---|
| 51 | item = CEGUI.createListboxTextItem(notification) |
---|
[7395] | 52 | local listbox = CEGUI.toListbox(queue.window) |
---|
[7338] | 53 | if listbox:getItemCount() == 0 then |
---|
| 54 | listbox:addItem(item) |
---|
| 55 | else |
---|
| 56 | listbox:insertItem(item, listbox:getListboxItemFromIndex(0)) |
---|
| 57 | end |
---|
[7351] | 58 | |
---|
[7395] | 59 | if queue.visible == false then |
---|
[7351] | 60 | P.setVisible(queue, true) |
---|
| 61 | end |
---|
[7338] | 62 | end |
---|
| 63 | |
---|
| 64 | function P.popNotification(queueName) |
---|
[7395] | 65 | local queue = P.queueList[queueName] |
---|
[7338] | 66 | if queue == nil then |
---|
[7395] | 67 | cout(0, "1Queue is nil! " .. queueName) |
---|
[7338] | 68 | return |
---|
| 69 | end |
---|
[7395] | 70 | local listbox = CEGUI.toListbox(queue.window) |
---|
[7338] | 71 | listbox:removeItem(listbox:getListboxItemFromIndex(listbox:getItemCount()-1)) |
---|
[7351] | 72 | |
---|
| 73 | if listbox:getItemCount() == 0 then |
---|
| 74 | P.setVisible(queue, false) |
---|
| 75 | end |
---|
[7338] | 76 | end |
---|
| 77 | |
---|
| 78 | function P.removeNotification(queueName, index) |
---|
[7395] | 79 | local queue = P.queueList[queueName] |
---|
[7338] | 80 | if queue == nil then |
---|
[7395] | 81 | cout(0, "2Queue is nil! " .. queueName) |
---|
[7338] | 82 | return |
---|
| 83 | end |
---|
[7395] | 84 | local listbox = CEGUI.toListbox(queue.window) |
---|
[7338] | 85 | listbox:removeItem(listbox:getListboxItemFromIndex(tonumber(index))) |
---|
[7351] | 86 | |
---|
| 87 | if listbox:getItemCount() == 0 then |
---|
| 88 | P.setVisible(queue, false) |
---|
| 89 | end |
---|
[7338] | 90 | end |
---|
| 91 | |
---|
| 92 | function P.clearQueue(name) |
---|
[7395] | 93 | local queue = P.queueList[name] |
---|
[7338] | 94 | if queue == nil then |
---|
[7395] | 95 | cout(0, "3Queue is nil! " .. name) |
---|
[7338] | 96 | return |
---|
| 97 | end |
---|
[7395] | 98 | local listbox = CEGUI.toListbox(queue.window) |
---|
| 99 | CEGUI.toListbox(queue.window):resetList() |
---|
[7351] | 100 | |
---|
| 101 | P.setVisible(queue, false) |
---|
[7338] | 102 | end |
---|
| 103 | |
---|
[7395] | 104 | function P.changeSize(name, size) |
---|
| 105 | local queue = P.queueList[name] |
---|
[7343] | 106 | if queue == nil then |
---|
[7395] | 107 | cout(0, "5Queue is nil! " .. name) |
---|
[7343] | 108 | return |
---|
| 109 | end |
---|
[7395] | 110 | queue.window:setHeight(CEGUI.UDim(0, P.queueHeightHelper(queue.window, size))) |
---|
[7343] | 111 | end |
---|
| 112 | |
---|
[7395] | 113 | function P.setVisible(queue, visible) |
---|
[7343] | 114 | if queue == nil then |
---|
[7395] | 115 | cout(0, "6Queue is nil! " .. queue.name) |
---|
[7343] | 116 | return |
---|
| 117 | end |
---|
[7395] | 118 | queue.window:setVisible(visible) |
---|
| 119 | queue.visible = visible |
---|
[7343] | 120 | end |
---|
| 121 | |
---|
[7354] | 122 | function P.enterEditMode() |
---|
| 123 | P.editMode = true |
---|
| 124 | |
---|
| 125 | local root = winMgr:getWindow("orxonox/NotificationLayer/Root") |
---|
[7395] | 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 | |
---|
[7354] | 178 | --Replace all queues with FrameWindows |
---|
| 179 | for k,v in pairs(P.queueList) do |
---|
| 180 | if v ~= nil then |
---|
[7395] | 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 |
---|
[7354] | 188 | end |
---|
| 189 | end |
---|
| 190 | end |
---|
| 191 | |
---|
[7395] | 192 | function 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 |
---|
| 300 | end |
---|
| 301 | |
---|
[7354] | 302 | function P.leaveEditMode() |
---|
| 303 | P.editMode = false |
---|
| 304 | |
---|
| 305 | local root = winMgr:getWindow("orxonox/NotificationLayer/Root") |
---|
| 306 | --Replace all queues with FrameWindows |
---|
| 307 | for k,v in pairs(P.queueList) do |
---|
| 308 | if v ~= nil then |
---|
[7395] | 309 | root:addChildWindow(v.window) |
---|
| 310 | v.window:setArea(v.edit:getArea()) |
---|
| 311 | winMgr:destroyWindow(v.edit) |
---|
| 312 | v.edit = nil |
---|
[7354] | 313 | end |
---|
| 314 | end |
---|
[7362] | 315 | |
---|
[7395] | 316 | --Remove control window |
---|
| 317 | winMgr:destroyWindow(winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow")) |
---|
[7354] | 318 | end |
---|
| 319 | |
---|
[7395] | 320 | function P.afterHide() |
---|
[7354] | 321 | if P.editMode then |
---|
| 322 | P.leaveEditMode() |
---|
[7395] | 323 | showMenuSheet(P.name, false, true) |
---|
[7354] | 324 | end |
---|
| 325 | end |
---|
| 326 | |
---|
[7395] | 327 | function 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))) |
---|
| 349 | end |
---|
| 350 | |
---|
| 351 | function 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))) |
---|
| 372 | end |
---|
| 373 | |
---|
| 374 | function 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))) |
---|
| 395 | end |
---|
| 396 | |
---|
| 397 | function 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 |
---|
[7338] | 406 | end |
---|
[7395] | 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("") |
---|
[7338] | 415 | end |
---|
| 416 | |
---|
[7395] | 417 | function P.leaveEditMode_clicked(e) |
---|
| 418 | hideMenuSheet(P.name) |
---|
| 419 | end |
---|
| 420 | |
---|
[7342] | 421 | function P.queueHeightHelper(queue, size) |
---|
| 422 | local listbox = CEGUI.toListbox(queue) |
---|
| 423 | local item = CEGUI.createListboxTextItem("Text") |
---|
| 424 | listbox:addItem(item) |
---|
| 425 | local singleItemHeight = listbox:getTotalItemsHeight() |
---|
| 426 | local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(queue:getLookNFeel()) |
---|
| 427 | local formattedArea = lookAndFeel:getNamedArea("ItemRenderingArea"):getArea():getPixelRect(queue) |
---|
| 428 | local frameHeight = queue:getUnclippedPixelRect():getHeight() - formattedArea:getHeight() |
---|
| 429 | listbox:removeItem(item) |
---|
| 430 | return frameHeight + singleItemHeight*size |
---|
| 431 | end |
---|
| 432 | |
---|
[7338] | 433 | return P |
---|