Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/Dialog.lua @ 12412

Last change on this file since 12412 was 11806, checked in by landauf, 7 years ago

migrated all ingame menus to cegui 0.8

  • Property svn:eol-style set to native
File size: 3.6 KB
RevLine 
[11652]1-- Dialog.lua
[11579]2
3local P = createMenuSheet("Dialog")
4
5P.wrapper = nil
[11612]6P.detailsWindows = {}
[11579]7P.showing = false
[11644]8P.choice = 0
[11652]9P.scrollbarWidth = 12
[11579]10
[11644]11function P.onLoad() --wird ausgefuert wenn Fenster geladen
[11579]12    P.wrapper = nil
13end
14
[11644]15function P.onShow() --wird ausgefuert wenn Dialogfenster gezeigt
[11612]16
[11579]17    orxonox.CommandExecutor:execute("setTimeFactor 0")
18    P.createDialog()
19    P.showing = true
20
21end
22
[11644]23function P.onHide() --aufgefuert wenn Fenster geschlossen wird
[11579]24    orxonox.CommandExecutor:execute("setTimeFactor 1")
25    P.showing = false
26    P.cleanup(true)
27end
28
[11644]29function P.createDialog() -- initiallisiert das Dialog Fenster, setzt Namen sowie die erste Frage mit enstprechenden Antworten
[11579]30
[11612]31    local manager = orxonox.DialogManager:getInstance()
[11579]32   
33   
[11806]34    local personfield = P.window:getChild("Options/Person")
[11642]35    local person = manager:getPerson()
36    personfield:setText(person)
37
[11806]38    local questionfield = P.window:getChild("Options/QuestionWrapper/QuestionPane/Question")
[11642]39    local question = manager:getQuestion()
[11652]40    questionfield:setText(question)
[11642]41
[11806]42    local listboxwindow = P.window:getChild("Options/AnsListbox")
[11644]43    CEGUI.toListbox(listboxwindow):resetList()
[11642]44
[11644]45    local ansList = {}
[11642]46    local anssize = manager:getSize()
[11612]47
[11642]48    for index = 0, anssize -1, 1 do
[11644]49        table.insert(ansList, manager:getAnswer(index))
[11642]50    end 
51
[11644]52    for k,v in pairs(ansList) do
[11642]53        item = CEGUI.createListboxTextItem(v)
[11806]54        item:setSelectionBrushImage(menuImageSet .. "/MultiListSelectionBrush")
[11642]55        CEGUI.toListbox(listboxwindow):addItem(item)
56    end
[11579]57end
58
[11644]59function P.updateDialog()   --updated den Dialog entsprechend der Ausgeaehlten option der letzten Frage, setzt Frage und Antwortmoeglichkeiten neu
[11642]60    local manager = orxonox.DialogManager:getInstance()
[11644]61    manager:update(P.choice)
[11642]62
[11806]63    local questionfield = P.window:getChild("Options/QuestionWrapper/QuestionPane/Question")
[11642]64    local question = manager:getQuestion()
[11652]65    questionfield:setText(question)
[11644]66
[11806]67    local listboxwindow = P.window:getChild("Options/AnsListbox")
[11644]68    listboxwindow:resetList()
69
70    local ansList = {}
71    local anssize = manager:getSize()
72
73    for index = 0, anssize -1, 1 do
74        table.insert(ansList, manager:getAnswer(index))
75    end 
76
77    for k,v in pairs(ansList) do
78        item = CEGUI.createListboxTextItem(v)
[11806]79        item:setSelectionBrushImage(menuImageSet .. "/MultiListSelectionBrush")
[11644]80        CEGUI.toListbox(listboxwindow):addItem(item)
81    end
82
83    P.choice = 0
[11579]84end
85
[11644]86function P.answer_changed(e)    --wird aufgerufen falls Auswahl geaendert wird und setzt enstprechenden Indexparameter 
[11806]87    listboxwindow = P.window:getChild("Options/AnsListbox")
[11644]88    selection = listboxwindow:getFirstSelectedItem()
89    if selection ~= nil then
90    P.choice = listboxwindow:getItemIndex(selection)
91    else 
92        P.choice = 0
93    end
[11642]94end
[11579]95
[11642]96
[11644]97function P.cleanup(destroyDetails)  --loest Fenster wieder auf (!nicht selbst geschrieben, nur uebernommen, eventuell nicht noetiger code)
98
[11579]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
[11644]117function P.Button_clicked(e)    --wird bei click auf say knopf ausgeloest, entscheidet ob Dialog schliesst oder updated und fuert entsprechen aus
118    local ending = orxonox.DialogManager:getInstance():endtest(P.choice)
[11579]119   
[11642]120    if ending then
[11579]121        orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog")
[11642]122    else 
123        P.updateDialog(index)
124    end
[11579]125end
126
127return P
Note: See TracBrowser for help on using the repository browser.