Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua @ 11433

Last change on this file since 11433 was 11433, checked in by rrogge, 7 years ago

Everything works

File size: 4.4 KB
Line 
1--[[local P = createMenuSheet("Dialogue Window")
2
3function P.onLoad()
4        P.createWindow()
5        P.showing = true   
6end
7 function function_name( ... )
8        -- body
9 end
10
11
12
13
14function 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   
26end
27local 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
37local P = createMenuSheet("Dialogue")
38
39P.wrapper = nil
40P.detailsWindows = {}
41P.detailPickups = {}
42P.pickupsList = {}
43
44P.showing = false
45
46-- Design parameters
47P.imageHeight = 50
48P.detailImageSize = 100
49P.textHeight = 30
50P.buttonWidth = 85
51
52function P.onLoad()
53
54        orxout("loading")
55    P.wrapper = nil
56    P.detailsWindows = {}
57    P.detailPickups = {}
58    P.pickupsList = {}
59end
60
61function P.onShow()
62        orxout("showing")
63    orxonox.CommandExecutor:execute("setTimeFactor 0")
64    P.createInventory()
65    P.showing = true
66
67end
68
69function P.onHide()
70    orxonox.CommandExecutor:execute("setTimeFactor 1")
71    P.showing = false
72    P.cleanup(true)
73end
74
75function 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   
90end
91
92function 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
121end
122
123function 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
131end
132
133
134function 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()
150end
151
152
153
154function 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
165end
166
167function 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   
179end
180
181return P
Note: See TracBrowser for help on using the repository browser.