Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/QuestGUI.lua @ 10385

Last change on this file since 10385 was 8891, checked in by jo, 13 years ago

Ai and tutorial improvements merged back to the trunk. AI features: all weapons are used, the ai-firestrength is configurable, bots are able to collect pickups . I've set the tutorial level as default level.

  • Property svn:eol-style set to native
File size: 23.4 KB
RevLine 
[6746]1-- QuestGUI.lua
[5746]2
[6746]3local P = createMenuSheet("QuestGUI")
[5746]4
[8706]5P.questManager = nil -- The QuestManager.
6P.showActive = true -- Whether the active or finished quest list is displayed.
7P.player = nil -- The player the quests are displayed for.
[7163]8P.quests = {}
[8706]9P.subquests = {}
[5746]10
[7163]11-- design parameters
12P.scrollbarWidth = 13
[8706]13P.frameHeigth = 18
14P.borderSize = 5
[7163]15P.titleHeight = 26
[6417]16
[8706]17--TODO:
18-- Highlight whether we are currently looking at active or finished quests
19-- Distinguish completed from failed quests
[7163]20
[8706]21function P.onLoad()
22    P.questManager = orxonox.QuestManager:getInstance() -- Store the pointer to the QuestManager as an internal variable to allow for faster access,
23end
[5746]24
[8706]25function P.onShow()
26    -- Get the player.
[7163]27    P.player = orxonox.GUIManager:getInstance():getPlayer(P.name)
[5746]28
[8706]29    -- Load the list of quests to be displayed.
[8891]30    P.loadQuestsList()
31    -- Pause the game - possible conflict for multiplayer quests
32    orxonox.execute("setPause 1")
[7163]33end
[5746]34
[8891]35function P.onQuit()
36    orxonox.execute("setPause 0")
37end
38
[8706]39-- Loads the list of quests, depending on P.showActive, either the active (P.showActive == true) or the finished, i.e. inactive quests are loaded.
40-- selectQuest is a pointer to a quest that should be selected, if it is nil the first quest is selected.
41function P.loadQuestsList(selectQuest)
42    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList"))
43    P.clearQuestList()
44
45    local selectQuestId = nil
46    if selectQuest ~= nil then
47        selectQuestId = P.questManager:getId(selectQuest)
48    end
49
50    -- Iterate through all root-quests.
51    local numRootQuests = P.questManager:getNumRootQuests(P.player)
52    if numRootQuests > 0 then
53        local i = 0
54        while i <= numRootQuests-1 do
55            local quest = P.questManager:getRootQuest(P.player, i)
56            -- Insert the current quest into the list.
57            local item = P.insertQuest(list, quest)
58            -- If the quest was inserted in the list and is has the same id as the selectQuest (thus it is the same quest) it is selected.
59            if selectQuestId ~= nil and item ~= nil and selectQuestId == P.questManager:getId(quest) then
60                list:setItemSelectState(item, true)
61            end
62            -- Insert all subquests of this rootquest.
63            P.insertSubQuests(list, quest, selectQuestId)
64            i = i+1
65        end
66        -- If there were quests added to the list but there was no selectQuest specified (i.e. selectQuest was nil), the first item is selected.
67        if list:getItemCount() > 0 then
68            if selectQuestId == nil then
69                list:setItemSelectState(list:getListboxItemFromIndex(0), true)  -- Select first quest.
70            end
71        -- If there werent any quests added the standard "no quests" message is loaded.
72        else
73            P.loadQuest()
74        end
75    end
[5746]76end
77
[8706]78-- Helper function, recursively inserts all the (active or inactive, depending on P.showActive) subquests of the input quest.
79-- list is the list into which the subquests should be insterted.
80-- quest is the quest, whose subquests should be inserted.
81-- selectQuestId is the id of the quest that should be selected.
82function P.insertSubQuests(list, quest, selectQuestId)
83    -- Iterate through all sub-quests.
84    local numQuests = P.questManager:getNumSubQuests(quest, P.player)
85    if numQuests > 0 then
86        local i = 0
87        while i <= numQuests-1 do
88            local subquest = P.questManager:getSubQuest(quest, P.player, i)
89            -- Insert the current quest into the list.
90            local item = P.insertQuest(list, subquest)
91            -- If the quest was inserted in the list and is has the same id as the selectQuest (thus it is the same quest) it is selected.
92            if selectQuestId ~= nil and item ~= nil and selectQuestId == P.questManager:getId(subquest) then
93                list:setItemSelectState(item, true)
94            end
95            i = i+1
96        end
97    end
98end
99
100-- Helper function, inserts a quest into the list (depending whether active or inactive quests are being shown). Returns nil if the quest was not inserted.
101-- list is the list into which the quets should be inserted.
102-- quest is the quest to be inserted.
103function P.insertQuest(list, quest)
104    if P.showActive == quest:isActive(P.player) then
105        local item = CEGUI.createListboxTextItem(P.questManager:getDescription(quest):getTitle())
106        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
107        list:addItem(item)
108        table.insert(P.quests, quest)
109        return item
110    end
111    return nil
112end
113
114-- Loads the input quest.
115-- quest the quest to be loaded.
116function P.loadQuest(quest)
117
118    P.clearQuest() -- Clear the old quest.
119    if quest == nil then -- If quets is nil there is nothing to display.
120        return
121    else
122        local offset = 0
123
124        -- Load title and description
125        local description = P.questManager:getDescription(quest)
126        local titleWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Title")
127        titleWindow:setText(description:getTitle())
128        local descriptionWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Description")
129        descriptionWindow:setText(description:getDescription())
130        descriptionWindow:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize), CEGUI.UDim(1, 0)))
131        descriptionWindow:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, P.borderSize)))
132        local height = getStaticTextWindowHeight(descriptionWindow)
133        descriptionWindow:setHeight(CEGUI.UDim(0, height))
134        offset = offset + height
135
136        -- Load subquests
137        local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/Quest/SubquestsList"))
138        local numQuests = P.questManager:getNumSubQuests(quest, P.player)
139        local i = 0
140        while i <= numQuests-1 do
141            local quest = P.questManager:getSubQuest(quest, P.player, i)
142            local item = CEGUI.createListboxTextItem(P.questManager:getDescription(quest):getTitle())
143            item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
144            list:addItem(item)
145            table.insert(P.subquests, quest)
146            i = i+1
147        end
148        height = list:getTotalItemsHeight()
149        if height > 0 then
150            height = height+P.frameHeigth
151        end
152        list:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize), CEGUI.UDim(0, height)))
153        list:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, offset)))
154        offset = offset + height + P.borderSize
155
156        -- Load hints
157        local hintsWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Hints")
158        hintsWindow:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, offset)))
159        hintsWindow:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize), CEGUI.UDim(0, 0)))
160        height = P.titleHeight
161        local numHints = P.questManager:getNumHints(quest, P.player)
162        local i = 0
163        while i <= numHints-1 do
164            local hint = P.questManager:getHints(quest, P.player, i)
165            height = height + P.insertHint(hintsWindow, hint, i, height)
166            i = i+1
167        end
168        if numHints == 0 then
169            height = 0
170        end
171        hintsWindow:setHeight(CEGUI.UDim(0, height))
172        offset = offset + height
173
174        -- Set the size of the wrapper
175        local window = winMgr:getWindow("orxonox/QuestGUI/Quest/Wrapper")
176        window:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize-P.scrollbarWidth), CEGUI.UDim(0,offset+P.borderSize)))
177    end
178end
179
180-- Clear the currently displayed quest.
181function P.clearQuest()
182    -- clear title
183    local titleWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Title")
184    titleWindow:setText("no Quests")
185
186    -- clear description
187    local descriptionWindow = winMgr:getWindow("orxonox/QuestGUI/Quest/Description")
188    descriptionWindow:setText("There is currently no quest that can be displayed.")
189
190    -- clear list fo subquests
191    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/Quest/SubquestsList"))
192    list:resetList()
193    list:setHeight(CEGUI.UDim(0, 0))
194    P.subquests = {}
195
196    -- clear hints
197    local hints = winMgr:getWindow("orxonox/QuestGUI/Quest/Hints")
198    local numChildren = hints:getChildCount()-2 -- TODO: HACK
199    local i = 0
200    while i < numChildren do
201        local hint = hints:getChild("orxonox/QuestGUI/Quest/Hints/" .. i)
202        if hint ~= nil then
203            hints:removeChildWindow(hint)
204            winMgr:destroyWindow(hint)
205        end
206        i = i+1
207    end
208    hints:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth-P.borderSize), CEGUI.UDim(0, 0)))
209end
210
211-- Clear the quests list
212function P.clearQuestList()
213    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList"))
214    list:resetList()
215    P.quests = {}
216end
217
218-- Select an input quest in the input list.
219-- list is the list in which the input quest is to be selected.
220-- quest is the quest to be selected.
221function P.selectQuest(list, quest)
222    if quest == nil then -- If the input quest is nil, there is nothing to be selected, an error is output and the first quest is selected instead.
[8858]223        orxout(orxonox.level.internal_error, "Error in QuestGUI: selectQuest(), input quest is nil. Selecting first.")
[8706]224        list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first
225        return
226    end
227
228    local questId = P.questManager:getId(quest)
229    local found = false
230    local index = 0
231    -- Iterate over all quests currently in the list.
232    for k,v in pairs(P.quests) do
233        -- If the id's are the same we have found the quest.
234        if P.questManager:getId(v) == questId then
235            found = true
236            index = k-1
237        end
238    end
239
240    if found then -- If the quest was found it is selected.
241        list:setItemSelectState(list:getListboxItemFromIndex(index), true)
242    else -- If the quest isn't found an error is output and the first quest is selected instead.
[8858]243        orxout(orxonox.level.internal_error, "Error in QuestGUI: selectQuest(), input quest is not in list. Selecting first.")
[8706]244        list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first
245    end
246end
247
248-- Helper function, insert the input hint into the input hintsWindow. Returns the height of the newly inserted hint.
249-- hintsWindow is the window in which the hint is to be inserted.
250-- hint is the hint to be inserted.
251-- index is the index of the hint.
252-- offset is the current offset in the hintsWindow.
253function P.insertHint(hintsWindow, hint, index, offset)
254    -- Create the window for the hint.
255    local window = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/QuestGUI/Quest/Hints/" .. index)
256    window:setProperty("HorzFormatting", "WordWrapLeftAligned")
257    window:setProperty("VertFormatting", "TopAligned")
258    window:setProperty("FrameEnabled", "false")
259    window:setID(index)
260    hintsWindow:addChildWindow(window)
261    local description = P.questManager:getDescription(hint)
262    window:setText(description:getDescription())
263    window:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.borderSize), CEGUI.UDim(1, 0)))
264    local height = getStaticTextWindowHeight(window)
265    window:setHeight(CEGUI.UDim(0, height))
266    window:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderSize), CEGUI.UDim(0, offset)))
267    return height
268end
269
270-- Show the currently active quests in the quests list.
271function P.showActiveQuestsButton_clicked(e)
272    if P.showActive == false then
273        P.showActive = true
274        P.loadQuestsList()
275    end
276end
277
278-- Show the finished (i.e. inactive) quests in the quests list.
279function P.showFinishedQuestsButton_clicked(e)
280    if P.showActive == true then
281        P.showActive = false
282        P.loadQuestsList()
283    end
284end
285
286-- Change to a new quest.
287function P.changeQuest_clicked(e)
288    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList"))
289    local choice = list:getFirstSelectedItem()
290    if choice ~= nil then
291        local index = list:getItemIndex(choice)
292        local quest = P.quests[index+1]
293        if quest ~= nil then
294            P.loadQuest(quest)
295        end
296    end
297end
298
299-- Change to a new subquest.
300function P.changeToSubquest_clicked(e)
301    local list = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/Quest/SubquestsList"))
302    local questsList = CEGUI.toListbox(winMgr:getWindow("orxonox/QuestGUI/QuestsList"))
303    local choice = list:getFirstSelectedItem()
304    if choice ~= nil then
305        local index = list:getItemIndex(choice)
306        local quest = P.subquests[index+1]
307        if quest ~= nil then
308            -- If the P.showActive must be changed to display the quest the quests list also has to be regenerated.
309            if quest:isActive(P.player) == P.showActive then
310                P.selectQuest(questsList, quest)
311            else
312                P.showActive = quest:isActive(P.player)
313                P.loadQuestsList(quest)
314            end
315        else
[8858]316            orxout(orxonox.level.internal_error, "Error in QuestGUI: changeToSubquest(), quest was nil. Ignoring...")
[8706]317        end
318    end
319end
320
321-- old:
322--[[
[7163]323function P.createQuestGUI()
324    local questManager = orxonox.QuestManager:getInstance()
325
326    local depth = 0
327    local index = 0
328
329    local questWindow = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/QuestGUI/Quests")
330    questWindow:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0),CEGUI.UDim(1, 0)))
331
[7456]332    -- Iterate through all root-quests.
333    local numRootQuests = orxonox.QuestManager:getInstance():getNumRootQuests(P.player)
[7163]334    local i = 0
[7456]335    while i <= numRootQuests-1 do
336        local quest = orxonox.QuestManager:getInstance():getRootQuest(P.player, i)
[7163]337        index = P.createQuestNodes(questWindow, quest, depth, index)
338        i = i+1
339    end
340
341    return questWindow
342end
343
344function P.createQuestNodes(root, parent, depth, index)
345    local number = table.getn(P.quests)+1
346    local name = "orxonox/QuestGUI/Quests/" .. number
347    local node = winMgr:createWindow("MenuWidgets/TabButton", name)
348    node:setText(orxonox.QuestManager:getInstance():getDescription(parent):getTitle())
349    node:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.indentWidth*depth), CEGUI.UDim(0, P.buttonHeight*index)))
350    node:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.indentWidth*depth-P.scrollbarWidth), CEGUI.UDim(0, P.buttonHeight)))
351    orxonox.GUIManager:subscribeEventHelper(node, "Clicked", P.name .. ".openDetails_clicked")
352    root:addChildWindow(node)
353   
354    table.insert(P.quests, parent)
355
356    index = index+1
357
358    -- Iterate through all sub-quests.
359    local numQuests = orxonox.QuestManager:getInstance():getNumSubQuests(parent, P.player)
360    local i = 0
361    while i <= numQuests-1 do
362        local quest = orxonox.QuestManager:getInstance():getSubQuest(parent, P.player, i)
363        index = P.createQuestNodes(root, quest, depth+1, index)
364        i = i+1
365    end
366
[7732]367    return index
[7163]368end
369
370function P.cleanup()
371    winMgr:destroyWindow(P.rootWindow)
372    for k,v in pairs(P.detailsWindows) do
373        if v ~= nil then
374            winMgr:destroyWindow(v)
375            P.detailsWindows[k] = nil
376        end
377    end
378    P.detailsWindows = {}
379
380    P.quests = {}
381    P.hints = {}
382    P.player = nil
383
384    winMgr:destroyWindow(P.rootWindow)
385    P.rootWindow = nil
386end
387
388function P.openDetails_clicked(e)
389    --Get some numbers from the window
390    local we = CEGUI.toWindowEventArgs(e)
391    local name = we.window:getName()
392    local match = string.gmatch(name, "%d+")
393    local questNr = tonumber(match())
394
395    name = name .. "/Details" .. P.getNewDetailNumber()
396    quest = P.quests[questNr]
397
398    local details = winMgr:createWindow("MenuWidgets/FrameWindow", name)
399    details:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.7, 0)))
400    details:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0), CEGUI.UDim(0.1, 0)))
401    details:setText(orxonox.QuestManager:getInstance():getDescription(quest):getTitle())
402    details:setProperty("Alpha", 1.0)
403    details:setProperty("InheritsAlpha", "setFalse")
404    orxonox.GUIManager:subscribeEventHelper(details, "CloseClicked", P.name .. ".closeDetails_clicked")
405
406    table.insert(P.detailsWindows, details)
407
408    name = name .. "/Scrollable"
409    local window = winMgr:createWindow("MenuWidgets/ScrollablePane", name)
410    window:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -2*P.borderWidth),CEGUI.UDim(1.0, -P.titleHeight)))
411    window:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderWidth), CEGUI.UDim(0, P.titleHeight)))
412    details:addChildWindow(window)
413
414    local offset = 0
415
416    local status = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Status")
417    window:addChildWindow(status)
418    status:setProperty("HorzFormatting", "WordWrapLeftAligned")
419    status:setProperty("VertFormatting", "TopAligned")
420    if quest:isActive(P.player) then
421        status:setText("This quest is active.")
422    elseif quest:isCompleted(P.player) then
423        status:setText("This quest was completed.")
424    elseif quest:isFailed(P.player) then
425        status:setText("This quest was failed.")
426    end
427    status:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
428    status:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
429    local height = getStaticTextWindowHeight(status)
430    status:setHeight(CEGUI.UDim(0, height))
431    offset = offset + height
432
[7732]433    local descriptionTitle = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Title")
[7163]434    window:addChildWindow(descriptionTitle)
435    descriptionTitle:setProperty("HorzFormatting", "HorzCentred")
436    descriptionTitle:setProperty("VertFormatting", "TopAligned")
437    descriptionTitle:setText("Description:")
438    descriptionTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
439    descriptionTitle:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
440    height = getStaticTextWindowHeight(descriptionTitle)
441    descriptionTitle:setHeight(CEGUI.UDim(0, height))
442    offset = offset + height
443
[7732]444    local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description")
[7163]445    window:addChildWindow(description)
446    description:setProperty("HorzFormatting", "WordWrapLeftAligned")
447    description:setProperty("VertFormatting", "TopAligned")
448    description:setText(orxonox.QuestManager:getInstance():getDescription(quest):getDescription())
449    description:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
450    description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
451    height = getStaticTextWindowHeight(description)
452    description:setHeight(CEGUI.UDim(0, height))
453    offset = offset + height
454
455    -- Display the hints of this quest
456    local numHints = orxonox.QuestManager:getInstance():getNumHints(quest, P.player)
457    if numHints > 0 then
[7732]458        local hintsTitle = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Hints/Title")
[7163]459        window:addChildWindow(hintsTitle)
460        hintsTitle:setProperty("HorzFormatting", "HorzCentred")
461        hintsTitle:setProperty("VertFormatting", "TopAligned")
462        hintsTitle:setText("Hints:")
463        hintsTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
464        hintsTitle:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
465        height = getStaticTextWindowHeight(hintsTitle)
466        hintsTitle:setHeight(CEGUI.UDim(0, height))
467        offset = offset + height
468    end
469    local i = 0
470    while i <= numHints-1 do
471        local hint = orxonox.QuestManager:getInstance():getHints(quest, P.player, i)
472        table.insert(P.hints, hint)
473        local number = table.getn(P.hints)
474        local node = winMgr:createWindow("MenuWidgets/TabButton", name .. "/Hints" .. number)
475        node:setText(orxonox.QuestManager:getInstance():getDescription(hint):getTitle())
476        node:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
477        node:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth), CEGUI.UDim(0, P.buttonHeight)))
478        window:addChildWindow(node)
479        offset = offset + P.buttonHeight
480
481        orxonox.GUIManager:subscribeEventHelper(node, "Clicked", P.name .. ".openHintDetails_clicked")
482        i = i+1
483    end
484
485    local window = winMgr:getWindow("orxonox/QuestGUI/Background")
486    window:addChildWindow(details)
487end
488
489function P.getNewDetailNumber()
490    local number = table.getn(P.detailsWindows)
491    for k,v in pairs(P.detailsWindows) do
492        if v == nil then
493            number = k-1
494        end
495    end
496    return number+1
497end
498
499function P.closeDetails_clicked(e)
500    local we = CEGUI.toWindowEventArgs(e)
501    local name = we.window:getName()
502    local match = string.gmatch(name, "%d+")
503    match()
504    local detailsNr = tonumber(match())
505
506    winMgr:destroyWindow(P.detailsWindows[detailsNr])
507    P.detailsWindows[detailsNr] = nil
508end
509
510function P.openHintDetails_clicked(e)
511    --Get some numbers from the window
512    local we = CEGUI.toWindowEventArgs(e)
513    local name = we.window:getName()
514    local match = string.gmatch(name, "%d+")
515    match()
516    match()
517    local hintNr = tonumber(match())
518
519    name = name .. "/Details" .. P.getNewDetailNumber()
520    hint = P.hints[hintNr]
521
522    local details = winMgr:createWindow("MenuWidgets/FrameWindow", name)
523    details:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.7, 0)))
524    details:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0), CEGUI.UDim(0.1, 0)))
525    details:setText(orxonox.QuestManager:getInstance():getDescription(hint):getTitle())
526    details:setProperty("Alpha", 1.0)
527    details:setProperty("InheritsAlpha", "setFalse")
528    orxonox.GUIManager:subscribeEventHelper(details, "CloseClicked", P.name .. ".closeHintDetails_clicked")
529
530    table.insert(P.detailsWindows, details)
531
532    name = name .. "/Scrollable"
533    local window = winMgr:createWindow("MenuWidgets/ScrollablePane", name)
534    window:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -2*P.borderWidth),CEGUI.UDim(1.0, -P.titleHeight)))
535    window:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderWidth), CEGUI.UDim(0, P.titleHeight)))
536    details:addChildWindow(window)
537
538    local offset = 0
539   
[7732]540    local descriptionTitle = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Title")
[7163]541    window:addChildWindow(descriptionTitle)
542    descriptionTitle:setProperty("HorzFormatting", "HorzCentred")
543    descriptionTitle:setProperty("VertFormatting", "TopAligned")
544    descriptionTitle:setText("Description:")
545    descriptionTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
546    descriptionTitle:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
547    height = getStaticTextWindowHeight(descriptionTitle)
548    descriptionTitle:setHeight(CEGUI.UDim(0, height))
549    offset = offset + height
550
[7732]551    local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description")
[7163]552    window:addChildWindow(description)
553    description:setProperty("HorzFormatting", "WordWrapLeftAligned")
554    description:setProperty("VertFormatting", "TopAligned")
555    description:setText(orxonox.QuestManager:getInstance():getDescription(hint):getDescription())
556    description:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
557    description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
558    height = getStaticTextWindowHeight(description)
559    description:setHeight(CEGUI.UDim(0, height))
560
561    local window = winMgr:getWindow("orxonox/QuestGUI/Background")
562    window:addChildWindow(details)
563end
564
565function P.closeHintDetails_clicked(e)
566    local we = CEGUI.toWindowEventArgs(e)
567    local name = we.window:getName()
568    local match = string.gmatch(name, "%d+")
569    match()
570    match()
571    match()
572    local detailsNr = tonumber(match())
573
574    winMgr:destroyWindow(P.detailsWindows[detailsNr])
575    P.detailsWindows[detailsNr] = nil
[8706]576end --]]
[7163]577
[5746]578return P
579
Note: See TracBrowser for help on using the repository browser.