tibia-client/modules/game/game.lua

67 lines
1.4 KiB
Lua
Raw Normal View History

2011-08-30 17:12:57 +02:00
require 'textmessage'
-- private functions
local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
if keyboardModifiers == KeyboardCtrlModifier then
if keyCode == KeyG then
CharacterList.show()
return true
elseif keyCode == KeyQ then
2011-08-30 01:20:30 +02:00
Game.logout(false)
return true
end
end
return false
end
-- public functions
function Game.create()
2011-08-30 17:12:57 +02:00
Game.gameUi = loadUI('/game/ui/gameinterface.otui', UI.root)
Game.gameMapUi = Game.gameUi:getChildById('gameMap')
Game.gameUi.onKeyPress = onGameKeyPress
2011-11-02 04:02:56 +01:00
TextMessage.create()
2011-08-29 05:44:02 +02:00
end
function Game.destroy()
2011-08-31 01:39:14 +02:00
if Game.gameUi then
2011-08-30 17:12:57 +02:00
Game.gameUi:destroy()
Game.gameUi = nil
end
end
function Game.show()
Game.gameUi:show()
Game.gameUi:focus()
Game.gameMapUi:focus()
end
function Game.hide()
Game.gameUi:hide()
end
-- hooked events
function Game.onLogin()
2011-11-02 04:02:56 +01:00
Background.hide()
CharacterList.destroyLoadBox()
Game.show()
2011-08-29 05:44:02 +02:00
end
2011-08-30 01:20:30 +02:00
function Game.onLoginError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Login error: " .. message)
errorBox.onOk = CharacterList.show
end
2011-08-29 20:38:01 +02:00
function Game.onConnectionError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
errorBox.onOk = CharacterList.show
end
2011-08-29 05:44:02 +02:00
function Game.onLogout()
Game.hide()
2011-11-02 04:02:56 +01:00
Background.show()
2011-08-30 01:20:30 +02:00
CharacterList.show()
2011-08-29 05:44:02 +02:00
end