tibia-client/modules/game/game.lua

52 lines
1.1 KiB
Lua
Raw Normal View History

-- 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
local function createMainInterface()
2011-08-29 05:04:23 +02:00
gameUi = loadUI('/game/ui/gameinterface.otui', UI.root)
gameUi.onKeyPress = onGameKeyPress
2011-08-29 05:44:02 +02:00
end
local function destroyMainInterface()
if gameUi then
gameUi:destroy()
gameUi = nil
end
end
2011-08-29 20:38:01 +02:00
-- public functions
function Game.onLogin()
MainMenu.hide()
CharacterList.destroyLoadBox()
createMainInterface()
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()
MainMenu.show()
2011-08-30 01:20:30 +02:00
CharacterList.show()
destroyMainInterface()
2011-08-29 05:44:02 +02:00
end