Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 11, 2011, 10:45:56 PM (13 years ago)
Author:
dafrick
Message:

Extending NotificationQueueCEGUI.

File:
1 edited

Legend:

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

    r8446 r8448  
    2727        ["window"]    = queue,
    2828        ["name"]      = name,
    29         ["edit"]      = nil,
     29        ["maxSize"]      = size,
    3030        ["visible"]   = false,
    3131        ["fontSize"]  = 12,
     
    183183-- Change the size of the queue.
    184184-- The parameters are (in order) 'name of the queue', 'relative width', 'absolute width in pixel', 'relative height', 'absolute heigth in pixel'.
    185 -- 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.
     185-- Additionally the last two parameters can be ommitted, which leads to the height being set such that all notifications can be displayed. using the size of the queue.
    186186function P.resizeQueue(queueName, relativeWidth, absoluteWidth, relativeHeight, absoluteHeigth)
    187     local queueWindow = P.queueList[queueName].window
     187    local queue = P.queueList[queueName]
     188    local queueWindow = queue.window
    188189    if queueWindow == nil then
    189190        return
    190191    end
    191192    if absoluteHeigth == nil then
    192         absoluteHeigth = P.queueHeightHelper(P.queueList[queueName], relativeHeight)
     193        absoluteHeigth = P.queueHeightHelper(queue, queue.maxSize)
    193194        relativeHeight = 0
    194195    end
     
    196197end
    197198
    198 -- Change the font size and font color of all notifications in a queueHeightHelper
    199 -- The parameters are (in order) 'name of the queue', 'font size', 'ARGB of the font color in hex notation'.
    200 function P.changeQueueFont(queueName, size, color)
    201     local queue = P.queueList[queueName]
    202     local queueWindow = queue.window
    203     if queueWindow == nil then
    204         return
    205     end
    206 
    207     queue.fontSize = size
    208     local changeColor = false
    209     if color ~= nil then
    210         queue.fontColor = color
    211         changeColor = true
    212     end
    213     for i=queue.first,queue.last-1 do
    214         P.setItemFontHelper(queue.items[i], queue, changeColor)
    215     end
    216 end
    217 
     199-- Change the horizontal alignment of the displayed notifications.
     200-- The parameters are the name of the queue and the alignment parameter,
    218201function P.changeQueueAlignment(queueName, alignment)
    219202    local queue = P.queueList[queueName]
     
    222205        return
    223206    end
    224    
     207
    225208    queue.alignment = alignment
    226209    local item = nil
     
    228211        item = queue.items[i]
    229212        item:setProperty("HorzFormatting", queue.alignment)
     213    end
     214end
     215
     216-- Change the font size  of all notifications in a queue.
     217-- The parameters are (in order) 'name of the queue', 'font size'.
     218function P.changeQueueFontSize(queueName, size)
     219    local queue = P.queueList[queueName]
     220    local queueWindow = queue.window
     221    if queueWindow == nil then
     222        return
     223    end
     224
     225    queue.fontSize = size
     226    for i=queue.first,queue.last-1 do
     227        P.setItemFontHelper(queue.items[i], queue, false)
     228    end
     229end
     230
     231-- Change the font color of all notifications in a queue.
     232-- The parameters are (in order) 'name of the queue', 'ARGB of the font color in hex notation'.
     233function P.changeQueueFontColor(queueName, color)
     234    local queue = P.queueList[queueName]
     235    local queueWindow = queue.window
     236    if queueWindow == nil then
     237        return
     238    end
     239
     240    queue.fontColor = color
     241    for i=queue.first,queue.last-1 do
     242        P.setItemFontHelper(queue.items[i], queue, true)
    230243    end
    231244end
Note: See TracChangeset for help on using the changeset viewer.