Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Alles funktionioniert so weit, bloss kann man pro Spiel bloss einmal einen Dialog durchlaufen

File size: 4.2 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        orxout("loading")
54    P.wrapper = nil
55    P.detailsWindows = {}
56    P.detailPickups = {}
57    P.pickupsList = {}
58end
59
60function P.onShow()
61        orxout("showing")
62    P.createInventory()
63    P.showing = true
64end
65
66function P.onHide()
67    P.showing = false
68    P.cleanup(true)
69end
70
71function P.update()
72    orxout("UPDATING")
73    P.updateInventory()
74    if P.showing == false then
75        return
76    end
77
78    -- Update opened detail windows.
79   
80
81    -- Update main inventory.
82    P.cleanup(false)
83    P.createInventory()
84    -- TODO: Recover scrolling position
85   
86end
87
88function P.createInventory()
89    local pickupManager = orxonox.DialogueManager:getInstance()
90   
91    root = winMgr:getWindow("orxonox/Dialogue/Inventory")
92    local question = orxonox.DialogueManager:getInstance():getquestion()
93    root:setText(question)
94    P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper")
95    P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
96    root:addChildWindow(P.wrapper)
97   
98   
99    detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton")
100    local a1 = orxonox.DialogueManager:getInstance():getanswers1()
101    detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.25, 0)))
102    detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, 575), CEGUI.UDim(0, P.textHeight)))
103    detailsButton:setText(a1)
104    orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".a1Button_clicked")
105    P.wrapper:addChildWindow(detailsButton)
106
107    a2Button = winMgr:createWindow("MenuWidgets/Button", "/a2Button")
108    local a2 = orxonox.DialogueManager:getInstance():getanswers2()
109    a2Button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.4, 0)))
110    a2Button:setSize(CEGUI.UVector2(CEGUI.UDim(0, 575), CEGUI.UDim(0, P.textHeight)))
111    a2Button:setText(a2)
112    orxonox.GUIManager:subscribeEventHelper(a2Button, "Clicked", P.name ..".a2Button_clicked")
113    P.wrapper:addChildWindow(a2Button)
114
115
116end
117
118function P.updateInventory()
119    local questionn = orxonox.DialogueManager:getInstance():getquestion()
120    root:setText(questionn)
121    local a1n = orxonox.DialogueManager:getInstance():getanswers1()
122    detailsButton:setText(a1n)
123    local a2n = orxonox.DialogueManager:getInstance():getanswers2()
124    a2Button:setText(a2n)
125
126end
127
128
129function P.cleanup(destroyDetails)
130    if P.wrapper ~= nil then
131        winMgr:destroyWindow(P.wrapper)
132    end
133   
134    --Destroy details windows.
135    if destroyDetails == false then
136        return
137    end
138    for k,v in pairs(P.detailsWindows) do
139        if v ~= nil then
140            P.destroyDetailWindow(k)
141        end
142    end
143end
144
145
146
147function P.a1Button_clicked(e)
148    local ending = orxonox.DialogueManager:getInstance():theEnd()
149   
150    if ending then
151        orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue")
152   
153   
154    else 
155        orxonox.DialogueManager:getInstance():a1clicked()
156        P.update()
157    end
158end
159
160function P.a2Button_clicked(e)
161    local ending = orxonox.DialogueManager:getInstance():theEnd()
162   
163    if ending then
164        orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue")
165   
166   
167    else 
168        orxonox.DialogueManager:getInstance():a2clicked()
169        P.update()
170    end
171   
172end
173
174return P
Note: See TracBrowser for help on using the repository browser.