Browse Source

Add a keyboard shortcut to toggle topmenu visibility

Kamil Chojnowski 3 years ago
parent
commit
483988f814
2 changed files with 20 additions and 2 deletions
  1. 19
    0
      modules/client_topmenu/topmenu.lua
  2. 1
    2
      modules/game_interface/gameinterface.otui

+ 19
- 0
modules/client_topmenu/topmenu.lua View File

@@ -51,6 +51,8 @@ function init()
51 51
   pingLabel = topMenu:getChildById('pingLabel')
52 52
   fpsLabel = topMenu:getChildById('fpsLabel')
53 53
 
54
+  g_keyboard.bindKeyDown('Ctrl+Shift+T', toggle)
55
+
54 56
   if g_game.isOnline() then
55 57
     online()
56 58
   end
@@ -164,3 +166,20 @@ end
164 166
 function getTopMenu()
165 167
   return topMenu
166 168
 end
169
+
170
+function toggle()
171
+  local menu = getTopMenu()
172
+  if not menu then
173
+    return
174
+  end
175
+
176
+  if menu:isVisible() then
177
+    menu:hide()
178
+    modules.client_background.getBackground():addAnchor(AnchorTop, 'parent', AnchorTop)
179
+    modules.game_interface.getRootPanel():addAnchor(AnchorTop, 'parent', AnchorTop)
180
+  else
181
+    menu:show()
182
+    modules.client_background.getBackground():addAnchor(AnchorTop, 'topMenu', AnchorBottom)
183
+    modules.game_interface.getRootPanel():addAnchor(AnchorTop, 'topMenu', AnchorBottom)
184
+  end
185
+end

+ 1
- 2
modules/game_interface/gameinterface.otui View File

@@ -1,4 +1,3 @@
1
-
2 1
 GameSidePanel < UIMiniWindowContainer
3 2
   image-source: /images/ui/panel_side
4 3
   image-border: 4
@@ -73,4 +72,4 @@ UIWidget
73 72
   UIWidget
74 73
     id: mouseGrabber
75 74
     focusable: false
76
-    visible: false
75
+    visible: false

Loading…
Cancel
Save