Merge pull request #907 from diath/topbar_visibility_toggle
Add a keyboard shortcut to toggle topmenu visibility
This commit is contained in:
commit
47766685d9
|
@ -51,6 +51,8 @@ function init()
|
||||||
pingLabel = topMenu:getChildById('pingLabel')
|
pingLabel = topMenu:getChildById('pingLabel')
|
||||||
fpsLabel = topMenu:getChildById('fpsLabel')
|
fpsLabel = topMenu:getChildById('fpsLabel')
|
||||||
|
|
||||||
|
g_keyboard.bindKeyDown('Ctrl+Shift+T', toggle)
|
||||||
|
|
||||||
if g_game.isOnline() then
|
if g_game.isOnline() then
|
||||||
online()
|
online()
|
||||||
end
|
end
|
||||||
|
@ -164,3 +166,22 @@ end
|
||||||
function getTopMenu()
|
function getTopMenu()
|
||||||
return topMenu
|
return topMenu
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function toggle()
|
||||||
|
local menu = getTopMenu()
|
||||||
|
if not menu then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if menu:isVisible() then
|
||||||
|
menu:hide()
|
||||||
|
modules.client_background.getBackground():addAnchor(AnchorTop, 'parent', AnchorTop)
|
||||||
|
modules.game_interface.getRootPanel():addAnchor(AnchorTop, 'parent', AnchorTop)
|
||||||
|
modules.game_interface.getShowTopMenuButton():show()
|
||||||
|
else
|
||||||
|
menu:show()
|
||||||
|
modules.client_background.getBackground():addAnchor(AnchorTop, 'topMenu', AnchorBottom)
|
||||||
|
modules.game_interface.getRootPanel():addAnchor(AnchorTop, 'topMenu', AnchorBottom)
|
||||||
|
modules.game_interface.getShowTopMenuButton():hide()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ gameMapPanel = nil
|
||||||
gameRightPanel = nil
|
gameRightPanel = nil
|
||||||
gameLeftPanel = nil
|
gameLeftPanel = nil
|
||||||
gameBottomPanel = nil
|
gameBottomPanel = nil
|
||||||
|
showTopMenuButton = nil
|
||||||
logoutButton = nil
|
logoutButton = nil
|
||||||
mouseGrabberWidget = nil
|
mouseGrabberWidget = nil
|
||||||
countWindow = nil
|
countWindow = nil
|
||||||
|
@ -56,6 +57,11 @@ function init()
|
||||||
logoutButton = modules.client_topmenu.addLeftButton('logoutButton', tr('Exit'),
|
logoutButton = modules.client_topmenu.addLeftButton('logoutButton', tr('Exit'),
|
||||||
'/images/topbuttons/logout', tryLogout, true)
|
'/images/topbuttons/logout', tryLogout, true)
|
||||||
|
|
||||||
|
showTopMenuButton = gameMapPanel:getChildById('showTopMenuButton')
|
||||||
|
showTopMenuButton.onClick = function()
|
||||||
|
modules.client_topmenu.toggle()
|
||||||
|
end
|
||||||
|
|
||||||
setupViewMode(0)
|
setupViewMode(0)
|
||||||
|
|
||||||
bindKeys()
|
bindKeys()
|
||||||
|
@ -815,6 +821,10 @@ function getBottomPanel()
|
||||||
return gameBottomPanel
|
return gameBottomPanel
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function getShowTopMenuButton()
|
||||||
|
return showTopMenuButton
|
||||||
|
end
|
||||||
|
|
||||||
function onLeftPanelVisibilityChange(leftPanel, visible)
|
function onLeftPanelVisibilityChange(leftPanel, visible)
|
||||||
if not visible and g_game.isOnline() then
|
if not visible and g_game.isOnline() then
|
||||||
local children = leftPanel:getChildren()
|
local children = leftPanel:getChildren()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
GameSidePanel < UIMiniWindowContainer
|
GameSidePanel < UIMiniWindowContainer
|
||||||
image-source: /images/ui/panel_side
|
image-source: /images/ui/panel_side
|
||||||
image-border: 4
|
image-border: 4
|
||||||
|
@ -33,6 +32,14 @@ UIWidget
|
||||||
anchors.bottom: gameBottomPanel.top
|
anchors.bottom: gameBottomPanel.top
|
||||||
focusable: false
|
focusable: false
|
||||||
|
|
||||||
|
Button
|
||||||
|
id: showTopMenuButton
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.left: parent.left
|
||||||
|
!text: tr('Show Top Menu')
|
||||||
|
height: 32
|
||||||
|
visible: false
|
||||||
|
|
||||||
GameBottomPanel
|
GameBottomPanel
|
||||||
id: gameBottomPanel
|
id: gameBottomPanel
|
||||||
anchors.left: gameLeftPanel.right
|
anchors.left: gameLeftPanel.right
|
||||||
|
@ -73,4 +80,4 @@ UIWidget
|
||||||
UIWidget
|
UIWidget
|
||||||
id: mouseGrabber
|
id: mouseGrabber
|
||||||
focusable: false
|
focusable: false
|
||||||
visible: false
|
visible: false
|
||||||
|
|
Loading…
Reference in New Issue