Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11642 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
RevLine 
[11401]1
2-- Dialogue.lua
3
[11406]4local P = createMenuSheet("Dialogue")
[11401]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 = {}
[11612]24   
[11401]25end
26
27function P.onShow()
[11433]28    orxonox.CommandExecutor:execute("setTimeFactor 0")
[11401]29    P.createInventory()
30    P.showing = true
31end
32
[11612]33
[11401]34function P.onHide()
[11433]35    orxonox.CommandExecutor:execute("setTimeFactor 1")
[11401]36    P.showing = false
37    P.cleanup(true)
38end
39
40function P.update()
[11422]41    P.updateInventory()
[11401]42    if P.showing == false then
43        return
44    end
45
46    -- Update opened detail windows.
[11406]47   
[11401]48
49    -- Update main inventory.
50    P.cleanup(false)
51    P.createInventory()
52    -- TODO: Recover scrolling position
53   
54end
55
56function P.createInventory()
[11433]57
[11406]58    local pickupManager = orxonox.DialogueManager:getInstance()
[11401]59   
[11422]60    root = winMgr:getWindow("orxonox/Dialogue/Inventory")
[11406]61    local question = orxonox.DialogueManager:getInstance():getquestion()
62    root:setText(question)
63    P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper")
[11401]64    P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
65    root:addChildWindow(P.wrapper)
66   
[11413]67   
[11422]68    detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton")
[11413]69    local a1 = orxonox.DialogueManager:getInstance():getanswers1()
[11435]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)))
[11413]72    detailsButton:setText(a1)
73    orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".a1Button_clicked")
[11415]74    P.wrapper:addChildWindow(detailsButton)
[11401]75
[11422]76    a2Button = winMgr:createWindow("MenuWidgets/Button", "/a2Button")
[11413]77    local a2 = orxonox.DialogueManager:getInstance():getanswers2()
[11435]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)))
[11413]80    a2Button:setText(a2)
81    orxonox.GUIManager:subscribeEventHelper(a2Button, "Clicked", P.name ..".a2Button_clicked")
[11415]82    P.wrapper:addChildWindow(a2Button)
[11413]83
84
[11401]85end
86
[11422]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)
[11401]94
[11422]95end
[11401]96
[11422]97
[11401]98function P.cleanup(destroyDetails)
[11432]99   
[11401]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
[11435]113   
[11401]114end
115
116
117
[11413]118function P.a1Button_clicked(e)
[11428]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
[11401]129end
130
[11413]131function P.a2Button_clicked(e)
[11428]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   
[11413]143end
144
[11401]145return P
Note: See TracBrowser for help on using the repository browser.