Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/UndockingDialog.lua @ 11476

Last change on this file since 11476 was 9943, checked in by landauf, 11 years ago

eol-style native

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1-- DockingDialog.lua
2
3local P = createMenuSheet("UndockingDialog")
4
5P.docks = {}
6
7function P.onLoad()
8
9     --button are arranged in a 1x2 matrix
10    P:setButton(1, 1, {
11            ["button"] = winMgr:getWindow("orxonox/Undocking/DockButton"),
12            ["callback"]  = P.undockButton_clicked
13    })
14
15    P:setButton(1, 2, {
16            ["button"] = winMgr:getWindow("orxonox/Undocking/CancelButton"),
17            ["callback"]  = P.cancelButton_clicked
18    })
19   
20end
21
22function P.onShow()
23    orxonox.execute("setPause 1")
24    P.update()
25end
26
27function P.onHide()
28    orxonox.execute("setPause 0")
29end
30
31function P.update()
32    -- update dock list
33    P.docks = {}
34    local docks = orxonox.Dock:getNumberOfActiveDocks()
35    for i = 0, docks-1 do
36        table.insert(P.docks, orxonox.Dock:getActiveDockAtIndex(i))
37    end
38
39    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/Undocking/Docks"))
40    listbox:resetList()
41
42    for k in pairs(P.docks) do
43        local item = CEGUI.createListboxTextItem("Dock " .. k)
44        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
45        listbox:addItem(item)
46        if k == 1 then
47            listbox:setItemSelectState(item, true)
48        end
49    end
50end
51
52function P.undockButton_clicked(e)
53    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/Undocking/Docks"))
54    local choice = listbox:getFirstSelectedItem()
55    if choice ~= nil then
56        local index = listbox:getItemIndex(choice)
57        local dock = P.docks[index+1]
58        if dock ~= nil then
59            dock:undock()
60        end
61    end
62    hideMenuSheet(P.name)
63end
64
65function P.cancelButton_clicked(e)
66    hideMenuSheet(P.name)
67end
68
69return P
Note: See TracBrowser for help on using the repository browser.