Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua @ 11590

Last change on this file since 11590 was 11579, checked in by kuchlert, 7 years ago

some bug fixed most not

File size: 2.7 KB
Line 
1
2-- Dialog.lua
3
4local P = createMenuSheet("Dialog")
5
6P.wrapper = nil
7P.answerList = {}
8P.scrollbarWidht = 13
9P.selectedAnswer = {}
10
11P.showing = false
12
13-- Design parameters
14P.imageHeight = 50
15P.detailImageSize = 100
16P.textHeight = 30
17P.buttonWidth = 85
18
19function P.onLoad()
20    P.wrapper = nil
21
22end
23
24function P.onShow()
25    orxonox.CommandExecutor:execute("setTimeFactor 0")
26    P.createDialog()
27    P.showing = true
28
29end
30
31function P.onHide()
32    orxonox.CommandExecutor:execute("setTimeFactor 1")
33    P.showing = false
34    P.cleanup(true)
35end
36
37function P.update()
38    P.updateDialog()
39    if P.showing == false then
40        return
41    end
42
43    P.cleanup(false)
44end
45
46function 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
70end
71
72
73function P.updateDialog()
74    local dialog = orxonox.DialogManager:getInstance():getDialog()
75    root:setText(dialog:getQuestion)
76    --todo: tabellen updaten
77end
78
79
80function 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   
96end
97
98
99
100function 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
110end
111
112return P
Note: See TracBrowser for help on using the repository browser.