lua hotkeys system

This commit is contained in:
Eduardo Bart
2012-01-07 18:00:07 -02:00
parent c4b2dd18d6
commit 060d8740f5
13 changed files with 320 additions and 69 deletions

View File

@@ -5,24 +5,27 @@ local topMenu
local leftButtonsPanel
local rightButtonsPanel
-- private functions
local function onLogout()
if Game.isOnline() then
Game.logout(false)
else
exit()
end
end
-- public functions
function TopMenu.init()
topMenu = displayUI('topmenu.otui')
leftButtonsPanel = topMenu:getChildById('leftButtonsPanel')
rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
TopMenu.addRightButton('logoutButton', 'Logout', '/core_styles/icons/logout.png',
function()
if Game.isOnline() then
Game.logout(false)
else
exit()
end
end
)
TopMenu.addRightButton('logoutButton', 'Logout (Ctrl+Q)', '/core_styles/icons/logout.png', onLogout)
Hotkeys.bind('Ctrl+Q', onLogout)
end
function TopMenu.terminate()
Hotkeys.unbind('Ctrl+Q')
leftButtonsPanel = nil
rightButtonsPanel = nil
topMenu:destroy()