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
|
2011-08-29 21:35:58 +02:00
|
|
|
elseif keyCode == KeyQ then
|
2011-08-30 01:20:30 +02:00
|
|
|
Game.logout(false)
|
2011-08-29 21:35:58 +02:00
|
|
|
return true
|
2011-08-29 16:14:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2011-11-03 10:59:11 +01:00
|
|
|
-- public functions
|
2011-11-03 21:54:53 +01:00
|
|
|
function Game.createInterface()
|
|
|
|
Background.hide()
|
|
|
|
CharacterList.destroyLoadBox()
|
2011-11-16 22:00:40 +01:00
|
|
|
Game.gameUi = UI.loadAndDisplay('/game/game.otui')
|
2011-11-11 21:26:10 +01:00
|
|
|
UI.root:moveChildToIndex(Game.gameUi, 1)
|
2011-11-03 13:17:10 +01:00
|
|
|
Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
|
|
|
|
Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
|
2011-11-03 21:54:53 +01:00
|
|
|
Game.gameBottomPanel = Game.gameUi:getChildById('bottomPanel')
|
2011-08-30 17:12:57 +02:00
|
|
|
Game.gameUi.onKeyPress = onGameKeyPress
|
2011-08-29 05:44:02 +02:00
|
|
|
end
|
|
|
|
|
2011-11-03 21:54:53 +01:00
|
|
|
function Game.destroyInterface()
|
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
|
2011-08-29 16:14:21 +02:00
|
|
|
end
|
2011-11-03 21:54:53 +01:00
|
|
|
Background.show()
|
|
|
|
CharacterList.show()
|
2011-08-29 16:14:21 +02:00
|
|
|
end
|
|
|
|
|
2011-11-03 10:59:11 +01:00
|
|
|
function Game.show()
|
|
|
|
Game.gameUi:show()
|
|
|
|
Game.gameUi:focus()
|
2011-11-03 13:17:10 +01:00
|
|
|
Game.gameMapPanel:focus()
|
2011-11-03 10:59:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function Game.hide()
|
|
|
|
Game.gameUi:hide()
|
|
|
|
end
|
|
|
|
|
|
|
|
-- hooked events
|
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-11-03 21:54:53 +01:00
|
|
|
connect(Game, { onLogin = Game.createInterface,
|
|
|
|
onLogout = Game.destroyInterface })
|