Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/HUD_HS16/data/gui/scripts/Dialogue.lua @ 12073

Last change on this file since 12073 was 11502, checked in by patricwi, 7 years ago

updated HUD by merging trunk into it

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