Use new coding style in game modules

Lots of refactoring and changes
Remove docs folder
This commit is contained in:
Eduardo Bart
2012-07-24 02:30:08 -03:00
parent 1c3e630237
commit c54cd1fdf1
69 changed files with 1629 additions and 2634 deletions

View File

@@ -1,11 +1,39 @@
QuestLog = {}
questLogButton = nil
questLineWindow = nil
local questLogButton
local questLogWindow
local questLineWindow
function init()
g_ui.importStyle('questlogwindow.otui')
g_ui.importStyle('questlinewindow.otui')
local function onGameQuestLog(quests)
QuestLog.destroyWindows()
questLogButton = TopMenu.addLeftGameButton('questLogButton', tr('Quest Log'), 'questlog.png', function() g_game.requestQuestLog() end)
connect(g_game, { onQuestLog = onGameQuestLog,
onQuestLine = onGameQuestLine,
onGameEnd = destroyWindows})
end
function terminate()
disconnect(g_game, { onQuestLog = onGameQuestLog,
onQuestLine = onGameQuestLine,
onGameEnd = destroyWindows})
destroyWindows()
end
function destroyWindows()
if questLogWindow then
questLogWindow:destroy()
questLogWindow = nil
end
if questLineWindow then
questLineWindow:destroy()
questLineWindow = nil
end
end
function onGameQuestLog(quests)
destroyWindows()
questLogWindow = g_ui.createWidget('QuestLogWindow', rootWidget)
local questList = questLogWindow:getChildById('questList')
@@ -27,7 +55,7 @@ local function onGameQuestLog(quests)
end
end
local function onGameQuestLine(questId, questMissions)
function onGameQuestLine(questId, questMissions)
if questLogWindow then questLogWindow:hide() end
if questLineWindow then questLineWindow:destroy() end
@@ -53,37 +81,3 @@ local function onGameQuestLine(questId, questMissions)
questLineWindow = nil
end
end
function QuestLog.init()
g_ui.importStyle('questlogwindow.otui')
g_ui.importStyle('questlinewindow.otui')
questLogButton = TopMenu.addLeftGameButton('questLogButton', tr('Quest Log'), 'questlog.png', function() g_game.requestQuestLog() end)
connect(g_game, { onQuestLog = onGameQuestLog,
onQuestLine = onGameQuestLine,
onGameEnd = QuestLog.destroyWindows})
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,
onQuestLine = onGameQuestLine,
onGameEnd = QuestLog.destroyWindows})
QuestLog.destroyWindows()
questLogButton:destroy()
questLogButton = nil
end

View File

@@ -3,13 +3,7 @@ Module
description: View game quests status
author: edubart
website: www.otclient.info
dependencies:
- game_interface
@onLoad: |
dofile 'questlog'
QuestLog.init()
@onUnload: |
QuestLog.terminate()
sandboxed: true
scripts: [ questlog.lua ]
@onLoad: init()
@onUnload: terminate()