tibia-client/modules/game_playerdeath/playerdeath.lua

62 lines
1.3 KiB
Lua
Raw Normal View History

deathWindow = nil
function init()
g_ui.importStyle('deathwindow')
connect(g_game, { onDeath = display,
onGameEnd = reset })
end
function terminate()
disconnect(g_game, { onDeath = display,
onGameEnd = reset })
reset()
end
function reset()
if deathWindow then
deathWindow:destroy()
2013-11-12 15:19:45 +01:00
deathWindow = nil
end
end
function display()
displayDeadMessage()
openWindow()
end
function displayDeadMessage()
2012-07-31 02:57:31 +02:00
local advanceLabel = modules.game_interface.getRootPanel():recursiveGetChildById('middleCenterLabel')
if advanceLabel:isVisible() then return end
modules.game_textmessage.displayGameMessage(tr('You are dead.'))
end
function openWindow()
if deathWindow then
deathWindow:destroy()
return
end
deathWindow = g_ui.createWidget('DeathWindow', rootWidget)
local okButton = deathWindow:getChildById('buttonOk')
local cancelButton = deathWindow:getChildById('buttonCancel')
local okFunc = function()
CharacterList.doLogin()
okButton:getParent():destroy()
deathWindow = nil
end
local cancelFunc = function()
2013-07-02 22:40:19 +02:00
g_game.safeLogout()
cancelButton:getParent():destroy()
deathWindow = nil
end
deathWindow.onEnter = okFunc
deathWindow.onEscape = cancelFunc
okButton.onClick = okFunc
cancelButton.onClick = cancelFunc
end