2012-07-24 07:30:08 +02:00
|
|
|
questLogButton = nil
|
|
|
|
questLineWindow = nil
|
2012-05-01 02:20:27 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function init()
|
2013-01-18 23:39:11 +01:00
|
|
|
g_ui.importStyle('questlogwindow')
|
|
|
|
g_ui.importStyle('questlinewindow')
|
2012-07-24 07:30:08 +02:00
|
|
|
|
2013-01-18 23:39:11 +01:00
|
|
|
questLogButton = modules.client_topmenu.addLeftGameButton('questLogButton', tr('Quest Log'), '/images/topbuttons/questlog', function() g_game.requestQuestLog() end)
|
2012-05-01 04:00:07 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
connect(g_game, { onQuestLog = onGameQuestLog,
|
|
|
|
onQuestLine = onGameQuestLine,
|
|
|
|
onGameEnd = destroyWindows})
|
|
|
|
end
|
|
|
|
|
|
|
|
function terminate()
|
|
|
|
disconnect(g_game, { onQuestLog = onGameQuestLog,
|
|
|
|
onQuestLine = onGameQuestLine,
|
|
|
|
onGameEnd = destroyWindows})
|
|
|
|
|
|
|
|
destroyWindows()
|
2013-02-01 05:32:15 +01:00
|
|
|
questLogButton:destroy()
|
2012-07-24 07:30:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function destroyWindows()
|
|
|
|
if questLogWindow then
|
|
|
|
questLogWindow:destroy()
|
|
|
|
end
|
|
|
|
|
|
|
|
if questLineWindow then
|
|
|
|
questLineWindow:destroy()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function onGameQuestLog(quests)
|
|
|
|
destroyWindows()
|
2012-05-01 04:00:07 +02:00
|
|
|
|
2012-06-26 00:13:30 +02:00
|
|
|
questLogWindow = g_ui.createWidget('QuestLogWindow', rootWidget)
|
2012-05-01 04:00:07 +02:00
|
|
|
local questList = questLogWindow:getChildById('questList')
|
|
|
|
|
|
|
|
for i,questEntry in pairs(quests) do
|
|
|
|
local id, name, completed = unpack(questEntry)
|
|
|
|
|
2012-06-26 00:13:30 +02:00
|
|
|
local questLabel = g_ui.createWidget('QuestLabel', questList)
|
2012-05-01 04:00:07 +02:00
|
|
|
questLabel:setOn(completed)
|
|
|
|
questLabel:setText(name)
|
|
|
|
questLabel.onDoubleClick = function()
|
|
|
|
questLogWindow:hide()
|
|
|
|
g_game.requestQuestLine(id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
questLogWindow.onDestroy = function()
|
|
|
|
questLogWindow = nil
|
2012-05-01 02:20:27 +02:00
|
|
|
end
|
2012-09-05 21:33:36 +02:00
|
|
|
|
|
|
|
questList:focusChild(questList:getFirstChild())
|
2012-05-01 02:20:27 +02:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function onGameQuestLine(questId, questMissions)
|
2012-05-01 04:00:07 +02:00
|
|
|
if questLogWindow then questLogWindow:hide() end
|
|
|
|
if questLineWindow then questLineWindow:destroy() end
|
|
|
|
|
2012-06-26 00:13:30 +02:00
|
|
|
questLineWindow = g_ui.createWidget('QuestLineWindow', rootWidget)
|
2012-05-01 04:00:07 +02:00
|
|
|
local missionList = questLineWindow:getChildById('missionList')
|
|
|
|
local missionDescription = questLineWindow:getChildById('missionDescription')
|
|
|
|
|
2012-06-02 02:38:26 +02:00
|
|
|
connect(missionList, { onChildFocusChange = function(self, focusedChild)
|
2012-05-01 04:00:07 +02:00
|
|
|
if focusedChild == nil then return end
|
|
|
|
missionDescription:setText(focusedChild.description)
|
2012-06-02 02:38:26 +02:00
|
|
|
end })
|
2012-05-01 04:00:07 +02:00
|
|
|
|
2012-05-01 02:20:27 +02:00
|
|
|
for i,questMission in pairs(questMissions) do
|
|
|
|
local name, description = unpack(questMission)
|
2012-05-01 04:00:07 +02:00
|
|
|
|
2012-09-05 21:33:36 +02:00
|
|
|
local missionLabel = g_ui.createWidget('MissionLabel')
|
2012-05-01 04:00:07 +02:00
|
|
|
missionLabel:setText(name)
|
|
|
|
missionLabel.description = description
|
2012-09-05 21:33:36 +02:00
|
|
|
missionList:addChild(missionLabel)
|
2012-05-01 04:00:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
questLineWindow.onDestroy = function()
|
|
|
|
if questLogWindow then questLogWindow:show() end
|
|
|
|
questLineWindow = nil
|
2012-05-01 02:20:27 +02:00
|
|
|
end
|
2012-09-05 21:33:36 +02:00
|
|
|
|
|
|
|
missionList:focusChild(missionList:getFirstChild())
|
2012-05-01 02:20:27 +02:00
|
|
|
end
|
2012-09-05 21:33:36 +02:00
|
|
|
|