1 | |
---|
2 | -- Dialog.lua |
---|
3 | |
---|
4 | local P = createMenuSheet("Dialog") |
---|
5 | |
---|
6 | P.wrapper = nil |
---|
7 | P.answerList = {} |
---|
8 | P.scrollbarWidht = 13 |
---|
9 | P.selectedAnswer = {} |
---|
10 | |
---|
11 | P.showing = false |
---|
12 | |
---|
13 | -- Design parameters |
---|
14 | P.imageHeight = 50 |
---|
15 | P.detailImageSize = 100 |
---|
16 | P.textHeight = 30 |
---|
17 | P.buttonWidth = 85 |
---|
18 | |
---|
19 | function P.onLoad() |
---|
20 | P.wrapper = nil |
---|
21 | |
---|
22 | end |
---|
23 | |
---|
24 | function P.onShow() |
---|
25 | orxonox.CommandExecutor:execute("setTimeFactor 0") |
---|
26 | P.createDialog() |
---|
27 | P.showing = true |
---|
28 | |
---|
29 | end |
---|
30 | |
---|
31 | function P.onHide() |
---|
32 | orxonox.CommandExecutor:execute("setTimeFactor 1") |
---|
33 | P.showing = false |
---|
34 | P.cleanup(true) |
---|
35 | end |
---|
36 | |
---|
37 | function P.update() |
---|
38 | P.updateDialog() |
---|
39 | if P.showing == false then |
---|
40 | return |
---|
41 | end |
---|
42 | |
---|
43 | P.cleanup(false) |
---|
44 | end |
---|
45 | |
---|
46 | function P.createDialog() |
---|
47 | |
---|
48 | local dialogManager = orxonox.DialogManager:getInstance() |
---|
49 | |
---|
50 | root = winMgr:getWindow("orxonox/Dialogue/Inventory") |
---|
51 | local dialog = dialogManager:getCurrentDialog() |
---|
52 | root:setText(dialog:getQuestion) |
---|
53 | P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper") |
---|
54 | P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0))) |
---|
55 | root:addChildWindow(P.wrapper) |
---|
56 | |
---|
57 | acceptButton = winMgr:createWindow("MenuWidgets/Button", "/a2Button") --a2 da graphik aus version mit 2 knoepfen uebernommen |
---|
58 | acceptButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.4, (P.imageHeight-P.textHeight)/2))) |
---|
59 | acceptButton:setSize(CEGUI.UVector2(CEGUI.UDim(0.8, 0), CEGUI.UDim(0, P.textHeight))) |
---|
60 | acceptButton:setText("accept") |
---|
61 | orxonox.GUIManager:subscribeEventHelper(acceptButton, "Clicked", P.name ..".acceptButton_clicked") |
---|
62 | P.wrapper:addChildWindow(acceptButton) |
---|
63 | |
---|
64 | P.answerList = {} -- erstellen der tabelle aus AntwortIds und Antworten im Lua |
---|
65 | local answers = dialog:getAnswers() |
---|
66 | for ans in answers do |
---|
67 | P.answerList[ans] = dialog:getAnswer(ans) |
---|
68 | end |
---|
69 | --todo herausfinden wie antworten in tabelle enzeigen |
---|
70 | end |
---|
71 | |
---|
72 | |
---|
73 | function P.updateDialog() |
---|
74 | local dialog = orxonox.DialogManager:getInstance():getDialog() |
---|
75 | root:setText(dialog:getQuestion) |
---|
76 | --todo: tabellen updaten |
---|
77 | end |
---|
78 | |
---|
79 | |
---|
80 | function P.cleanup(destroyDetails) |
---|
81 | |
---|
82 | if P.wrapper ~= nil then |
---|
83 | winMgr:destroyWindow(P.wrapper) |
---|
84 | end |
---|
85 | |
---|
86 | --Destroy details windows. |
---|
87 | if destroyDetails == false then |
---|
88 | return |
---|
89 | end |
---|
90 | for k,v in pairs(P.detailsWindows) do |
---|
91 | if v ~= nil then |
---|
92 | P.destroyDetailWindow(k) |
---|
93 | end |
---|
94 | end |
---|
95 | |
---|
96 | end |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | function P.acceptButton_clicked(e) |
---|
101 | local ending = orxonox.DialogManager:getInstance():getDialog:ending() |
---|
102 | |
---|
103 | if ending then |
---|
104 | orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog") |
---|
105 | |
---|
106 | --herausfindne wie tabelleneintrag uebergeben wird |
---|
107 | else |
---|
108 | P.update() |
---|
109 | end |
---|
110 | end |
---|
111 | |
---|
112 | return P |
---|