restore terminal, rework console

This commit is contained in:
Eduardo Bart
2012-01-07 15:36:58 -02:00
parent a3721b3a11
commit c4b2dd18d6
25 changed files with 265 additions and 143 deletions

View File

@@ -2,17 +2,74 @@ TopMenu = {}
-- private variables
local topMenu
local leftButtonsPanel
local rightButtonsPanel
-- public functions
function TopMenu.create()
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
)
end
function TopMenu.destroy()
function TopMenu.terminate()
leftButtonsPanel = nil
rightButtonsPanel = nil
topMenu:destroy()
topMenu = nil
end
function TopMenu.getButton(id)
return topMenu:getChildById(id)
function TopMenu.addButton(id, description, icon, callback, right)
local panel
local class
if right then
panel = rightButtonsPanel
class = 'TopRightButton'
else
panel = leftButtonsPanel
class = 'TopLeftButton'
end
local button = createWidget(class, panel)
button:setId(id)
button:setTooltip(description)
button:setIcon(resolvepath(icon, 2))
button.onClick = callback
return button
end
function TopMenu.addLeftButton(id, description, icon, callback)
return TopMenu.addButton(id, description, icon, callback, false)
end
function TopMenu.addRightButton(id, description, icon, callback)
return TopMenu.addButton(id, description, icon, callback, true)
end
function TopMenu.removeButton(param)
local button
if type(param) == 'string' then
button = TopMenu.getButton(param)
else
button = param
end
button:destroy()
end
function TopMenu.getButton(id)
return topMenu:recursiveGetChildById(id)
end
function TopMenu:getLogoutButton(id)
return TopMenu.getButton('logoutButton')
end