Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 12, 2011, 12:31:23 AM (14 years ago)
Author:
dafrick
Message:

Merging tutoriallevel2 branch into tutoriallevel3 branch.

Location:
code/branches/tutoriallevel3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutoriallevel3

  • code/branches/tutoriallevel3/data/gui/scripts/NotificationLayer.lua

    r8351 r8453  
    44
    55P.queueList = {}
    6 P.editMode = false
    76
    87P.sampleWindow = nil
     
    1716function P.createQueue(name, size)
    1817    local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    19     local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name)
    20     queue:setProperty("BackgroundColor", "00FFFFFF") -- Set background to be fully transparent.
     18    --local queue = winMgr:createWindow("MenuWidgets/Listbox", "orxonox/NotificationLayer/Root/Queue/" .. name)
     19    --queue:setProperty("BackgroundColor", "00FFFFFF") -- Set background to be fully transparent.
     20    local queue = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/Queue/" .. name)
     21    queue:setProperty("Alpha", 0.0)
     22    --queue:setProperty("FrameEnabled", "false")
    2123    root:addChildWindow(queue)
    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))))
    2524
    2625    local queueTuple =
    2726    {
    28         ["window"]  = queue,
    29         ["name"]    = name,
    30         ["edit"]    = nil,
    31         ["visible"] = false
     27        ["window"]    = queue,
     28        ["name"]      = name,
     29        ["maxSize"]      = size,
     30        ["visible"]   = false,
     31        ["fontSize"]  = 12,
     32        ["fontColor"] = "FFFFFFFF",
     33        ["alignment"] = "LeftAligned",
     34        ["items"]     = {},
     35        ["first"]     = 1,
     36        ["last"]      = 1
    3237    }
     38   
     39    queue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
     40    queue:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, 0), CEGUI.UDim(0, P.queueHeightHelper(queueTuple, size))))
    3341
    3442    P.queueList[name] = queueTuple -- name access
     
    5260        return
    5361    end
    54     item = CEGUI.createListboxTextItem(notification)
    55     local listbox = CEGUI.toListbox(queue.window)
    56     -- Add the item to the top of the listbox.
    57     if listbox:getItemCount() == 0 then
    58         listbox:addItem(item)
    59     else
    60         listbox:insertItem(item, listbox:getListboxItemFromIndex(0))
    61     end
     62
     63    local item = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/Queue/" .. queueName .. "/" .. queue.last)
     64    item:setText(notification)
     65    P.setItemFontHelper(item, queue, true)
     66    -- Add the item to the top of the queue.
     67    local itemHeight = P.itemHeightHelper(queue)
     68    if queue.last-queue.first > 0 then -- If the queue is not empty move all items down
     69        for i=queue.first,queue.last-1 do
     70            local item = queue.items[i]
     71            item:setYPosition(CEGUI.UDim(0, itemHeight*(queue.last-i)))
     72        end
     73    end
     74    queue.window:addChildWindow(item)
     75    item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, itemHeight)))
     76    item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
     77    item:setProperty("Alpha", 1.0)
     78    item:setProperty("InheritsAlpha", "false")
     79    item:setProperty("BackgroundEnabled", "false")
     80    item:setProperty("FrameEnabled", "false")
     81    item:setProperty("HorzFormatting", queue.alignment)
     82    queue.items[queue.last] = item
     83    queue.last = queue.last+1
    6284
    6385    -- If the queue has been invisible, set it to visible.
     
    7395        return
    7496    end
    75     local listbox = CEGUI.toListbox(queue.window)
    76     -- Removes the item from the bottom of the listbox.
    77     listbox:removeItem(listbox:getListboxItemFromIndex(listbox:getItemCount()-1))
     97    local item = queue.items[queue.first]
     98    -- Removes the item from the bottom of the queue.
     99    queue.window:removeChildWindow(item)
     100    winMgr:destroyWindow(item)
     101    queue.first = queue.first+1
    78102
    79103    -- Sets the queue to invisible if there are no more notifications in it.
    80     if listbox:getItemCount() == 0 then
     104    if queue.last-queue.first == 0 then
    81105        P.setVisible(queue, false)
    82106    end
    83107end
    84108
    85 -- Removes a notification at a given index from the queue.
     109-- Removes a notification at a given index from the queue. Where the 0th item is the newest and the nth the (n+1)th newest.
    86110function P.removeNotification(queueName, index)
    87111    local queue = P.queueList[queueName]
     
    89113        return
    90114    end
    91     local listbox = CEGUI.toListbox(queue.window)
     115
     116    index = queue.last-tonumber(index)-1
     117    --if index == queue.first then -- If we want to remove the oldest notification, we can just use pop.
     118    --    P.popNotification(queueName)
     119    --    return
     120    --end
     121
    92122    -- Removes the item.
    93     listbox:removeItem(listbox:getListboxItemFromIndex(tonumber(index)))
     123    local item = queue.items[index]
     124    queue.window:removeChildWindow(item)
     125    winMgr:destroyWindow(item)
     126    queue.items[index] = nil
     127
     128    -- Move the items below, up.
     129    local itemHeight = P.itemHeightHelper(queue)
     130    local moved = false
     131    if index > queue.first then -- Move all older notifications up in the list.
     132        for i=index-1,-1,queue.first do
     133            cout(0, i)
     134            item = queue.items[i]
     135            item:setYposition(CEGUI.UDim(0, itemHeight*(queue.last-i-1)))
     136            queue.items[i+1] = item
     137        end
     138    end
     139    queue.items[queue.first] = nil
     140    queue.first = queue.first+1
    94141
    95142    -- Sets the queue to invisible if there are no more notifications in it.
    96     if listbox:getItemCount() == 0 then
     143    if queue.last-queue.first == 0 then
    97144        P.setVisible(queue, false)
    98145    end
     
    105152        return
    106153    end
    107     local listbox = CEGUI.toListbox(queue.window)
    108     CEGUI.toListbox(queue.window):resetList()
     154    for i=queue.first,queue.last-1 do
     155        local item = queue.items[i]
     156        queue.window:removeChildWindow(item)
     157        winMgr:destroyWindow(item)
     158    end
     159    queue.items = {}
     160    queue.first = 1
     161    queue.last = 1
    109162
    110163    -- Sets the queue to invisible.
     
    121174end
    122175
    123 -- Enter the edit mode of the notification layer.
    124 function P.enterEditMode()
    125     P.editMode = true
    126 
    127     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    128 
    129     --Add control frame window.
    130     local window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/ControlWindow")
    131     local frame = tolua.cast(window, "CEGUI::FrameWindow")
    132     frame:setCloseButtonEnabled(false)
    133     frame:setText("NotificationLayer Control Window")
    134     frame:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.2, 0)))
    135     root:addChildWindow(window)
    136     local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/ScrollingPane")
    137     pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30)))
    138     pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26)))
    139     window:addChildWindow(pane)
    140 
    141     vertOffset = 0
    142     horzOffset = 0
    143     -- Line to be able to create a new queue.
    144     local newQueueTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueTitle")
    145     newQueueTitle:setText("Create a new NotificationQueue:")
    146     local size = getMinTextSize(newQueueTitle)
    147     local textHeight = size[1]
    148     newQueueTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    149     newQueueTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    150     pane:addChildWindow(newQueueTitle)
    151     horzOffset = horzOffset + size[2] + 5
    152     local newQueueName = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
    153     newQueueName:setProperty("ReadOnly", "set:False")
    154     newQueueName:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    155     newQueueName:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    156     horzOffset = horzOffset + size[2] + 5
    157     pane:addChildWindow(newQueueName)
    158     local create = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/CreateNewQueue")
    159     create:setText("create")
    160     P.sampleWindow:setText("create")
    161     size = getMinTextSize(P.sampleWindow)
    162     create:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight)))
    163     create:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    164     orxonox.GUIManager:subscribeEventHelper(create, "Clicked", P.name .. ".createNewQueue_clicked")
    165     pane:addChildWindow(create)
    166     horzOffset = horzOffset + size[2]+20 + 5
    167     vertOffset = vertOffset + textHeight + 5
    168 
    169     horzOffset = 0
    170     -- Button to leave the edit mode.
    171     local leave = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/ControlWindow/LeaveEditModeButton")
    172     leave:setText("leave Edit Mode")
    173     P.sampleWindow:setText("leave Edit Mode")
    174     size = getMinTextSize(P.sampleWindow)
    175     leave:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]+20), CEGUI.UDim(0, textHeight)))
    176     leave:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    177     orxonox.GUIManager:subscribeEventHelper(leave, "Clicked", P.name .. ".leaveEditMode_clicked")
    178     pane:addChildWindow(leave)
    179     horzOffset = horzOffset + size[2]+20 + 5
    180     vertOffset = vertOffset + textHeight + 5
    181 
    182     --Replace all queues with FrameWindows
    183     for k,v in pairs(P.queueList) do
    184         if v ~= nil then
    185             local queue = P.queueList[k]
    186             -- Remove the window that displays the queue from the root window such that it is no longer displayed.
    187             root:removeChildWindow(v.window)
    188 
    189             -- Create the frame window, with options to edit the queue, that is displayed instead of the queue.
    190             local window = P.createQueueEditFrame(v.name)
    191             window:setArea(v.window:getArea()) -- Set the frame window size and position to the same as the queue.
    192 
    193             v.edit = window
    194         end
    195     end
    196 end
    197 
    198 -- Helper function. Creates a frame for the input queue.
    199 function P.createQueueEditFrame(queueName)
    200     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    201 
    202     window = winMgr:createWindow("MenuWidgets/FrameWindow", "orxonox/NotificationLayer/Root/EditMode/" .. queueName)
    203     local frame = tolua.cast(window, "CEGUI::FrameWindow")
    204     frame:setCloseButtonEnabled(true)
    205     orxonox.GUIManager:subscribeEventHelper(frame, "CloseClicked", P.name .. ".closeQueue_clicked")
    206     frame:setText("NotificationQueue \"" .. queueName .. "\"")
    207     root:addChildWindow(window)
    208     local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/ScrollingPane")
    209     pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,-20), CEGUI.UDim(1,-30)))
    210     pane:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10), CEGUI.UDim(0, 26)))
    211     window:addChildWindow(pane)
    212 
    213     local horzOffset = 0
    214     local vertOffset = 0
    215 
    216     -- The line that lets you edit the targets of the queue.
    217     local targetsTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/TargetsTitle")
    218     targetsTitle:setText("Targets:")
    219     local size = getMinTextSize(targetsTitle)
    220     local textHeight = size[1]
    221     targetsTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    222     targetsTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    223     pane:addChildWindow(targetsTitle)
    224     horzOffset = horzOffset + size[2] + 5
    225     local targets = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets")
    226     targets:setProperty("ReadOnly", "set:False")
    227     local targetsText = orxonox.NotificationManager:getInstance():getQueue(queueName):getTargets()
    228     targets:setText(targetsText)
    229     P.sampleWindow:setText(targetsText)
    230     size = getMinTextSize(P.sampleWindow)
    231     targets:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
    232     targets:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    233     horzOffset = horzOffset + size[2]*2+20 + 5
    234     pane:addChildWindow(targets)
    235     local save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets/Save")
    236     save:setText("save")
    237     P.sampleWindow:setText("save")
    238     size = getMinTextSize(P.sampleWindow)
    239     local saveTextWidth = size[2]+20
    240     save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
    241     save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    242     orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveTargets_clicked")
    243     pane:addChildWindow(save)
    244     horzOffset = horzOffset + saveTextWidth
    245     vertOffset = vertOffset + textHeight + 5
    246 
    247     horzOffset = 0
    248     -- The line that lets you edit the size of the queue.
    249     local sizeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/SizeTitle")
    250     sizeTitle:setText("Size:")
    251     size = getMinTextSize(sizeTitle)
    252     sizeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    253     sizeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    254     pane:addChildWindow(sizeTitle)
    255     horzOffset = horzOffset + size[2] + 5
    256     local queueSize = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size")
    257     queueSize:setProperty("ReadOnly", "set:False")
    258     local maxSize = orxonox.NotificationManager:getInstance():getQueue(queueName):getMaxSize()
    259     queueSize:setText(maxSize)
    260     P.sampleWindow:setText(maxSize)
    261     size = getMinTextSize(P.sampleWindow)
    262     queueSize:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
    263     queueSize:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    264     horzOffset = horzOffset + size[2]*2+20 + 5
    265     pane:addChildWindow(queueSize)
    266     save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size/Save")
    267     save:setText("save")
    268     P.sampleWindow:setText("save")
    269     size = getMinTextSize(P.sampleWindow)
    270     local saveTextWidth = size[2]+20
    271     save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
    272     save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    273     orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveSize_clicked")
    274     pane:addChildWindow(save)
    275     horzOffset = horzOffset + saveTextWidth
    276     vertOffset = vertOffset + textHeight + 5
    277 
    278     horzOffset = 0
    279     -- The line that lets you edit the display time of the queue.
    280     local displayTimeTitle = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTimeTitle")
    281     displayTimeTitle:setText("Display time:")
    282     size = getMinTextSize(displayTimeTitle)
    283     displayTimeTitle:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]), CEGUI.UDim(0, textHeight)))
    284     displayTimeTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    285     pane:addChildWindow(displayTimeTitle)
    286     horzOffset = horzOffset + size[2] + 5
    287     local displayTime = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime")
    288     displayTime:setProperty("ReadOnly", "set:False")
    289     local time = orxonox.NotificationManager:getInstance():getQueue(queueName):getDisplayTime()
    290     displayTime:setText(time)
    291     P.sampleWindow:setText(time)
    292     size = getMinTextSize(P.sampleWindow)
    293     displayTime:setSize(CEGUI.UVector2(CEGUI.UDim(0, size[2]*2+20), CEGUI.UDim(0, textHeight)))
    294     displayTime:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    295     horzOffset = horzOffset + size[2]*2+20 + 5
    296     pane:addChildWindow(displayTime)
    297     save = winMgr:createWindow("MenuWidgets/Button", "orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime/Save")
    298     save:setText("save")
    299     P.sampleWindow:setText("save")
    300     size = getMinTextSize(P.sampleWindow)
    301     local saveTextWidth = size[2]+20
    302     save:setSize(CEGUI.UVector2(CEGUI.UDim(0, saveTextWidth), CEGUI.UDim(0, textHeight)))
    303     save:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horzOffset), CEGUI.UDim(0, vertOffset)))
    304     orxonox.GUIManager:subscribeEventHelper(save, "Clicked", P.name .. ".saveDisplayTime_clicked")
    305     pane:addChildWindow(save)
    306     horzOffset = horzOffset + saveTextWidth
    307     vertOffset = vertOffset + textHeight + 5
    308 
    309     return window
    310 end
    311 
    312 -- Leave the edit mode.
    313 function P.leaveEditMode()
    314     P.editMode = false
    315 
    316     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    317     --Replace all queues with FrameWindows
    318     for k,v in pairs(P.queueList) do
    319         if v ~= nil then
    320             -- Add the queue window to the root window to have it displayed again.
    321             root:addChildWindow(v.window)
    322             -- Set the size and position of the queue window to the size and position of the queue edit frame.
    323             v.window:setArea(v.edit:getArea())
    324             -- Destroy the edit frame.
    325             winMgr:destroyWindow(v.edit)
    326             v.edit = nil
    327         end
    328     end
    329 
    330     --Remove control window
    331     winMgr:destroyWindow(winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow"))
    332 end
    333 
    334 -- Is called after the sheet has been hidden.
    335 function P.onQuit()
    336     -- If we leave the edit mode we show the sheet again.
    337     if P.editMode then
    338         P.leaveEditMode()
    339         showMenuSheet(P.name, false, true)
    340     end
    341 end
    342 
    343 -- If the button to save the targets of a queue has been clicked.
    344 function P. saveTargets_clicked(e)
    345     local we = CEGUI.toWindowEventArgs(e)
    346     local name = we.window:getName()
    347 
    348     local match = string.gmatch(name, "EditMode/.*/Targets/Save")
    349     local nameStr = match()
    350     local queueName = string.sub(nameStr, 10, string.len(nameStr)-13)
    351 
    352     local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets")
    353     local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Targets/Save")
    354     local width = window:getWidth():asAbsolute(1)
    355 
    356     local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
    357     -- Set the new targets.
    358     queue:setTargets(window:getText())
    359     local targets = queue:getTargets()
    360 
    361     window:setText(targets)
    362     P.sampleWindow:setText(targets)
    363     local size = getMinTextSize(P.sampleWindow)
    364     -- Adjust the width of the targets field.
    365     window:setWidth(CEGUI.UDim(0, size[2]*2+20))
    366     -- Adjust the position of the save button after the targets field.
    367     save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
    368 end
    369 
    370 -- If the button to save the size if a queue has been clicked.
    371 function P. saveSize_clicked(e)
    372     local we = CEGUI.toWindowEventArgs(e)
    373     local name = we.window:getName()
    374 
    375     local match = string.gmatch(name, "EditMode/.*/Size/Save")
    376     local nameStr = match()
    377     local queueName = string.sub(nameStr, 10, string.len(nameStr)-10)
    378 
    379     local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size")
    380     local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/Size/Save")
    381     local width = window:getWidth():asAbsolute(1)
    382 
    383     local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
    384     -- Set the new size.
    385     queue:setMaxSize(tonumber(window:getText()))
    386     local maxSize = queue:getMaxSize()
    387 
    388     window:setText(maxSize)
    389     P.sampleWindow:setText(maxSize)
    390     local size = getMinTextSize(P.sampleWindow)
    391     -- Adjust the width of the size field.
    392     window:setWidth(CEGUI.UDim(0, size[2]*2+20))
    393     -- Adjust the position of the save button after the size field.
    394     save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
    395 end
    396 
    397 -- If the button to save the display time if a queue has been clicked.
    398 function P. saveDisplayTime_clicked(e)
    399     local we = CEGUI.toWindowEventArgs(e)
    400     local name = we.window:getName()
    401 
    402     local match = string.gmatch(name, "EditMode/.*/DisplayTime/Save")
    403     local nameStr = match()
    404     local queueName = string.sub(nameStr, 10, string.len(nameStr)-17)
    405 
    406     local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime")
    407     local save = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/" .. queueName .. "/DisplayTime/Save")
    408     local width = window:getWidth():asAbsolute(1)
    409 
    410     local queue = orxonox.NotificationManager:getInstance():getQueue(queueName)
    411     -- Set the new display time.
    412     queue:setDisplayTime(tonumber(window:getText()))
    413     local time = queue:getDisplayTime()
    414 
    415     window:setText(time)
    416     P.sampleWindow:setText(time)
    417     local size = getMinTextSize(P.sampleWindow)
    418     -- Adjust the width of the display time field.
    419     window:setWidth(CEGUI.UDim(0, size[2]*2+20))
    420     -- Adjust the position of the save button after the display time field.
    421     save:setXPosition(CEGUI.UDim(0, save:getXPosition():asAbsolute(1)-width+window:getWidth():asAbsolute(1)))
    422 end
    423 
    424 -- if the button to create a new queue has been clicked.
    425 function P.createNewQueue_clicked(e)
    426     local window = winMgr:getWindow("orxonox/NotificationLayer/Root/EditMode/ControlWindow/NewQueueName")
    427     local name = window:getText()
    428 
    429     local queue = P.queueList[name]
    430     -- Test if a queue with that name already exists.
    431     if queue ~= nil then
    432         window:setText("Queue with that name already exists.")
    433         return
    434     end
    435 
    436     -- Creates the new queue.
    437     orxonox.NotificationManager:getInstance():createQueue(name)
    438 
    439     queue = P.queueList[name]
    440     if queue == nil then
    441         return
    442     end
    443 
    444     -- Create the frame that represents the queue in edit mode, since that's what we're in.
    445     local frame = P.createQueueEditFrame(name)
    446     local root = winMgr:getWindow("orxonox/NotificationLayer/Root")
    447     -- Remove the queue window from the root window, since we're in edit mode.
    448     root:removeChildWindow(queue.window)
    449     -- Set the frame window size and position to that of the queue window.
    450     frame:setArea(queue.window:getArea())
    451     queue.edit = frame
    452 
    453     -- Reset the text to create a new queue.
    454     window:setText("")
    455 end
    456 
    457 -- If the button to leave the edit mode has been clicked.
    458 function P.leaveEditMode_clicked(e)
    459     hideMenuSheet(P.name)
    460 end
    461 
    462 -- If the button to close the queue has been clicked.
    463 function P.closeQueue_clicked(e)
    464     local we = CEGUI.toWindowEventArgs(e)
    465     local name = we.window:getName()
    466 
    467     local match = string.gmatch(name, "EditMode/.*")
    468     local nameStr = match()
    469     local queueName = string.sub(nameStr, 10, string.len(nameStr))
    470 
    471     -- Destroy the frame window,
    472     winMgr:destroyWindow(P.queueList[queueName].edit)
    473     P.queueList[queueName].edit = nil
    474     -- Destroy the queue.
    475     orxonox.NotificationManager:getInstance():getQueue(queueName):destroy()
     176-- Change the position of the queue.
     177-- 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'.
     178function P.moveQueue(queueName, relativeXPos, absoluteXPos, relativeYpos, absoluteYPos)
     179    local queueWindow = P.queueList[queueName].window
     180    queueWindow:setPosition(CEGUI.UVector2(CEGUI.UDim(relativeXPos, absoluteXPos), CEGUI.UDim(relativeYpos, absoluteYPos)))
     181end
     182
     183-- Change the size of the queue.
     184-- 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 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.
     186function P.resizeQueue(queueName, relativeWidth, absoluteWidth, relativeHeight, absoluteHeigth)
     187    local queue = P.queueList[queueName]
     188    local queueWindow = queue.window
     189    if queueWindow == nil then
     190        return
     191    end
     192    if absoluteHeigth == nil then
     193        absoluteHeigth = P.queueHeightHelper(queue, queue.maxSize)
     194        relativeHeight = 0
     195    end
     196    queueWindow:setSize(CEGUI.UVector2(CEGUI.UDim(relativeWidth, absoluteWidth), CEGUI.UDim(relativeHeight, absoluteHeigth)))
     197end
     198
     199-- Change the horizontal alignment of the displayed notifications.
     200-- The parameters are the name of the queue and the alignment parameter,
     201function P.changeQueueAlignment(queueName, alignment)
     202    local queue = P.queueList[queueName]
     203    local queueWindow = queue.window
     204    if queueWindow == nil then
     205        return
     206    end
     207
     208    queue.alignment = alignment
     209    local item = nil
     210    for i=queue.first,queue.last-1 do
     211        item = queue.items[i]
     212        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)
     243    end
     244end
     245
     246-- Helper function to set the font size and color of a item of a queue.
     247-- The parameters are (in order) 'the ListboxItem', 'the queue table', 'whether color should be changed as well'
     248function P.setItemFontHelper(item, queue, changeColor)
     249    --local item = tolua.cast(item, "CEGUI::ListboxTextItem")
     250    local fontMgr = CEGUI.FontManager:getSingleton()
     251    if fontMgr:isFontPresent("BlueHighway-" .. queue.fontSize) then
     252        item:setFont("BlueHighway-" .. queue.fontSize)
     253    else
     254        orxonox.GUIManager:addFontHelper("BlueHighway-" .. queue.fontSize, queue.fontSize, "bluehigh.ttf")
     255        item:setFont("BlueHighway-" .. queue.fontSize)
     256    end
     257    if changeColor then
     258        item:setProperty("TextColours", "tl:" .. queue.fontColor .. " tr:" .. queue.fontColor .. " bl:" .. queue.fontColor .. " br:" .. queue.fontColor .. "")
     259    end
    476260end
    477261
    478262-- Helper function. Returns height a queue needs to have to display 'size' items.
    479263function P.queueHeightHelper(queue, size)
    480     local listbox = CEGUI.toListbox(queue)
    481     local item = CEGUI.createListboxTextItem("Text")
    482     listbox:addItem(item)
    483     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:getUnclippedOuterRect():getHeight() - formattedArea:getHeight()
    487     listbox:removeItem(item)
    488     return frameHeight + singleItemHeight*size
     264    --local listbox = CEGUI.toListbox(queue.window)
     265    --local item = CEGUI.createListboxTextItem("Text")
     266    --P.setItemFontHelper(item, queue, false)
     267    --listbox:addItem(item)
     268    --local singleItemHeight = listbox:getTotalItemsHeight()
     269    local singleItemHeight = P.itemHeightHelper(queue)
     270    --local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(queue.window:getLookNFeel())
     271    --local formattedArea = lookAndFeel:getNamedArea("ItemRenderingArea"):getArea():getPixelRect(queue.window)
     272    --local frameHeight = queue.window:getUnclippedOuterRect():getHeight() - formattedArea:getHeight()
     273    --listbox:removeItem(item)
     274    --return frameHeight + singleItemHeight*size
     275    return singleItemHeight*size + 1
     276end
     277
     278function P.itemHeightHelper(queue)
     279    local item = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/NotificationLayer/Root/Test/")
     280    item:setText("text")
     281    P.setItemFontHelper(item, queue, true)
     282    queue.window:addChildWindow(item)
     283    item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(1, 0)))
     284    item:setProperty("FrameEnabled", "false")
     285    local height = getStaticTextWindowHeight(item)
     286    queue.window:removeChildWindow(item)
     287    winMgr:destroyWindow(item)
     288    return height
    489289end
    490290
  • code/branches/tutoriallevel3/data/gui/scripts/QuestGUI.lua

    r7732 r8453  
    33local P = createMenuSheet("QuestGUI")
    44
    5 P.rootWindow = nil
    6 P.detailsWindows = {}
     5P.questManager = nil -- The QuestManager.
     6P.showActive = true -- Whether the active or finished quest list is displayed.
     7P.currentQuest = nil -- The quest that is currently displayed.
     8P.player = nil -- The player the quests are displayed for.
    79P.quests = {}
    8 P.hints = {}
    9 P.player = nil
     10P.subquests = {}
    1011
    1112-- design parameters
    12 P.indentWidth = 20
    1313P.scrollbarWidth = 13
    14 P.buttonHeight = 30
     14P.frameHeigth = 18
     15P.borderSize = 5
    1516P.titleHeight = 26
    16 P.borderWidth = 5
     17
     18--TODO:
     19-- Highlight whether we are currently looking at active or finished quests
     20-- Distinguish completed from failed quests
     21
     22function P.onLoad()
     23    P.questManager = orxonox.QuestManager:getInstance() -- Store the pointer to the QuestManager as an internal variable to allow for faster access,
     24end
    1725
    1826function P.onShow()
    19 
    20     local questsList = winMgr:getWindow("orxonox/QuestGUI/QuestsList")
    21 
     27    -- Get the player.
    2228    P.player = orxonox.GUIManager:getInstance():getPlayer(P.name)
    23     P.rootWindow = P.createQuestGUI()
    24 
    25     questsList:addChildWindow(P.rootWindow)
    26 end
    27 
    28 function P.onHide()
    29     P.cleanup()
    30 end
    31 
     29
     30    -- Load the list of quests to be displayed.
     31    P.loadQuestsList(P.currentQuest)
     32end
     33
     34-- Loads the list of quests, depending on P.showActive, either the active (P.showActive == true) or the finished, i.e. inactive quests are loaded.
     35-- selectQuest is a pointer to a quest that should be selected, if it is nil the first quest is selected.
     36function P.loadQuestsList(selectQuest)
     37    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList"))
     38    P.clearQuestList()
     39
     40    local selectQuestId = nil
     41    if selectQuest ~= nil then
     42        selectQuestId = P.questManager:getId(selectQuest)
     43    end
     44
     45    -- Iterate through all root-quests.
     46    local numRootQuests = P.questManager:getNumRootQuests(P.player)
     47    if numRootQuests > 0 then
     48        local i = 0
     49        while i <= numRootQuests-1 do
     50            local quest = P.questManager:getRootQuest(P.player, i)
     51            -- Insert the current quest into the list.
     52            local item = P.insertQuest(list, quest)
     53            -- If the quest was inserted in the list and is has the same id as the selectQuest (thus it is the same quest) it is selected.
     54            if selectQuestId ~= nil and item ~= nil and selectQuestId == P.questManager:getId(quest) then
     55                list:setItemSelectState(item, true)
     56            end
     57            -- Insert all subquests of this rootquest.
     58            P.insertSubQuests(list, quest, selectQuestId)
     59            i = i+1
     60        end
     61        -- If there were quests added to the list but there was no selectQuest specified (i.e. selectQuest was nil), the first item is selected.
     62        if list:getItemCount() > 0 then
     63            if selectQuestId == nil then
     64                list:setItemSelectState(list:getListboxItemFromIndex(0), true)  -- Select first quest.
     65            end
     66        -- If there werent any quests added the standard "no quests" message is loaded.
     67        else
     68            P.loadQuest()
     69        end
     70    end
     71end
     72
     73-- Helper function, recursively inserts all the (active or inactive, depending on P.showActive) subquests of the input quest.
     74-- list is the list into which the subquests should be insterted.
     75-- quest is the quest, whose subquests should be inserted.
     76-- selectQuestId is the id of the quest that should be selected.
     77function P.insertSubQuests(list, quest, selectQuestId)
     78    -- Iterate through all sub-quests.
     79    local numQuests = P.questManager:getNumSubQuests(quest, P.player)
     80    if numQuests > 0 then
     81        local i = 0
     82        while i <= numQuests-1 do
     83            local subquest = P.questManager:getSubQuest(quest, P.player, i)
     84            -- Insert the current quest into the list.
     85            local item = P.insertQuest(list, subquest)
     86            -- If the quest was inserted in the list and is has the same id as the selectQuest (thus it is the same quest) it is selected.
     87            if selectQuestId ~= nil and item ~= nil and selectQuestId == P.questManager:getId(subquest) then
     88                list:setItemSelectState(item, true)
     89            end
     90            i = i+1
     91        end
     92    end
     93end
     94
     95-- Helper function, inserts a quest into the list (depending whether active or inactive quests are being shown). Returns nil if the quest was not inserted.
     96-- list is the list into which the quets should be inserted.
     97-- quest is the quest to be inserted.
     98function P.insertQuest(list, quest)
     99    if P.showActive == quest:isActive(P.player) then
     100        local item = CEGUI.createListboxTextItem(P.questManager:getDescription(quest):getTitle())
     101        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     102        list:addItem(item)
     103        table.insert(P.quests, quest)
     104        return item
     105    end
     106    return nil
     107end
     108
     109-- Loads the input quest.
     110-- quest the quest to be loaded.
     111function P.loadQuest(quest)
     112
     113    P.clearQuest() -- Clear the old quest.
     114    if quest == nil then -- If quets is nil there is nothing to display.
     115        return
     116    else
     117        local offset = 0
     118
     119        -- Load title and description
     120        local description = P.questManager:getDescription(quest)
     121        local titleWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Title")
     122        titleWindow:setText(description:getTitle())
     123        local descriptionWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Description")
     124        descriptionWindow:setText(description:getDescription())
     125        descriptionWindow:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize), CEGUI.UDim(1, 0)))
     126        descriptionWindow:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, P.borderSize)))
     127        local height = getStaticTextWindowHeight(descriptionWindow)
     128        descriptionWindow:setHeight(CEGUI.UDim(0, height))
     129        offset = offset + height
     130
     131        -- Load subquests
     132        local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/Quest/SubquestsList"))
     133        local numQuests = P.questManager:getNumSubQuests(quest, P.player)
     134        local i = 0
     135        while i <= numQuests-1 do
     136            local quest = P.questManager:getSubQuest(quest, P.player, i)
     137            local item = CEGUI.createListboxTextItem(P.questManager:getDescription(quest):getTitle())
     138            item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     139            list:addItem(item)
     140            table.insert(P.subquests, quest)
     141            i = i+1
     142        end
     143        height = list:getTotalItemsHeight()
     144        if height > 0 then
     145            height = height+P.frameHeigth
     146        end
     147        list:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize), CEGUI.UDim(0, height)))
     148        list:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, offset)))
     149        offset = offset + height + P.borderSize
     150
     151        -- Load hints
     152        local hintsWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Hints")
     153        hintsWindow:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, offset)))
     154        hintsWindow:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize), CEGUI.UDim(0, 0)))
     155        height = P.titleHeight
     156        local numHints = P.questManager:getNumHints(quest, P.player)
     157        local i = 0
     158        while i <= numHints-1 do
     159            local hint = P.questManager:getHints(quest, P.player, i)
     160            height = height + P.insertHint(hintsWindow, hint, i, height)
     161            i = i+1
     162        end
     163        if numHints == 0 then
     164            height = 0
     165        end
     166        hintsWindow:setHeight(CEGUI.UDim(0, height))
     167        offset = offset + height
     168
     169        -- Set the size of the wrapper
     170        local window = winMgr:getWindow("orxonox/QuestGUI/Quest/Wrapper")
     171        window:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize-P.scrollbarWidth), CEGUI.UDim(0,offset+P.borderSize)))
     172    end
     173
     174    P.currentQuest = quest
     175end
     176
     177-- Clear the currently displayed quest.
     178function P.clearQuest()
     179    -- clear title
     180    local titleWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Title")
     181    titleWindow:setText("no Quests")
     182
     183    -- clear description
     184    local descriptionWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Description")
     185    descriptionWindow:setText("There is currently no quest that can be displayed.")
     186
     187    -- clear list fo subquests
     188    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/Quest/SubquestsList"))
     189    list:resetList()
     190    list:setHeight(CEGUI.UDim(0, 0))
     191    P.subquests = {}
     192
     193    -- clear hints
     194    local hints = winMgr:getWindow("orxonox/QuestGUI/Quest/Hints")
     195    local numChildren = hints:getChildCount()-2 -- TODO: HACK
     196    local i = 0
     197    while i < numChildren do
     198        local hint = hints:getChild("orxonox/QuestGUI/Quest/Hints/" .. i)
     199        if hint ~= nil then
     200            hints:removeChildWindow(hint)
     201            winMgr:destroyWindow(hint)
     202        end
     203        i = i+1
     204    end
     205    hints:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth-P.borderSize), CEGUI.UDim(0, 0)))
     206
     207    P.currentQuest = nil
     208end
     209
     210-- Clear the quests list
     211function P.clearQuestList()
     212    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList"))
     213    list:resetList()
     214    P.quests = {}
     215end
     216
     217-- Select an input quest in the input list.
     218-- list is the list in which the input quest is to be selected.
     219-- quest is the quest to be selected.
     220function P.selectQuest(list, quest)
     221    if quest == nil then -- If the input quest is nil, there is nothing to be selected, an error is output and the first quest is selected instead.
     222        cout(1, "Error in QuestGUI: selectQuest(), input quest is nil. Selecting first.")
     223        list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first
     224        return
     225    end
     226
     227    local questId = P.questManager:getId(quest)
     228    local found = false
     229    local index = 0
     230    -- Iterate over all quests currently in the list.
     231    for k,v in pairs(P.quests) do
     232        -- If the id's are the same we have found the quest.
     233        if P.questManager:getId(v) == questId then
     234            found = true
     235            index = k-1
     236        end
     237    end
     238
     239    if found then -- If the quest was found it is selected.
     240        list:setItemSelectState(list:getListboxItemFromIndex(index), true)
     241    else -- If the quest isn't found an error is output and the first quest is selected instead.
     242        cout(1, "Error in QuestGUI: selectQuest(), input quest is not in list. Selecting first.")
     243        list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first
     244    end
     245end
     246
     247-- Helper function, insert the input hint into the input hintsWindow. Returns the height of the newly inserted hint.
     248-- hintsWindow is the window in which the hint is to be inserted.
     249-- hint is the hint to be inserted.
     250-- index is the index of the hint.
     251-- offset is the current offset in the hintsWindow.
     252function P.insertHint(hintsWindow, hint, index, offset)
     253    -- Create the window for the hint.
     254    local window = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/QuestGUI/Quest/Hints/" .. index)
     255    window:setProperty("HorzFormatting", "WordWrapLeftAligned")
     256    window:setProperty("VertFormatting", "TopAligned")
     257    window:setProperty("FrameEnabled", "false")
     258    window:setID(index)
     259    hintsWindow:addChildWindow(window)
     260    local description = P.questManager:getDescription(hint)
     261    window:setText(description:getDescription())
     262    window:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize), CEGUI.UDim(1, 0)))
     263    local height = getStaticTextWindowHeight(window)
     264    window:setHeight(CEGUI.UDim(0, height))
     265    window:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, offset)))
     266    return height
     267end
     268
     269-- Show the currently active quests in the quests list.
     270function P.showActiveQuestsButton_clicked(e)
     271    if P.showActive == false then
     272        P.showActive = true
     273        P.loadQuestsList()
     274    end
     275end
     276
     277-- Show the finished (i.e. inactive) quests in the quests list.
     278function P.showFinishedQuestsButton_clicked(e)
     279    if P.showActive == true then
     280        P.showActive = false
     281        P.loadQuestsList()
     282    end
     283end
     284
     285-- Change to a new quest.
     286function P.changeQuest_clicked(e)
     287    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList"))
     288    local choice = list:getFirstSelectedItem()
     289    if choice ~= nil then
     290        local index = list:getItemIndex(choice)
     291        local quest = P.quests[index+1]
     292        if quest ~= nil then
     293            P.loadQuest(quest)
     294        end
     295    end
     296end
     297
     298-- Change to a new subquest.
     299function P.changeToSubquest_clicked(e)
     300    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/Quest/SubquestsList"))
     301    local questsList = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList"))
     302    local choice = list:getFirstSelectedItem()
     303    if choice ~= nil then
     304        local index = list:getItemIndex(choice)
     305        local quest = P.subquests[index+1]
     306        if quest ~= nil then
     307            -- If the P.showActive must be changed to display the quest the quests list also has to be regenerated.
     308            if quest:isActive(P.player) == P.showActive then
     309                P.selectQuest(questsList, quest)
     310            else
     311                P.showActive = quest:isActive(P.player)
     312                P.loadQuestsList(quest)
     313            end
     314        else
     315            cout(1, "Error in QuestGUI: changeToSubquest(), quest was nil. Ignoring...")
     316        end
     317    end
     318end
     319
     320-- old:
     321--[[
    32322function P.createQuestGUI()
    33323    local questManager = orxonox.QuestManager:getInstance()
     
    283573    winMgr:destroyWindow(P.detailsWindows[detailsNr])
    284574    P.detailsWindows[detailsNr] = nil
    285 end
     575end --]]
    286576
    287577return P
  • code/branches/tutoriallevel3/data/gui/scripts/SingleplayerMenu.lua

    r8079 r8453  
    5454        index = index + 1
    5555    end
     56
    5657    for k,v in pairs(P.levelList) do
    5758        local item = CEGUI.createListboxTextItem(v:getName())
Note: See TracChangeset for help on using the changeset viewer.