questlog module complete

This commit is contained in:
Eduardo Bart
2012-04-30 23:00:07 -03:00
parent f290d821f1
commit 2f0a151fed
9 changed files with 181 additions and 26 deletions

View File

@@ -0,0 +1,52 @@
MissionLabel < Label
font: verdana-11px-monochrome
background-color: alpha
text-offset: 2 0
focusable: true
$focus:
background-color: #ffffff22
color: #ffffff
QuestLineWindow < MainWindow
id: questLineWindow
!text: tr('Quest Log')
size: 500 400
@onEscape: self:destroy()
TextList
id: missionList
anchors.fill: parent
anchors.bottom: none
width: 200
height: 200
padding: 1
focusable: false
margin-right: 20
vertical-scrollbar: missionListScrollBar
VerticalScrollBar
id: missionListScrollBar
anchors.top: missionList.top
anchors.bottom: missionList.bottom
anchors.left: missionList.right
step: 14
pixels-scroll: true
FlatLabel
id: missionDescription
anchors.top: missionList.bottom
anchors.left: parent.left
anchors.right: missionListScrollBar.right
anchors.bottom: parent.bottom
margin-bottom: 30
margin-top: 10
text-wrap: true
Button
id: closeButton
anchors.bottom: parent.bottom
anchors.right: parent.right
!text: tr('Close')
width: 90
@onClick: self:getParent():destroy()

View File

@@ -1,30 +1,87 @@
QuestLog = {}
local questLogButton
local questLogWindow
local questLineWindow
-- g_game.requestQuestLog()
-- g_game.requestQuestLine(questId)
local function onGameQuestLog(questList)
for i,questEntry in pairs(questList) do
local id, name, done = unpack(questEntry)
print(id, name, done)
local function onGameQuestLog(quests)
QuestLog.destroyWindows()
questLogWindow = createWidget('QuestLogWindow', rootWidget)
local questList = questLogWindow:getChildById('questList')
for i,questEntry in pairs(quests) do
local id, name, completed = unpack(questEntry)
local questLabel = createWidget('QuestLabel', questList)
questLabel:setOn(completed)
questLabel:setText(name)
questLabel.onDoubleClick = function()
questLogWindow:hide()
g_game.requestQuestLine(id)
end
end
questLogWindow.onDestroy = function()
questLogWindow = nil
end
end
local function onGameQuestLine(questId, questMissions)
if questLogWindow then questLogWindow:hide() end
if questLineWindow then questLineWindow:destroy() end
questLineWindow = createWidget('QuestLineWindow', rootWidget)
local missionList = questLineWindow:getChildById('missionList')
local missionDescription = questLineWindow:getChildById('missionDescription')
missionList.onChildFocusChange = function(self, focusedChild)
if focusedChild == nil then return end
missionDescription:setText(focusedChild.description)
end
for i,questMission in pairs(questMissions) do
local name, description = unpack(questMission)
print(name, description)
local missionLabel = createWidget('MissionLabel', missionList)
missionLabel:setText(name)
missionLabel.description = description
end
questLineWindow.onDestroy = function()
if questLogWindow then questLogWindow:show() end
questLineWindow = nil
end
end
function QuestLog.init()
importStyle 'questlogwindow.otui'
importStyle 'questlinewindow.otui'
questLogButton = TopMenu.addGameButton('questLogButton', tr('Quest Log'), 'questlog.png', function() g_game.requestQuestLog() end)
connect(g_game, { onQuestLog = onGameQuestLog })
connect(g_game, { onQuestLine= onGameQuestLine })
end
function QuestLog.destroyWindows()
if questLogWindow then
questLogWindow:destroy()
questLogWindow = nil
end
if questLineWindow then
questLineWindow:destroy()
questLineWindow = nil
end
end
function QuestLog.terminate()
disconnect(g_game, { onQuestLog = onGameQuestLog })
disconnect(g_game, { onQuestLine= onGameQuestLine })
QuestLog.destroyWindows()
end

View File

@@ -1 +1,51 @@
QuestLogWindow < MainWindow
QuestLabel < Label
font: verdana-11px-monochrome
background-color: alpha
text-offset: 2 0
focusable: true
color: #cccccc
$focus:
color: #ffffff
$on:
background-color: #006600
$!on:
background-color: #660000
$on focus:
background-color: #004400
$!on focus:
background-color: #440000
QuestLogWindow < MainWindow
id: questLogWindow
!text: tr('Quest Log')
size: 500 400
@onEscape: self:destroy()
TextList
id: questList
anchors.fill: parent
width: 190
padding: 1
focusable: false
margin-bottom: 30
margin-right: 20
vertical-scrollbar: questListScrollBar
VerticalScrollBar
id: questListScrollBar
anchors.top: questList.top
anchors.bottom: questList.bottom
anchors.left: questList.right
step: 14
pixels-scroll: true
Button
id: closeButton
anchors.bottom: parent.bottom
anchors.right: parent.right
!text: tr('Close')
width: 90
@onClick: self:getParent():destroy()