Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Dialog_HS17/data/gui/scripts/Dialogue.lua @ 11646

Last change on this file since 11646 was 11612, checked in by kuchlert, 7 years ago

funktioniert bis dialogmanager getInstance, angefangen und noch zu tun: luafunktionen von dialogmanager, lua und layout

File size: 3.6 KB
Line 
1
2-- Dialogue.lua
3
4local P = createMenuSheet("Dialogue")
5
6P.wrapper = nil
7P.detailsWindows = {}
8P.detailPickups = {}
9P.pickupsList = {}
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    P.detailsWindows = {}
22    P.detailPickups = {}
23    P.pickupsList = {}
24   
25end
26
27function P.onShow()
28    orxonox.CommandExecutor:execute("setTimeFactor 0")
29    P.createInventory()
30    P.showing = true
31end
32
33
34function P.onHide()
35    orxonox.CommandExecutor:execute("setTimeFactor 1")
36    P.showing = false
37    P.cleanup(true)
38end
39
40function P.update()
41    P.updateInventory()
42    if P.showing == false then
43        return
44    end
45
46    -- Update opened detail windows.
47   
48
49    -- Update main inventory.
50    P.cleanup(false)
51    P.createInventory()
52    -- TODO: Recover scrolling position
53   
54end
55
56function P.createInventory()
57
58    local pickupManager = orxonox.DialogueManager:getInstance()
59   
60    root = winMgr:getWindow("orxonox/Dialogue/Inventory")
61    local question = orxonox.DialogueManager:getInstance():getquestion()
62    root:setText(question)
63    P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper")
64    P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
65    root:addChildWindow(P.wrapper)
66   
67   
68    detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton")
69    local a1 = orxonox.DialogueManager:getInstance():getanswers1()
70    detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.25, (P.imageHeight-P.textHeight)/2)))
71    detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0.8, 0), CEGUI.UDim(0, P.textHeight)))
72    detailsButton:setText(a1)
73    orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".a1Button_clicked")
74    P.wrapper:addChildWindow(detailsButton)
75
76    a2Button = winMgr:createWindow("MenuWidgets/Button", "/a2Button")
77    local a2 = orxonox.DialogueManager:getInstance():getanswers2()
78    a2Button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.4, (P.imageHeight-P.textHeight)/2)))
79    a2Button:setSize(CEGUI.UVector2(CEGUI.UDim(0.8, 0), CEGUI.UDim(0, P.textHeight)))
80    a2Button:setText(a2)
81    orxonox.GUIManager:subscribeEventHelper(a2Button, "Clicked", P.name ..".a2Button_clicked")
82    P.wrapper:addChildWindow(a2Button)
83
84
85end
86
87function P.updateInventory()
88    local questionn = orxonox.DialogueManager:getInstance():getquestion()
89    root:setText(questionn)
90    local a1n = orxonox.DialogueManager:getInstance():getanswers1()
91    detailsButton:setText(a1n)
92    local a2n = orxonox.DialogueManager:getInstance():getanswers2()
93    a2Button:setText(a2n)
94
95end
96
97
98function P.cleanup(destroyDetails)
99   
100    if P.wrapper ~= nil then
101        winMgr:destroyWindow(P.wrapper)
102    end
103   
104    --Destroy details windows.
105    if destroyDetails == false then
106        return
107    end
108    for k,v in pairs(P.detailsWindows) do
109        if v ~= nil then
110            P.destroyDetailWindow(k)
111        end
112    end
113   
114end
115
116
117
118function P.a1Button_clicked(e)
119    local ending = orxonox.DialogueManager:getInstance():theEnd()
120   
121    if ending then
122        orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue")
123   
124   
125    else 
126        orxonox.DialogueManager:getInstance():a1clicked()
127        P.update()
128    end
129end
130
131function P.a2Button_clicked(e)
132    local ending = orxonox.DialogueManager:getInstance():theEnd()
133   
134    if ending then
135        orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue")
136   
137   
138    else 
139        orxonox.DialogueManager:getInstance():a2clicked()
140        P.update()
141    end
142   
143end
144
145return P
Note: See TracBrowser for help on using the repository browser.