2011-08-29 20:38:01 +02:00
|
|
|
-- private variables
|
|
|
|
local showCharacterListOnLogout = true
|
|
|
|
|
2011-08-29 16:14:21 +02:00
|
|
|
-- private functions
|
|
|
|
local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
|
|
|
|
if keyboardModifiers == KeyboardCtrlModifier then
|
|
|
|
if keyCode == KeyG then
|
|
|
|
CharacterList.show()
|
|
|
|
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)
|
2011-08-29 16:14:21 +02:00
|
|
|
gameUi.onKeyPress = onGameKeyPress
|
2011-08-29 05:44:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2011-08-29 16:14:21 +02:00
|
|
|
local function destroyMainInterface()
|
|
|
|
if gameUi then
|
|
|
|
gameUi:destroy()
|
|
|
|
gameUi = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-08-29 20:38:01 +02:00
|
|
|
-- public functions
|
2011-08-29 16:14:21 +02:00
|
|
|
function Game.onLogin()
|
|
|
|
MainMenu.hide()
|
|
|
|
CharacterList.destroyLoadBox()
|
|
|
|
createMainInterface()
|
2011-08-29 05:44:02 +02:00
|
|
|
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
|
|
|
|
showCharacterListOnLogout = false
|
|
|
|
end
|
|
|
|
|
2011-08-29 05:44:02 +02:00
|
|
|
function Game.onLogout()
|
2011-08-29 16:14:21 +02:00
|
|
|
MainMenu.show()
|
2011-08-29 20:38:01 +02:00
|
|
|
|
|
|
|
if showCharacterListOnLogout then
|
|
|
|
CharacterList.show()
|
|
|
|
else
|
|
|
|
showCharacterListOnLogout = true
|
|
|
|
end
|
|
|
|
|
2011-08-29 16:14:21 +02:00
|
|
|
destroyMainInterface()
|
2011-08-29 05:44:02 +02:00
|
|
|
end
|