[11401] | 1 | --[[local P = createMenuSheet("Dialogue Window") |
---|
| 2 | |
---|
| 3 | function P.onLoad() |
---|
| 4 | P.createWindow() |
---|
| 5 | P.showing = true |
---|
| 6 | end |
---|
| 7 | function function_name( ... ) |
---|
| 8 | -- body |
---|
| 9 | end |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | function P.createWindow() |
---|
| 15 | |
---|
| 16 | local question = orxonox.DialogueManager:getInstance():getquestion() |
---|
| 17 | local default = (winMgr:createWindow("DefaultWindow")) |
---|
| 18 | default:setText(question) |
---|
| 19 | default:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}") |
---|
| 20 | default:setProperty("UnifiedAreaRect", "{{0,0},{0,0},{1,0},{1,0}}") |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | end |
---|
| 27 | local numOptions = DialogueManager:getnumOptions() |
---|
| 28 | local counter = 1 |
---|
| 29 | local offset = 0 |
---|
| 30 | --create and name buttons while there are still options |
---|
| 31 | while counter <= numOptions do |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | end]] |
---|
| 35 | -- Dialogue.lua |
---|
| 36 | |
---|
[11406] | 37 | local P = createMenuSheet("Dialogue") |
---|
[11401] | 38 | |
---|
| 39 | P.wrapper = nil |
---|
| 40 | P.detailsWindows = {} |
---|
| 41 | P.detailPickups = {} |
---|
| 42 | P.pickupsList = {} |
---|
| 43 | |
---|
| 44 | P.showing = false |
---|
| 45 | |
---|
| 46 | -- Design parameters |
---|
| 47 | P.imageHeight = 50 |
---|
| 48 | P.detailImageSize = 100 |
---|
| 49 | P.textHeight = 30 |
---|
| 50 | P.buttonWidth = 85 |
---|
| 51 | |
---|
| 52 | function P.onLoad() |
---|
| 53 | orxout("loading") |
---|
| 54 | P.wrapper = nil |
---|
| 55 | P.detailsWindows = {} |
---|
| 56 | P.detailPickups = {} |
---|
| 57 | P.pickupsList = {} |
---|
| 58 | end |
---|
| 59 | |
---|
| 60 | function P.onShow() |
---|
| 61 | orxout("showing") |
---|
| 62 | P.createInventory() |
---|
| 63 | P.showing = true |
---|
| 64 | end |
---|
| 65 | |
---|
| 66 | function P.onHide() |
---|
| 67 | P.showing = false |
---|
| 68 | P.cleanup(true) |
---|
| 69 | end |
---|
| 70 | |
---|
| 71 | function P.update() |
---|
| 72 | if P.showing == false then |
---|
| 73 | return |
---|
| 74 | end |
---|
| 75 | |
---|
| 76 | -- Update opened detail windows. |
---|
[11406] | 77 | |
---|
[11401] | 78 | |
---|
| 79 | -- Update main inventory. |
---|
| 80 | P.cleanup(false) |
---|
| 81 | P.createInventory() |
---|
| 82 | -- TODO: Recover scrolling position |
---|
| 83 | |
---|
| 84 | end |
---|
| 85 | |
---|
| 86 | function P.createInventory() |
---|
[11406] | 87 | local pickupManager = orxonox.DialogueManager:getInstance() |
---|
[11401] | 88 | |
---|
[11406] | 89 | local root = winMgr:getWindow("orxonox/Dialogue/Inventory") |
---|
| 90 | local question = orxonox.DialogueManager:getInstance():getquestion() |
---|
| 91 | root:setText(question) |
---|
| 92 | P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper") |
---|
[11401] | 93 | P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0))) |
---|
| 94 | root:addChildWindow(P.wrapper) |
---|
| 95 | |
---|
[11413] | 96 | |
---|
| 97 | local detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton") |
---|
| 98 | local a1 = orxonox.DialogueManager:getInstance():getanswers1() |
---|
[11415] | 99 | detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.25, 0))) |
---|
| 100 | detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, 575), CEGUI.UDim(0, P.textHeight))) |
---|
[11413] | 101 | detailsButton:setText(a1) |
---|
| 102 | orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".a1Button_clicked") |
---|
[11415] | 103 | P.wrapper:addChildWindow(detailsButton) |
---|
[11401] | 104 | |
---|
[11413] | 105 | local a2Button = winMgr:createWindow("MenuWidgets/Button", "/a2Button") |
---|
| 106 | local a2 = orxonox.DialogueManager:getInstance():getanswers2() |
---|
[11415] | 107 | a2Button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.4, 0))) |
---|
| 108 | a2Button:setSize(CEGUI.UVector2(CEGUI.UDim(0, 575), CEGUI.UDim(0, P.textHeight))) |
---|
[11413] | 109 | a2Button:setText(a2) |
---|
| 110 | orxonox.GUIManager:subscribeEventHelper(a2Button, "Clicked", P.name ..".a2Button_clicked") |
---|
[11415] | 111 | P.wrapper:addChildWindow(a2Button) |
---|
[11413] | 112 | |
---|
| 113 | |
---|
[11401] | 114 | end |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | function P.cleanup(destroyDetails) |
---|
| 119 | if P.wrapper ~= nil then |
---|
| 120 | winMgr:destroyWindow(P.wrapper) |
---|
| 121 | end |
---|
| 122 | |
---|
| 123 | --Destroy details windows. |
---|
| 124 | if destroyDetails == false then |
---|
| 125 | return |
---|
| 126 | end |
---|
| 127 | for k,v in pairs(P.detailsWindows) do |
---|
| 128 | if v ~= nil then |
---|
| 129 | P.destroyDetailWindow(k) |
---|
| 130 | end |
---|
| 131 | end |
---|
| 132 | end |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | |
---|
[11413] | 136 | function P.a1Button_clicked(e) |
---|
| 137 | orxonox.DialogueManager:getInstance():a1clicked() |
---|
[11401] | 138 | end |
---|
| 139 | |
---|
[11413] | 140 | function P.a2Button_clicked(e) |
---|
[11415] | 141 | orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue") |
---|
[11413] | 142 | end |
---|
| 143 | |
---|
[11401] | 144 | return P |
---|