diff --git a/modules/client/client.otmod b/modules/client/client.otmod index 539e794f..3d002798 100644 --- a/modules/client/client.otmod +++ b/modules/client/client.otmod @@ -19,6 +19,5 @@ Module - client_options - client_terminal - client_modulemanager - - client_exit //- client_stats diff --git a/modules/client_exit/exit.lua b/modules/client_exit/exit.lua deleted file mode 100644 index 2859f1bf..00000000 --- a/modules/client_exit/exit.lua +++ /dev/null @@ -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 diff --git a/modules/client_exit/exit.otmod b/modules/client_exit/exit.otmod deleted file mode 100644 index 80afc3b8..00000000 --- a/modules/client_exit/exit.otmod +++ /dev/null @@ -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() diff --git a/modules/client_exit/exit.otui b/modules/client_exit/exit.otui deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/client_exit/exit.png b/modules/client_exit/exit.png deleted file mode 100644 index 1512fab2..00000000 Binary files a/modules/client_exit/exit.png and /dev/null differ diff --git a/modules/client_skins/skins/default/images/logout.png b/modules/client_skins/skins/default/images/logout.png index 12aa0dc0..91e2354c 100644 Binary files a/modules/client_skins/skins/default/images/logout.png and b/modules/client_skins/skins/default/images/logout.png differ diff --git a/modules/client_topmenu/topmenu.lua b/modules/client_topmenu/topmenu.lua index ec616f74..1cf96bd5 100644 --- a/modules/client_topmenu/topmenu.lua +++ b/modules/client_topmenu/topmenu.lua @@ -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() diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index ccf5fa8b..860ee31f 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -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