Changed/Fixed Text Windows, Text Message, Hotkeys Manager, Game Interface and Quest Log
* 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.
This commit is contained in:
parent
e3298d561c
commit
694a69e1bf
|
@ -25,11 +25,12 @@ Module
|
|||
- game_battle
|
||||
- game_minimap
|
||||
- game_npctrade
|
||||
- game_textbooks
|
||||
- game_textwindow
|
||||
- game_playertrade
|
||||
- game_ruleviolation
|
||||
- game_bugreport
|
||||
- game_shaders
|
||||
- game_playerdeath
|
||||
|
||||
@onLoad: |
|
||||
dofile 'const'
|
||||
|
|
|
@ -61,6 +61,7 @@ function HotkeysManager.init()
|
|||
itemWidget:setVisible(false)
|
||||
itemWidget:setFocusable(false)
|
||||
|
||||
connect(g_game, { onGameEnd = HotkeysManager.hide })
|
||||
connect(currentHotkeysList, { onChildFocusChange = function (self, focusedChild) HotkeysManager.checkSelectedHotkey(focusedChild) end } )
|
||||
|
||||
hotkeysManagerLoaded = true
|
||||
|
@ -104,6 +105,7 @@ end
|
|||
function HotkeysManager.terminate()
|
||||
hotkeysManagerLoaded = false
|
||||
|
||||
disconnect(g_game, { onGameEnd = HotkeysManager.hide })
|
||||
g_keyboard.unbindKeyDown('Ctrl+K')
|
||||
|
||||
HotkeysManager.save()
|
||||
|
|
|
@ -27,8 +27,8 @@ function GameInterface.init()
|
|||
g_ui.importStyle('styles/logoutwindow.otui')
|
||||
g_ui.importStyle('styles/exitwindow.otui')
|
||||
|
||||
connect(g_game, { onGameStart = GameInterface.show }, true)
|
||||
connect(g_game, { onGameEnd = GameInterface.hide }, true)
|
||||
connect(g_game, { onGameStart = GameInterface.show,
|
||||
onGameEnd = GameInterface.hide }, true)
|
||||
|
||||
gameRootPanel = g_ui.displayUI('gameinterface.otui')
|
||||
gameRootPanel:hide()
|
||||
|
@ -88,8 +88,8 @@ function GameInterface.init()
|
|||
end
|
||||
|
||||
function GameInterface.terminate()
|
||||
disconnect(g_game, { onGameStart = GameInterface.show })
|
||||
disconnect(g_game, { onGameEnd = GameInterface.hide })
|
||||
disconnect(g_game, { onGameStart = GameInterface.show,
|
||||
onGameEnd = GameInterface.hide })
|
||||
disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })
|
||||
|
||||
logoutButton:destroy()
|
||||
|
@ -117,6 +117,18 @@ function GameInterface.show()
|
|||
end
|
||||
|
||||
function GameInterface.hide()
|
||||
if(logoutWindow) then
|
||||
logoutWindow:destroy()
|
||||
logoutWindow = nil
|
||||
end
|
||||
if(exitWindow) then
|
||||
exitWindow:destroy()
|
||||
exitWindow = nil
|
||||
end
|
||||
if(countWindow) then
|
||||
countWindow:destroy()
|
||||
countWindow = nil
|
||||
end
|
||||
gameRootPanel:hide()
|
||||
logoutButton:hide()
|
||||
Background.show()
|
||||
|
|
|
@ -26,4 +26,3 @@ LogoutWindow < MainWindow
|
|||
anchors.left: prev.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin-left: 5
|
||||
@onClick: self:getParent():destroy()
|
||||
|
|
|
@ -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()
|
|
@ -60,8 +60,9 @@ function QuestLog.init()
|
|||
|
||||
questLogButton = TopMenu.addLeftGameButton('questLogButton', tr('Quest Log'), 'questlog.png', function() g_game.requestQuestLog() end)
|
||||
|
||||
connect(g_game, { onQuestLog = onGameQuestLog })
|
||||
connect(g_game, { onQuestLine= onGameQuestLine })
|
||||
connect(g_game, { onQuestLog = onGameQuestLog,
|
||||
onQuestLine = onGameQuestLine,
|
||||
onGameEnd = QuestLog.destroyWindows})
|
||||
end
|
||||
|
||||
function QuestLog.destroyWindows()
|
||||
|
@ -77,8 +78,9 @@ function QuestLog.destroyWindows()
|
|||
end
|
||||
|
||||
function QuestLog.terminate()
|
||||
disconnect(g_game, { onQuestLog = onGameQuestLog })
|
||||
disconnect(g_game, { onQuestLine= onGameQuestLine })
|
||||
disconnect(g_game, { onQuestLog = onGameQuestLog,
|
||||
onQuestLine = onGameQuestLine,
|
||||
onGameEnd = QuestLog.destroyWindows})
|
||||
|
||||
QuestLog.destroyWindows()
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ local MessageTypes = {
|
|||
local centerTextMessagePanel
|
||||
local bottomStatusLabel
|
||||
local privateLabel
|
||||
local deathWindow
|
||||
|
||||
-- private functions
|
||||
local function displayMessage(msgtype, msg, time)
|
||||
|
@ -58,10 +57,7 @@ end
|
|||
|
||||
-- public functions
|
||||
function TextMessage.init()
|
||||
g_ui.importStyle('deathwindow.otui')
|
||||
|
||||
connect(g_game, { onDeath = TextMessage.displayDeadMessage,
|
||||
onTextMessage = TextMessage.display,
|
||||
connect(g_game, { onTextMessage = TextMessage.display,
|
||||
onGameStart = TextMessage.clearMessages })
|
||||
|
||||
centerTextMessagePanel = g_ui.createWidget('Panel', GameInterface.getMapPanel())
|
||||
|
@ -96,7 +92,6 @@ function TextMessage.terminate()
|
|||
centerTextMessagePanel = nil
|
||||
bottomStatusLabel = nil
|
||||
privateLabel = nil
|
||||
deathWindow = nil
|
||||
TextMessage = nil
|
||||
end
|
||||
|
||||
|
@ -126,33 +121,3 @@ function TextMessage.display(msgtypedesc, msg)
|
|||
displayMessage(msgtype, msg)
|
||||
end
|
||||
end
|
||||
|
||||
function TextMessage.displayDeadMessage()
|
||||
local advanceLabel = GameInterface.getMapPanel():recursiveGetChildById('centerAdvance')
|
||||
if advanceLabel:isVisible() then return end
|
||||
TextMessage.displayEventAdvance(tr('You are dead.'))
|
||||
|
||||
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
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
TextBooks = {}
|
||||
TextWindow = {}
|
||||
|
||||
-- private variables
|
||||
local textWindow
|
||||
|
||||
-- private functions
|
||||
local function onGameEditText(id, itemId, maxLength, text, writter, time)
|
||||
local textWindow = g_ui.createWidget('TextWindow', rootWidget)
|
||||
if(textWindow) then
|
||||
return
|
||||
end
|
||||
textWindow = g_ui.createWidget('TextWindow', rootWidget)
|
||||
|
||||
local writeable = (maxLength ~= #text) and maxLength > 0
|
||||
local textItem = textWindow:getChildById('textItem')
|
||||
|
@ -41,16 +48,23 @@ local function onGameEditText(id, itemId, maxLength, text, writter, time)
|
|||
textWindow:setText(tr('Edit Text'))
|
||||
end
|
||||
|
||||
okButton.onClick = function()
|
||||
doneFunc = function()
|
||||
if writeable then
|
||||
g_game.editText(id, textEdit:getText())
|
||||
end
|
||||
textWindow:destroy()
|
||||
TextWindow.destroy()
|
||||
end
|
||||
|
||||
okButton.onClick = doneFunc
|
||||
textWindow.onEnter = doneFunc
|
||||
textWindow.onEscape = TextWindow.destroy
|
||||
end
|
||||
|
||||
local function onGameEditList(id, doorId, text)
|
||||
local textWindow = g_ui.createWidget('TextWindow', rootWidget)
|
||||
if(textWindow) then
|
||||
return
|
||||
end
|
||||
textWindow = g_ui.createWidget('TextWindow', rootWidget)
|
||||
|
||||
local textEdit = textWindow:getChildById('text')
|
||||
local description = textWindow:getChildById('description')
|
||||
|
@ -63,20 +77,36 @@ local function onGameEditList(id, doorId, text)
|
|||
description:setText(tr('Enter one name per line.'))
|
||||
textWindow:setText(tr('Edit List'))
|
||||
|
||||
okButton.onClick = function()
|
||||
doneFunc = function()
|
||||
g_game.editList(id, doorId, textEdit:getText())
|
||||
textWindow:destroy()
|
||||
end
|
||||
TextWindow.destroy()
|
||||
end
|
||||
|
||||
function TextBooks.init()
|
||||
okButton.onClick = doneFunc
|
||||
textWindow.onEnter = doneFunc
|
||||
textWindow.onEscape = TextWindow.destroy
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function TextWindow.init()
|
||||
g_ui.importStyle('textwindow.otui')
|
||||
|
||||
connect(g_game, { onEditText = onGameEditText })
|
||||
connect(g_game, { onEditList = onGameEditList })
|
||||
connect(g_game, { onEditText = onGameEditText,
|
||||
onEditList = onGameEditList,
|
||||
onGameEnd = TextWindow.destroy })
|
||||
end
|
||||
|
||||
function TextBooks.terminate()
|
||||
disconnect(g_game, { onEditText = onGameEditText })
|
||||
disconnect(g_game, { onEditList = onGameEditList })
|
||||
function TextWindow.terminate()
|
||||
disconnect(g_game, { onEditText = onGameEditText,
|
||||
onEditList = onGameEditList,
|
||||
onGameEnd = TextWindow.destroy })
|
||||
|
||||
TextWindow.destroy()
|
||||
end
|
||||
|
||||
function TextWindow.destroy()
|
||||
if(textWindow) then
|
||||
textWindow:destroy()
|
||||
textWindow = nil
|
||||
end
|
||||
end
|
|
@ -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()
|
Loading…
Reference in New Issue