Remove exit module, logout no longer at miniwindow side, always visible
This commit is contained in:
parent
1500c1d2f2
commit
ddaff8a46a
|
@ -19,6 +19,5 @@ Module
|
||||||
- client_options
|
- client_options
|
||||||
- client_terminal
|
- client_terminal
|
||||||
- client_modulemanager
|
- client_modulemanager
|
||||||
- client_exit
|
|
||||||
//- client_stats
|
//- client_stats
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
|
@ -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 |
|
@ -8,7 +8,7 @@ local leftGameButtonsPanel
|
||||||
local rightGameButtonsPanel
|
local rightGameButtonsPanel
|
||||||
|
|
||||||
-- private functions
|
-- private functions
|
||||||
local function addButton(id, description, icon, callback, panel, toggle)
|
local function addButton(id, description, icon, callback, panel, toggle, front)
|
||||||
local class
|
local class
|
||||||
if toggle then
|
if toggle then
|
||||||
class = 'TopToggleButton'
|
class = 'TopToggleButton'
|
||||||
|
@ -16,7 +16,12 @@ local function addButton(id, description, icon, callback, panel, toggle)
|
||||||
class = 'TopButton'
|
class = 'TopButton'
|
||||||
end
|
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:setId(id)
|
||||||
button:setTooltip(description)
|
button:setTooltip(description)
|
||||||
button:setIcon(resolvepath(icon, 3))
|
button:setIcon(resolvepath(icon, 3))
|
||||||
|
@ -57,36 +62,36 @@ function TopMenu.terminate()
|
||||||
TopMenu = nil
|
TopMenu = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.addLeftButton(id, description, icon, callback)
|
function TopMenu.addLeftButton(id, description, icon, callback, front)
|
||||||
return addButton(id, description, icon, callback, leftButtonsPanel, false)
|
return addButton(id, description, icon, callback, leftButtonsPanel, false, front)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.addLeftToggleButton(id, description, icon, callback, right)
|
function TopMenu.addLeftToggleButton(id, description, icon, callback, front)
|
||||||
return addButton(id, description, icon, callback, leftButtonsPanel, true)
|
return addButton(id, description, icon, callback, leftButtonsPanel, true, front)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.addRightButton(id, description, icon, callback)
|
function TopMenu.addRightButton(id, description, icon, callback, front)
|
||||||
return addButton(id, description, icon, callback, rightButtonsPanel, false)
|
return addButton(id, description, icon, callback, rightButtonsPanel, false, front)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.addRightToggleButton(id, description, icon, callback, right)
|
function TopMenu.addRightToggleButton(id, description, icon, callback, front)
|
||||||
return addButton(id, description, icon, callback, rightButtonsPanel, true)
|
return addButton(id, description, icon, callback, rightButtonsPanel, true, front)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.addLeftGameButton(id, description, icon, callback)
|
function TopMenu.addLeftGameButton(id, description, icon, callback, front)
|
||||||
return addButton(id, description, icon, callback, leftGameButtonsPanel, false)
|
return addButton(id, description, icon, callback, leftGameButtonsPanel, false, front)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.addLeftGameToggleButton(id, description, icon, callback, right)
|
function TopMenu.addLeftGameToggleButton(id, description, icon, callback, front)
|
||||||
return addButton(id, description, icon, callback, leftGameButtonsPanel, true)
|
return addButton(id, description, icon, callback, leftGameButtonsPanel, true, front)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.addRightGameButton(id, description, icon, callback)
|
function TopMenu.addRightGameButton(id, description, icon, callback, front)
|
||||||
return addButton(id, description, icon, callback, rightGameButtonsPanel, false)
|
return addButton(id, description, icon, callback, rightGameButtonsPanel, false, front)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.addRightGameToggleButton(id, description, icon, callback, right)
|
function TopMenu.addRightGameToggleButton(id, description, icon, callback, front)
|
||||||
return addButton(id, description, icon, callback, rightGameButtonsPanel, true)
|
return addButton(id, description, icon, callback, rightGameButtonsPanel, true, front)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.hideGameButtons()
|
function TopMenu.hideGameButtons()
|
||||||
|
|
|
@ -49,8 +49,7 @@ function init()
|
||||||
gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
|
gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
|
||||||
connect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })
|
connect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })
|
||||||
|
|
||||||
logoutButton = TopMenu.addRightButton('logoutButton', 'Logout', '/images/logout.png', tryLogout)
|
logoutButton = TopMenu.addLeftButton('logoutButton', 'Logout', '/images/logout.png', tryLogout, true)
|
||||||
logoutButton:hide()
|
|
||||||
|
|
||||||
bindKeys()
|
bindKeys()
|
||||||
|
|
||||||
|
@ -124,7 +123,6 @@ end
|
||||||
|
|
||||||
function show()
|
function show()
|
||||||
connect(g_app, { onClose = tryExit })
|
connect(g_app, { onClose = tryExit })
|
||||||
logoutButton:show()
|
|
||||||
Background.hide()
|
Background.hide()
|
||||||
gameRootPanel:show()
|
gameRootPanel:show()
|
||||||
gameRootPanel:focus()
|
gameRootPanel:focus()
|
||||||
|
@ -147,7 +145,6 @@ function hide()
|
||||||
countWindow = nil
|
countWindow = nil
|
||||||
end
|
end
|
||||||
gameRootPanel:hide()
|
gameRootPanel:hide()
|
||||||
logoutButton:hide()
|
|
||||||
Background.show()
|
Background.show()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -186,6 +183,10 @@ function logout()
|
||||||
end
|
end
|
||||||
|
|
||||||
function tryLogout()
|
function tryLogout()
|
||||||
|
if not g_game.isOnline() then
|
||||||
|
exit()
|
||||||
|
end
|
||||||
|
|
||||||
if logoutWindow then
|
if logoutWindow then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue