[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() |
---|
[11433] | 53 | |
---|
[11401] | 54 | orxout("loading") |
---|
| 55 | P.wrapper = nil |
---|
| 56 | P.detailsWindows = {} |
---|
| 57 | P.detailPickups = {} |
---|
| 58 | P.pickupsList = {} |
---|
| 59 | end |
---|
| 60 | |
---|
| 61 | function P.onShow() |
---|
| 62 | orxout("showing") |
---|
[11433] | 63 | orxonox.CommandExecutor:execute("setTimeFactor 0") |
---|
[11401] | 64 | P.createInventory() |
---|
| 65 | P.showing = true |
---|
[11433] | 66 | |
---|
[11401] | 67 | end |
---|
| 68 | |
---|
| 69 | function P.onHide() |
---|
[11433] | 70 | orxonox.CommandExecutor:execute("setTimeFactor 1") |
---|
[11401] | 71 | P.showing = false |
---|
| 72 | P.cleanup(true) |
---|
| 73 | end |
---|
| 74 | |
---|
| 75 | function P.update() |
---|
[11421] | 76 | orxout("UPDATING") |
---|
[11422] | 77 | P.updateInventory() |
---|
[11401] | 78 | if P.showing == false then |
---|
| 79 | return |
---|
| 80 | end |
---|
| 81 | |
---|
| 82 | -- Update opened detail windows. |
---|
[11406] | 83 | |
---|
[11401] | 84 | |
---|
| 85 | -- Update main inventory. |
---|
| 86 | P.cleanup(false) |
---|
| 87 | P.createInventory() |
---|
| 88 | -- TODO: Recover scrolling position |
---|
| 89 | |
---|
| 90 | end |
---|
| 91 | |
---|
| 92 | function P.createInventory() |
---|
[11433] | 93 | |
---|
[11406] | 94 | local pickupManager = orxonox.DialogueManager:getInstance() |
---|
[11401] | 95 | |
---|
[11422] | 96 | root = winMgr:getWindow("orxonox/Dialogue/Inventory") |
---|
[11406] | 97 | local question = orxonox.DialogueManager:getInstance():getquestion() |
---|
| 98 | root:setText(question) |
---|
| 99 | P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper") |
---|
[11401] | 100 | P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0))) |
---|
| 101 | root:addChildWindow(P.wrapper) |
---|
| 102 | |
---|
[11413] | 103 | |
---|
[11422] | 104 | detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton") |
---|
[11413] | 105 | local a1 = orxonox.DialogueManager:getInstance():getanswers1() |
---|
[11415] | 106 | detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.25, 0))) |
---|
| 107 | detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, 575), CEGUI.UDim(0, P.textHeight))) |
---|
[11413] | 108 | detailsButton:setText(a1) |
---|
| 109 | orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".a1Button_clicked") |
---|
[11415] | 110 | P.wrapper:addChildWindow(detailsButton) |
---|
[11401] | 111 | |
---|
[11422] | 112 | a2Button = winMgr:createWindow("MenuWidgets/Button", "/a2Button") |
---|
[11413] | 113 | local a2 = orxonox.DialogueManager:getInstance():getanswers2() |
---|
[11415] | 114 | a2Button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.4, 0))) |
---|
| 115 | a2Button:setSize(CEGUI.UVector2(CEGUI.UDim(0, 575), CEGUI.UDim(0, P.textHeight))) |
---|
[11413] | 116 | a2Button:setText(a2) |
---|
| 117 | orxonox.GUIManager:subscribeEventHelper(a2Button, "Clicked", P.name ..".a2Button_clicked") |
---|
[11415] | 118 | P.wrapper:addChildWindow(a2Button) |
---|
[11413] | 119 | |
---|
| 120 | |
---|
[11401] | 121 | end |
---|
| 122 | |
---|
[11422] | 123 | function P.updateInventory() |
---|
| 124 | local questionn = orxonox.DialogueManager:getInstance():getquestion() |
---|
| 125 | root:setText(questionn) |
---|
| 126 | local a1n = orxonox.DialogueManager:getInstance():getanswers1() |
---|
| 127 | detailsButton:setText(a1n) |
---|
| 128 | local a2n = orxonox.DialogueManager:getInstance():getanswers2() |
---|
| 129 | a2Button:setText(a2n) |
---|
[11401] | 130 | |
---|
[11422] | 131 | end |
---|
[11401] | 132 | |
---|
[11422] | 133 | |
---|
[11401] | 134 | function P.cleanup(destroyDetails) |
---|
[11432] | 135 | |
---|
[11401] | 136 | if P.wrapper ~= nil then |
---|
| 137 | winMgr:destroyWindow(P.wrapper) |
---|
| 138 | end |
---|
| 139 | |
---|
| 140 | --Destroy details windows. |
---|
| 141 | if destroyDetails == false then |
---|
| 142 | return |
---|
| 143 | end |
---|
| 144 | for k,v in pairs(P.detailsWindows) do |
---|
| 145 | if v ~= nil then |
---|
| 146 | P.destroyDetailWindow(k) |
---|
| 147 | end |
---|
| 148 | end |
---|
[11432] | 149 | orxonox.DialogueManager:getInstance():clean() |
---|
[11401] | 150 | end |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | |
---|
[11413] | 154 | function P.a1Button_clicked(e) |
---|
[11428] | 155 | local ending = orxonox.DialogueManager:getInstance():theEnd() |
---|
| 156 | |
---|
| 157 | if ending then |
---|
| 158 | orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue") |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | else |
---|
| 162 | orxonox.DialogueManager:getInstance():a1clicked() |
---|
| 163 | P.update() |
---|
| 164 | end |
---|
[11401] | 165 | end |
---|
| 166 | |
---|
[11413] | 167 | function P.a2Button_clicked(e) |
---|
[11428] | 168 | local ending = orxonox.DialogueManager:getInstance():theEnd() |
---|
| 169 | |
---|
| 170 | if ending then |
---|
| 171 | orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue") |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | else |
---|
| 175 | orxonox.DialogueManager:getInstance():a2clicked() |
---|
| 176 | P.update() |
---|
| 177 | end |
---|
| 178 | |
---|
[11413] | 179 | end |
---|
| 180 | |
---|
[11401] | 181 | return P |
---|