Changeset 7894 for code/branches/tutoriallevel/data/gui/scripts
- Timestamp:
- Feb 14, 2011, 11:02:58 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutoriallevel/data/gui/scripts/NotificationLayer.lua
r7413 r7894 21 21 root:addChildWindow(queue) 22 22 23 queue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))24 queue:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, 0), CEGUI.UDim(0, P.queueHeightHelper(queue, size))))25 26 23 local queueTuple = 27 24 { 28 ["window"] = queue, 29 ["name"] = name, 30 ["edit"] = nil, 31 ["visible"] = false 25 ["window"] = queue, 26 ["name"] = name, 27 ["edit"] = nil, 28 ["visible"] = false, 29 ["fontSize"] = 12, 30 ["fontColor"] = CEGUI.colour(1.0, 1.0, 1.0, 1.0) 32 31 } 32 33 queue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0))) 34 queue:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, 0), CEGUI.UDim(0, P.queueHeightHelper(queueTuple, size)))) 33 35 34 36 P.queueList[name] = queueTuple -- name access … … 53 55 end 54 56 item = CEGUI.createListboxTextItem(notification) 57 P.setItemFontHelper(item, queue, true) 55 58 local listbox = CEGUI.toListbox(queue.window) 56 59 -- Add the item to the top of the listbox. … … 119 122 queue.window:setVisible(visible) 120 123 queue.visible = visible 124 end 125 126 -- Change the position of the queue. 127 -- The parameters are (in order) 'name of the queue', 'relative x-position', 'absolute x-position in pixel', 'relative y-position', 'absolute y-position in pixel'. 128 function P.moveQueue(queueName, relativeXPos, absoluteXPos, relativeYpos, absoluteYPos) 129 local queueWindow = P.queueList[queueName].window 130 queueWindow:setPosition(CEGUI.UVector2(CEGUI.UDim(relativeXPos, absoluteXPos), CEGUI.UDim(relativeYpos, absoluteYPos))) 131 end 132 133 -- Change the size of the queue. 134 -- The parameters are (in order) 'name of the queue', 'relative width', 'absolute width in pixel', 'relative height', 'absolute heigth in pixel'. 135 -- Additionally the last parameter can be ommitted and relativeHeight can be set to the size (i.e. the maximal number of notifications displayed) of the queue, which leads to the height being set such that all notifications can be displayed. 136 function P.resizeQueue(queueName, relativeWidth, absoluteWidth, relativeHeight, absoluteHeigth) 137 local queueWindow = P.queueList[queueName].window 138 if queueWindow == nil then 139 return 140 end 141 if absoluteHeigth == nil then 142 absoluteHeigth = P.queueHeightHelper(P.queueList[queueName], relativeHeight) 143 relativeHeight = 0 144 end 145 queueWindow:setSize(CEGUI.UVector2(CEGUI.UDim(relativeWidth, absoluteWidth), CEGUI.UDim(relativeHeight, absoluteHeigth))) 146 end 147 148 -- Change the font size and font color of all notifications in a queueHeightHelper 149 -- The parameters are (in order) 'name of the queue', 'font size', 'RGBA of the font color, with values from 0 to 1 each'. 150 function P.changeQueueFont(queueName, size, colorRed, colorGreen, colorBlue, colorAlpha) 151 local queue = P.queueList[queueName] 152 local queueWindow = queue.window 153 if queueWindow == nil then 154 return 155 end 156 if colorAlpha == nil then 157 colorAlpha = 1.0 158 end 159 160 local list = CEGUI.toListbox(queueWindow) 161 local num = list:getItemCount() 162 queue.fontSize = size 163 local changeColor = false 164 if colorRed ~= nil and colorGreen ~= nil and colorBlue ~= nil then 165 queue.fontColor:set(colorRed, colorGreen, colorBlue, colorAlpha) 166 changeColor = true 167 end 168 for i=0,num-1 do 169 P.setItemFontHelper(item, queue, changeColor) 170 end 171 end 172 173 -- Helper function to set the font size and color of a item of a queue. 174 -- The parameters are (in order) 'the ListboxItem', 'the queue table', 'whether color should be changed as well' 175 function P.setItemFontHelper(item, queue, changeColor) 176 local item = tolua.cast(item, "CEGUI::ListboxTextItem") 177 local fontMgr = CEGUI.FontManager:getSingleton() 178 if fontMgr:isFontPresent("BlueHighway-" .. queue.fontSize) then 179 item:setFont("BlueHighway-" .. queue.fontSize) 180 else 181 orxonox.GUIManager:addFontHelper("BlueHighway-" .. queue.fontSize, queue.fontSize, "bluehigh.ttf") 182 item:setFont("BlueHighway-" .. queue.fontSize) 183 end 184 if changeColor then 185 item:setTextColours(queue.fontColor) 186 end 121 187 end 122 188 … … 342 408 343 409 -- If the button to save the targets of a queue has been clicked. 344 function P. 410 function P.saveTargets_clicked(e) 345 411 local we = CEGUI.toWindowEventArgs(e) 346 412 local name = we.window:getName() … … 369 435 370 436 -- If the button to save the size if a queue has been clicked. 371 function P. 437 function P.saveSize_clicked(e) 372 438 local we = CEGUI.toWindowEventArgs(e) 373 439 local name = we.window:getName() … … 396 462 397 463 -- If the button to save the display time if a queue has been clicked. 398 function P. 464 function P.saveDisplayTime_clicked(e) 399 465 local we = CEGUI.toWindowEventArgs(e) 400 466 local name = we.window:getName() … … 478 544 -- Helper function. Returns height a queue needs to have to display 'size' items. 479 545 function P.queueHeightHelper(queue, size) 480 local listbox = CEGUI.toListbox(queue )546 local listbox = CEGUI.toListbox(queue.window) 481 547 local item = CEGUI.createListboxTextItem("Text") 548 P.setItemFontHelper(item, queue, false) 482 549 listbox:addItem(item) 483 550 local singleItemHeight = listbox:getTotalItemsHeight() 484 local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(queue :getLookNFeel())485 local formattedArea = lookAndFeel:getNamedArea("ItemRenderingArea"):getArea():getPixelRect(queue )486 local frameHeight = queue :getUnclippedPixelRect():getHeight() - formattedArea:getHeight()551 local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(queue.window:getLookNFeel()) 552 local formattedArea = lookAndFeel:getNamedArea("ItemRenderingArea"):getArea():getPixelRect(queue.window) 553 local frameHeight = queue.window:getUnclippedPixelRect():getHeight() - formattedArea:getHeight() 487 554 listbox:removeItem(item) 488 555 return frameHeight + singleItemHeight*size
Note: See TracChangeset
for help on using the changeset viewer.