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,51 +1,42 @@
PlayerDeath = {}
deathWindow = nil
-- private variables
local deathWindow
-- private functions
-- public functions
function PlayerDeath.init()
function init()
g_ui.importStyle('deathwindow.otui')
connect(g_game, { onDeath = PlayerDeath.display,
onGameEnd = PlayerDeath.reset })
connect(g_game, { onDeath = display,
onGameEnd = reset })
end
function PlayerDeath.terminate()
disconnect(g_game, { onDeath = PlayerDeath.display,
onGameEnd = PlayerDeath.reset })
function terminate()
disconnect(g_game, { onDeath = display,
onGameEnd = reset })
PlayerDeath.reset()
PlayerDeath = nil
reset()
end
function PlayerDeath.reset()
function reset()
if deathWindow then
deathWindow:destroy()
deathWindow = nil
end
end
function PlayerDeath.display()
PlayerDeath.displayDeadMessage()
PlayerDeath.openWindow()
function display()
displayDeadMessage()
openWindow()
end
function PlayerDeath.displayDeadMessage()
local advanceLabel = GameInterface.getMapPanel():recursiveGetChildById('centerAdvance')
function displayDeadMessage()
local advanceLabel = modules.game_interface.getMapPanel():recursiveGetChildById('centerAdvance')
if advanceLabel:isVisible() then
return
end
TextMessage.displayEventAdvance(tr('You are dead.'))
modules.game_textmessage.displayEventAdvance(tr('You are dead.'))
end
function PlayerDeath.openWindow()
if deathWindow then
return
end
function openWindow()
if deathWindow then return end
deathWindow = g_ui.createWidget('DeathWindow', rootWidget)
local okButton = deathWindow:getChildById('buttonOk')
local cancelButton = deathWindow:getChildById('buttonCancel')
@@ -56,7 +47,7 @@ function PlayerDeath.openWindow()
deathWindow = nil
end
local cancelFunc = function()
GameInterface.logout()
modules.game_interface.logout()
cancelButton:getParent():destroy()
deathWindow = nil
end
@@ -66,4 +57,4 @@ function PlayerDeath.openWindow()
okButton.onClick = okFunc
cancelButton.onClick = cancelFunc
end
end

View File

@@ -3,15 +3,7 @@ Module
description: Manage player deaths
author: BeniS, edubart
website: www.otclient.info
dependencies:
- game_interface
- game_textmessage
- client_entergame
@onLoad: |
dofile 'playerdeath'
PlayerDeath.init()
@onUnload: |
PlayerDeath.terminate()
sandboxed: true
scripts: [ playerdeath.lua ]
@onLoad: init()
@onUnload: terminate()