Last change
on this file since 12153 was
11806,
checked in by landauf, 7 years ago
|
migrated all ingame menus to cegui 0.8
|
-
Property svn:eol-style set to
native
|
File size:
1.6 KB
|
Rev | Line | |
---|
[8434] | 1 | -- DockingDialog.lua |
---|
| 2 | |
---|
| 3 | local P = createMenuSheet("DockingDialog") |
---|
| 4 | |
---|
| 5 | P.docks = {} |
---|
| 6 | |
---|
| 7 | function P.onLoad() |
---|
[8500] | 8 | |
---|
| 9 | --button are arranged in a 1x2 matrix |
---|
| 10 | P:setButton(1, 1, { |
---|
[11806] | 11 | ["button"] = P.window:getChild("DockButton"), |
---|
[8500] | 12 | ["callback"] = P.dockButton_clicked |
---|
| 13 | }) |
---|
| 14 | |
---|
| 15 | P:setButton(1, 2, { |
---|
[11806] | 16 | ["button"] = P.window:getChild("CancelButton"), |
---|
[8500] | 17 | ["callback"] = P.cancelButton_clicked |
---|
| 18 | }) |
---|
[8434] | 19 | |
---|
| 20 | end |
---|
| 21 | |
---|
| 22 | function P.onShow() |
---|
[8493] | 23 | orxonox.execute("setPause 1") |
---|
[8434] | 24 | P.update() |
---|
| 25 | end |
---|
| 26 | |
---|
| 27 | function P.onHide() |
---|
[8493] | 28 | orxonox.execute("setPause 0") |
---|
[8434] | 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 | |
---|
[11806] | 39 | local listbox = CEGUI.toListbox(P.window:getChild("Title/Docks")) |
---|
[8434] | 40 | listbox:resetList() |
---|
| 41 | |
---|
| 42 | for k in pairs(P.docks) do |
---|
| 43 | local item = CEGUI.createListboxTextItem("Dock " .. k) |
---|
[11795] | 44 | item:setSelectionBrushImage(menuImageSet .. "/MultiListSelectionBrush") |
---|
[8434] | 45 | listbox:addItem(item) |
---|
[8568] | 46 | if k == 1 then |
---|
| 47 | listbox:setItemSelectState(item, true) |
---|
| 48 | end |
---|
[8434] | 49 | end |
---|
| 50 | end |
---|
| 51 | |
---|
| 52 | function P.dockButton_clicked(e) |
---|
[11806] | 53 | local listbox = CEGUI.toListbox(P.window:getChild("Title/Docks")) |
---|
[8434] | 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:dock() |
---|
| 60 | end |
---|
| 61 | end |
---|
| 62 | hideMenuSheet(P.name) |
---|
| 63 | end |
---|
| 64 | |
---|
| 65 | function P.cancelButton_clicked(e) |
---|
| 66 | hideMenuSheet(P.name) |
---|
| 67 | end |
---|
| 68 | |
---|
| 69 | return P |
---|
Note: See
TracBrowser
for help on using the repository browser.