Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutoriallevel/data/gui/scripts/QuestGUI.lua @ 8225

Last change on this file since 8225 was 7831, checked in by dafrick, 14 years ago

Improvements on QuestGUI, also documented some of the code.

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