2012-07-24 07:30:08 +02:00
|
|
|
deathWindow = nil
|
2012-07-14 12:59:32 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function init()
|
2012-07-14 12:59:32 +02:00
|
|
|
g_ui.importStyle('deathwindow.otui')
|
2012-07-19 11:12:17 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
connect(g_game, { onDeath = display,
|
|
|
|
onGameEnd = reset })
|
2012-07-14 12:59:32 +02:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function terminate()
|
|
|
|
disconnect(g_game, { onDeath = display,
|
|
|
|
onGameEnd = reset })
|
2012-07-14 12:59:32 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
reset()
|
2012-07-14 12:59:32 +02:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function reset()
|
2012-07-15 13:49:28 +02:00
|
|
|
if deathWindow then
|
2012-07-14 12:59:32 +02:00
|
|
|
deathWindow:destroy()
|
|
|
|
deathWindow = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function display()
|
|
|
|
displayDeadMessage()
|
|
|
|
openWindow()
|
2012-07-14 12:59:32 +02:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function displayDeadMessage()
|
2012-07-31 02:57:31 +02:00
|
|
|
local advanceLabel = modules.game_interface.getRootPanel():recursiveGetChildById('middleCenterLabel')
|
|
|
|
if advanceLabel:isVisible() then return end
|
2012-07-19 11:12:17 +02:00
|
|
|
|
2012-07-26 11:12:20 +02:00
|
|
|
modules.game_textmessage.displayGameMessage(tr('You are dead.'))
|
2012-07-14 12:59:32 +02:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function openWindow()
|
|
|
|
if deathWindow then return end
|
2012-07-14 12:59:32 +02:00
|
|
|
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()
|
2012-07-24 07:30:08 +02:00
|
|
|
modules.game_interface.logout()
|
2012-07-14 12:59:32 +02:00
|
|
|
cancelButton:getParent():destroy()
|
|
|
|
deathWindow = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
deathWindow.onEnter = okFunc
|
|
|
|
deathWindow.onEscape = cancelFunc
|
2012-07-19 11:12:17 +02:00
|
|
|
|
2012-07-14 12:59:32 +02:00
|
|
|
okButton.onClick = okFunc
|
|
|
|
cancelButton.onClick = cancelFunc
|
2012-07-24 07:30:08 +02:00
|
|
|
end
|