Remove exit module, logout no longer at miniwindow side, always visible

This commit is contained in:
Henrique Santiago 2013-01-18 05:53:41 +00:00
parent 1500c1d2f2
commit ddaff8a46a
8 changed files with 28 additions and 104 deletions

View File

@ -19,6 +19,5 @@ Module
- client_options
- client_terminal
- client_modulemanager
- client_exit
//- client_stats

View File

@ -1,65 +0,0 @@
Exit = {}
local exitWindow
local exitButton
function Exit.init()
exitButton = TopMenu.addRightButton('exitButton', tr('Exit Client'), 'exit.png', Exit.tryExit)
if g_game.isOnline() then
exitButton:hide()
else
exitButton:show()
end
connect(g_game, {
onGameStart = Exit.hide,
onGameEnd = Exit.show
})
end
function Exit.terminate()
disconnect(g_game, {
onGameStart = Exit.hide,
onGameEnd = Exit.show
})
if exitWindow then
exitWindow:destroy()
exitWindow = nil
end
if exitButton then
exitButton:destroy()
exitButton = nil
end
Exit = nil
end
function Exit.hide()
if exitWindow then
exitWindow:destroy()
end
exitButton:hide()
end
function Exit.show()
exitButton:show()
end
function Exit.tryExit()
if exitWindow then
return true
end
local yesFunc = function() scheduleEvent(exit, 10) end
local noFunc = function() exitWindow:destroy() exitWindow = nil end
exitWindow = displayGeneralBox('Exit', tr("Do you really want to exit?"),
{ { text='Yes', callback=yesFunc },
{ text='No', callback=noFunc },
anchor=AnchorHorizontalCenter }, yesFunc, noFunc)
return true
end

View File

@ -1,16 +0,0 @@
Module
name: client_exit
description: Handles the exit exit of the client (for cases of fullscreen)
author: BeniS
website: www.otclient.info
dependencies:
- client_topmenu
- client_entergame
@onLoad: |
dofile 'exit'
Exit.init()
@onUnload: |
Exit.terminate()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 B

After

Width:  |  Height:  |  Size: 381 B

View File

@ -8,7 +8,7 @@ local leftGameButtonsPanel
local rightGameButtonsPanel
-- private functions
local function addButton(id, description, icon, callback, panel, toggle)
local function addButton(id, description, icon, callback, panel, toggle, front)
local class
if toggle then
class = 'TopToggleButton'
@ -16,7 +16,12 @@ local function addButton(id, description, icon, callback, panel, toggle)
class = 'TopButton'
end
local button = g_ui.createWidget(class, panel)
local button = g_ui.createWidget(class)
if front then
panel:insertChild(1, button)
else
panel:addChild(button)
end
button:setId(id)
button:setTooltip(description)
button:setIcon(resolvepath(icon, 3))
@ -57,36 +62,36 @@ function TopMenu.terminate()
TopMenu = nil
end
function TopMenu.addLeftButton(id, description, icon, callback)
return addButton(id, description, icon, callback, leftButtonsPanel, false)
function TopMenu.addLeftButton(id, description, icon, callback, front)
return addButton(id, description, icon, callback, leftButtonsPanel, false, front)
end
function TopMenu.addLeftToggleButton(id, description, icon, callback, right)
return addButton(id, description, icon, callback, leftButtonsPanel, true)
function TopMenu.addLeftToggleButton(id, description, icon, callback, front)
return addButton(id, description, icon, callback, leftButtonsPanel, true, front)
end
function TopMenu.addRightButton(id, description, icon, callback)
return addButton(id, description, icon, callback, rightButtonsPanel, false)
function TopMenu.addRightButton(id, description, icon, callback, front)
return addButton(id, description, icon, callback, rightButtonsPanel, false, front)
end
function TopMenu.addRightToggleButton(id, description, icon, callback, right)
return addButton(id, description, icon, callback, rightButtonsPanel, true)
function TopMenu.addRightToggleButton(id, description, icon, callback, front)
return addButton(id, description, icon, callback, rightButtonsPanel, true, front)
end
function TopMenu.addLeftGameButton(id, description, icon, callback)
return addButton(id, description, icon, callback, leftGameButtonsPanel, false)
function TopMenu.addLeftGameButton(id, description, icon, callback, front)
return addButton(id, description, icon, callback, leftGameButtonsPanel, false, front)
end
function TopMenu.addLeftGameToggleButton(id, description, icon, callback, right)
return addButton(id, description, icon, callback, leftGameButtonsPanel, true)
function TopMenu.addLeftGameToggleButton(id, description, icon, callback, front)
return addButton(id, description, icon, callback, leftGameButtonsPanel, true, front)
end
function TopMenu.addRightGameButton(id, description, icon, callback)
return addButton(id, description, icon, callback, rightGameButtonsPanel, false)
function TopMenu.addRightGameButton(id, description, icon, callback, front)
return addButton(id, description, icon, callback, rightGameButtonsPanel, false, front)
end
function TopMenu.addRightGameToggleButton(id, description, icon, callback, right)
return addButton(id, description, icon, callback, rightGameButtonsPanel, true)
function TopMenu.addRightGameToggleButton(id, description, icon, callback, front)
return addButton(id, description, icon, callback, rightGameButtonsPanel, true, front)
end
function TopMenu.hideGameButtons()

View File

@ -49,8 +49,7 @@ function init()
gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
connect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })
logoutButton = TopMenu.addRightButton('logoutButton', 'Logout', '/images/logout.png', tryLogout)
logoutButton:hide()
logoutButton = TopMenu.addLeftButton('logoutButton', 'Logout', '/images/logout.png', tryLogout, true)
bindKeys()
@ -124,7 +123,6 @@ end
function show()
connect(g_app, { onClose = tryExit })
logoutButton:show()
Background.hide()
gameRootPanel:show()
gameRootPanel:focus()
@ -147,7 +145,6 @@ function hide()
countWindow = nil
end
gameRootPanel:hide()
logoutButton:hide()
Background.show()
end
@ -186,6 +183,10 @@ function logout()
end
function tryLogout()
if not g_game.isOnline() then
exit()
end
if logoutWindow then
return
end