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

2
TODO
View File

@ -3,8 +3,6 @@ game_shaders (with shader manager)
game_map (with save/load/options) game_map (with save/load/options)
game_minimap (with all tibia functionality) game_minimap (with all tibia functionality)
game_playertrade game_playertrade
game_textbooks
game_questlog
game_ruleviolations game_ruleviolations
== NOTABLE FEATURES == NOTABLE FEATURES

View File

@ -5,6 +5,18 @@ Label < UILabel
$disabled: $disabled:
color: #bbbbbb88 color: #bbbbbb88
FlatLabel < UILabel
font: verdana-11px-antialised
color: #aaaaaa
size: 86 20
text-offset: 3 3
text-margin: 3
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
$disabled:
color: #aaaaaa88
GameLabel < UILabel GameLabel < UILabel
font: verdana-11px-antialised font: verdana-11px-antialised
color: #bbbbbb color: #bbbbbb

View File

@ -88,25 +88,11 @@ MiniWindow
margin-top: 5 margin-top: 5
&position: {x=65535, y=10, z=0} &position: {x=65535, y=10, z=0}
GameLabel
id: soul
anchors.top: slot9.bottom
anchors.bottom: slot8.bottom
anchors.left: slot9.left
anchors.right: slot9.right
margin-top: 5
text-align: center
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1
GameLabel GameLabel
id: capacity id: capacity
height: 30
anchors.top: slot10.bottom anchors.top: slot10.bottom
anchors.bottom: slot8.bottom
anchors.left: slot10.left anchors.left: slot10.left
anchors.right: slot10.right
margin-top: 5 margin-top: 5
text-align: center text-align: center
image-source: /core_styles/styles/images/panel_flat.png
image-border: 1

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 = {} QuestLog = {}
local questLogButton
local questLogWindow
local questLineWindow
-- g_game.requestQuestLog() -- g_game.requestQuestLog()
-- g_game.requestQuestLine(questId) -- g_game.requestQuestLine(questId)
local function onGameQuestLog(questList) local function onGameQuestLog(quests)
for i,questEntry in pairs(questList) do QuestLog.destroyWindows()
local id, name, done = unpack(questEntry)
print(id, name, done) 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
end end
local function onGameQuestLine(questId, questMissions) 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 for i,questMission in pairs(questMissions) do
local name, description = unpack(questMission) 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
end end
function QuestLog.init() function QuestLog.init()
importStyle 'questlogwindow.otui' 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, { onQuestLog = onGameQuestLog })
connect(g_game, { onQuestLine= onGameQuestLine }) connect(g_game, { onQuestLine= onGameQuestLine })
end end
function QuestLog.destroyWindows()
if questLogWindow then
questLogWindow:destroy()
questLogWindow = nil
end
if questLineWindow then
questLineWindow:destroy()
questLineWindow = nil
end
end
function QuestLog.terminate() function QuestLog.terminate()
disconnect(g_game, { onQuestLog = onGameQuestLog }) disconnect(g_game, { onQuestLog = onGameQuestLog })
disconnect(g_game, { onQuestLine= onGameQuestLine }) disconnect(g_game, { onQuestLine= onGameQuestLine })
QuestLog.destroyWindows()
end 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()

View File

@ -60,7 +60,7 @@ local function onGameEditList(id, doorId, text)
textEdit:setMaxLength(8192) textEdit:setMaxLength(8192)
textEdit:setText(text) textEdit:setText(text)
textEdit:setEnabled(true) textEdit:setEnabled(true)
description:setText(tr('Enter one text per line.')) description:setText(tr('Enter one name per line.'))
textWindow:setText(tr('Edit List')) textWindow:setText(tr('Edit List'))
okButton.onClick = function() okButton.onClick = function()

View File

@ -33,7 +33,7 @@ public:
static TexturePtr loadPNG(std::stringstream& file); static TexturePtr loadPNG(std::stringstream& file);
private: private:
std::map<std::string, TextureWeakPtr> m_textures; std::unordered_map<std::string, TextureWeakPtr> m_textures;
}; };
extern TextureManager g_textures; extern TextureManager g_textures;

View File

@ -82,7 +82,7 @@ private:
Boolean<false> m_hoverUpdateScheduled; Boolean<false> m_hoverUpdateScheduled;
bool m_isOnInputEvent; bool m_isOnInputEvent;
Boolean<false> m_drawDebugBoxes; Boolean<false> m_drawDebugBoxes;
std::map<std::string, OTMLNodePtr> m_styles; std::unordered_map<std::string, OTMLNodePtr> m_styles;
}; };
extern UIManager g_ui; extern UIManager g_ui;