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 | |
---|
37 | local P = createMenuSheet("Dialogue") |
---|
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 | |
---|
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") |
---|
63 | orxonox.CommandExecutor:execute("setTimeFactor 0") |
---|
64 | P.createInventory() |
---|
65 | P.showing = true |
---|
66 | |
---|
67 | end |
---|
68 | |
---|
69 | function P.onHide() |
---|
70 | orxonox.CommandExecutor:execute("setTimeFactor 1") |
---|
71 | P.showing = false |
---|
72 | P.cleanup(true) |
---|
73 | end |
---|
74 | |
---|
75 | function P.update() |
---|
76 | orxout("UPDATING") |
---|
77 | P.updateInventory() |
---|
78 | if P.showing == false then |
---|
79 | return |
---|
80 | end |
---|
81 | |
---|
82 | -- Update opened detail windows. |
---|
83 | |
---|
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() |
---|
93 | |
---|
94 | local pickupManager = orxonox.DialogueManager:getInstance() |
---|
95 | |
---|
96 | root = winMgr:getWindow("orxonox/Dialogue/Inventory") |
---|
97 | local question = orxonox.DialogueManager:getInstance():getquestion() |
---|
98 | root:setText(question) |
---|
99 | P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper") |
---|
100 | P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0))) |
---|
101 | root:addChildWindow(P.wrapper) |
---|
102 | |
---|
103 | |
---|
104 | detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton") |
---|
105 | local a1 = orxonox.DialogueManager:getInstance():getanswers1() |
---|
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))) |
---|
108 | detailsButton:setText(a1) |
---|
109 | orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".a1Button_clicked") |
---|
110 | P.wrapper:addChildWindow(detailsButton) |
---|
111 | |
---|
112 | a2Button = winMgr:createWindow("MenuWidgets/Button", "/a2Button") |
---|
113 | local a2 = orxonox.DialogueManager:getInstance():getanswers2() |
---|
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))) |
---|
116 | a2Button:setText(a2) |
---|
117 | orxonox.GUIManager:subscribeEventHelper(a2Button, "Clicked", P.name ..".a2Button_clicked") |
---|
118 | P.wrapper:addChildWindow(a2Button) |
---|
119 | |
---|
120 | |
---|
121 | end |
---|
122 | |
---|
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) |
---|
130 | |
---|
131 | end |
---|
132 | |
---|
133 | |
---|
134 | function P.cleanup(destroyDetails) |
---|
135 | |
---|
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 |
---|
149 | orxonox.DialogueManager:getInstance():clean() |
---|
150 | end |
---|
151 | |
---|
152 | |
---|
153 | |
---|
154 | function P.a1Button_clicked(e) |
---|
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 |
---|
165 | end |
---|
166 | |
---|
167 | function P.a2Button_clicked(e) |
---|
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 | |
---|
179 | end |
---|
180 | |
---|
181 | return P |
---|