* Renamed game_textbooks to game_textwindow. * Fixed text window from opening multiple times, and is destroyed correctly. * Added new game_playerdeath module (moved death message and window here). * Hotkey window will hide on game end. * Logout/Exit/Stackable Items/Questlog/Hotkeys windows will now close on game end.master
pai
e3298d561c
commit
694a69e1bf
@ -0,0 +1,70 @@
|
||||
PlayerDeath = {}
|
||||
|
||||
-- private variables
|
||||
local deathWindow
|
||||
|
||||
-- private functions
|
||||
|
||||
-- public functions
|
||||
function PlayerDeath.init()
|
||||
g_ui.importStyle('deathwindow.otui')
|
||||
|
||||
connect(g_game, { onDeath = PlayerDeath.display,
|
||||
onGameEnd = PlayerDeath.reset })
|
||||
end
|
||||
|
||||
function PlayerDeath.terminate()
|
||||
disconnect(g_game, { onDeath = PlayerDeath.display,
|
||||
onGameEnd = PlayerDeath.reset })
|
||||
|
||||
PlayerDeath.reset()
|
||||
PlayerDeath = nil
|
||||
end
|
||||
|
||||
function PlayerDeath.reset()
|
||||
GameInterface.getMapPanel():recursiveGetChildById('centerAdvance'):hide()
|
||||
if(deathWindow) then
|
||||
deathWindow:destroy()
|
||||
deathWindow = nil
|
||||
end
|
||||
end
|
||||
|
||||
function PlayerDeath.display()
|
||||
PlayerDeath.displayDeadMessage()
|
||||
PlayerDeath.openWindow()
|
||||
end
|
||||
|
||||
function PlayerDeath.displayDeadMessage()
|
||||
local advanceLabel = GameInterface.getMapPanel():recursiveGetChildById('centerAdvance')
|
||||
if advanceLabel:isVisible() then
|
||||
return
|
||||
end
|
||||
|
||||
TextMessage.displayEventAdvance(tr('You are dead.'))
|
||||
end
|
||||
|
||||
function PlayerDeath.openWindow()
|
||||
if(deathWindow) then
|
||||
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()
|
||||
GameInterface.logout()
|
||||
cancelButton:getParent():destroy()
|
||||
deathWindow = nil
|
||||
end
|
||||
|
||||
deathWindow.onEnter = okFunc
|
||||
deathWindow.onEscape = cancelFunc
|
||||
|
||||
okButton.onClick = okFunc
|
||||
cancelButton.onClick = cancelFunc
|
||||
end
|
@ -0,0 +1,17 @@
|
||||
Module
|
||||
name: game_playerdeath
|
||||
description: Manage player deaths
|
||||
author: edubart, BeniS
|
||||
website: www.otclient.info
|
||||
|
||||
dependencies:
|
||||
- game_interface
|
||||
- game_textmessage
|
||||
- client_entergame
|
||||
|
||||
@onLoad: |
|
||||
dofile 'playerdeath'
|
||||
PlayerDeath.init()
|
||||
|
||||
@onUnload: |
|
||||
PlayerDeath.terminate()
|
@ -1,15 +1,15 @@
|
||||
Module
|
||||
name: game_textbooks
|
||||
name: game_textwindow
|
||||
description: Allow to edit text books and lists
|
||||
author: edubart
|
||||
author: edubart, BeniS
|
||||
website: www.otclient.info
|
||||
|
||||
dependencies:
|
||||
- game_interface
|
||||
|
||||
@onLoad: |
|
||||
dofile 'textbooks'
|
||||
TextBooks.init()
|
||||
dofile 'textwindow'
|
||||
TextWindow.init()
|
||||
|
||||
@onUnload: |
|
||||
TextBooks.terminate()
|
||||
TextWindow.terminate()
|
Carregando…
Referência em uma nova issue