1 | -- Dialogue.lua |
---|
2 | |
---|
3 | local P = createMenuSheet("Dialog") |
---|
4 | |
---|
5 | P.wrapper = nil |
---|
6 | P.detailsWindows = {} |
---|
7 | P.showing = false |
---|
8 | |
---|
9 | -- Design parameters |
---|
10 | P.imageHeight = 50 |
---|
11 | P.detailImageSize = 100 |
---|
12 | P.textHeight = 50 |
---|
13 | P.buttonWidth = 50 |
---|
14 | |
---|
15 | function P.onLoad() |
---|
16 | P.wrapper = nil |
---|
17 | end |
---|
18 | |
---|
19 | function P.onShow() |
---|
20 | |
---|
21 | orxonox.CommandExecutor:execute("setTimeFactor 0") |
---|
22 | P.createDialog() |
---|
23 | P.showing = true |
---|
24 | |
---|
25 | end |
---|
26 | |
---|
27 | function P.onHide() |
---|
28 | orxonox.CommandExecutor:execute("setTimeFactor 1") |
---|
29 | P.showing = false |
---|
30 | P.cleanup(true) |
---|
31 | end |
---|
32 | |
---|
33 | function P.createDialog() |
---|
34 | |
---|
35 | local manager = orxonox.DialogManager:getInstance() |
---|
36 | |
---|
37 | |
---|
38 | local personfield = winMgr:getWindow("orxonox/Dialog/Person") |
---|
39 | local person = manager:getPerson() |
---|
40 | personfield:setText(person) |
---|
41 | |
---|
42 | local questionfiled = winMgr:getWindow("orxonox/Dialog/Question") |
---|
43 | local question = manager:getQuestion() |
---|
44 | questionfiled:setText(question) |
---|
45 | |
---|
46 | listboxwindow = winMgr:getWindow("orxonox/AnsListbox") |
---|
47 | |
---|
48 | local themeList = {} |
---|
49 | --[[ |
---|
50 | table.insert(themeList, "Default") |
---|
51 | table.insert(themeList, "Drum n' Bass") |
---|
52 | table.insert(themeList, "8-Bit Style") |
---|
53 | table.insert(themeList, "Corny Jazz") |
---|
54 | table.insert(themeList, "Metal") |
---|
55 | --]] |
---|
56 | local anssize = manager:getSize() |
---|
57 | |
---|
58 | for index = 0, anssize -1, 1 do |
---|
59 | table.insert(themeList, manager:getAnswer(index)) |
---|
60 | end |
---|
61 | |
---|
62 | for k,v in pairs(themeList) do |
---|
63 | item = CEGUI.createListboxTextItem(v) |
---|
64 | item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") |
---|
65 | CEGUI.toListbox(listboxwindow):addItem(item) |
---|
66 | end |
---|
67 | end |
---|
68 | |
---|
69 | function P.updateDialog() |
---|
70 | local manager = orxonox.DialogManager:getInstance() |
---|
71 | --manager:update() |
---|
72 | |
---|
73 | local questionfiled = winMgr:getWindow("orxonox/Dialog/Question") |
---|
74 | local question = manager:getQuestion() |
---|
75 | questionfiled:setText(question) |
---|
76 | end |
---|
77 | |
---|
78 | function P.answer_changed(e) |
---|
79 | -- body |
---|
80 | end |
---|
81 | |
---|
82 | |
---|
83 | function P.cleanup(destroyDetails) |
---|
84 | |
---|
85 | if P.wrapper ~= nil then |
---|
86 | winMgr:destroyWindow(P.wrapper) |
---|
87 | end |
---|
88 | |
---|
89 | --Destroy details windows. |
---|
90 | if destroyDetails == false then |
---|
91 | return |
---|
92 | end |
---|
93 | for k,v in pairs(P.detailsWindows) do |
---|
94 | if v ~= nil then |
---|
95 | P.destroyDetailWindow(k) |
---|
96 | end |
---|
97 | end |
---|
98 | |
---|
99 | end |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | function P.Button_clicked(e) |
---|
104 | local ending = orxonox.DialogManager:getInstance():endtest() |
---|
105 | orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog") |
---|
106 | |
---|
107 | if ending then |
---|
108 | orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog") |
---|
109 | |
---|
110 | |
---|
111 | else |
---|
112 | P.updateDialog(index) |
---|
113 | end |
---|
114 | end |
---|
115 | |
---|
116 | return P |
---|