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