Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ai2/data/gui/scripts/QuestGUI.lua @ 8838

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

Minor level changes. Questmenu pauses game now.

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