Line | |
---|
1 | -- DockingDialog.lua |
---|
2 | |
---|
3 | local P = createMenuSheet("DockingDialog") |
---|
4 | |
---|
5 | P.docks = {} |
---|
6 | |
---|
7 | function P.onLoad() |
---|
8 | |
---|
9 | --button are arranged in a 1x2 matrix |
---|
10 | P:setButton(1, 1, { |
---|
11 | ["button"] = winMgr:getWindow("orxonox/DockingDockButton"), |
---|
12 | ["callback"] = P.dockButton_clicked |
---|
13 | }) |
---|
14 | |
---|
15 | P:setButton(1, 2, { |
---|
16 | ["button"] = winMgr:getWindow("orxonox/DockingCancelButton"), |
---|
17 | ["callback"] = P.cancelButton_clicked |
---|
18 | }) |
---|
19 | |
---|
20 | end |
---|
21 | |
---|
22 | function P.onShow() |
---|
23 | orxonox.execute("setPause 1") |
---|
24 | P.update() |
---|
25 | end |
---|
26 | |
---|
27 | function P.onHide() |
---|
28 | orxonox.execute("setPause 0") |
---|
29 | end |
---|
30 | |
---|
31 | function 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/DockingDocks")) |
---|
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 | end |
---|
47 | end |
---|
48 | |
---|
49 | function P.dockButton_clicked(e) |
---|
50 | local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/DockingDocks")) |
---|
51 | local choice = listbox:getFirstSelectedItem() |
---|
52 | if choice ~= nil then |
---|
53 | local index = listbox:getItemIndex(choice) |
---|
54 | local dock = P.docks[index+1] |
---|
55 | if dock ~= nil then |
---|
56 | dock:dock() |
---|
57 | end |
---|
58 | end |
---|
59 | hideMenuSheet(P.name) |
---|
60 | end |
---|
61 | |
---|
62 | function P.cancelButton_clicked(e) |
---|
63 | hideMenuSheet(P.name) |
---|
64 | end |
---|
65 | |
---|
66 | return P |
---|
Note: See
TracBrowser
for help on using the repository browser.