Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/Dialogue.lua @ 11781

Last change on this file since 11781 was 11451, checked in by patricwi, 7 years ago

Dialogue merged without core modifications

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