Hide controls by default

This commit is contained in:
2026-07-22 23:00:45 +03:00
parent 603a674e08
commit 622830a6ee
+21 -2
View File
@@ -14,9 +14,10 @@ const _ABILITY_ICONS: Array[String] = [
]
const _ABILITY_ACTIONS: Array[StringName] = [&"ability_kick", &"ability_slam", &"ability_dash"]
var _controls_visible: bool = true
var _controls_visible: bool = false
var _controls_panel: PanelContainer
var _toggle_btn: Button
var _tab_hint: Label
var _spawner: Node
var _player: Node = null
var _cd_overlays: Array[ColorRect] = []
@@ -29,6 +30,7 @@ func _ready() -> void:
layer = 11
process_mode = Node.PROCESS_MODE_ALWAYS
_build_controls_panel()
_build_tab_hint()
_build_ability_bar()
_build_health_bar()
_find_spawner.call_deferred()
@@ -81,6 +83,7 @@ func _return_to_menu() -> void:
func _toggle_controls() -> void:
_controls_visible = not _controls_visible
_controls_panel.visible = _controls_visible
_tab_hint.visible = not _controls_visible
_toggle_btn.text = "Hide controls" if _controls_visible else "Show controls"
@@ -225,6 +228,21 @@ func _build_ability_slot(idx: int) -> Control:
return vbox
func _build_tab_hint() -> void:
_tab_hint = Label.new()
_tab_hint.text = "Press 'Tab' to see controls"
_tab_hint.anchor_left = 0.0
_tab_hint.anchor_top = 1.0
_tab_hint.anchor_right = 0.0
_tab_hint.anchor_bottom = 1.0
_tab_hint.grow_vertical = Control.GROW_DIRECTION_BEGIN
_tab_hint.offset_left = 20.0
_tab_hint.offset_bottom = -20.0
_tab_hint.add_theme_color_override("font_color", _MUTED)
_tab_hint.add_theme_font_size_override("font_size", 12)
add_child(_tab_hint)
func _build_controls_panel() -> void:
_controls_panel = PanelContainer.new()
@@ -252,6 +270,7 @@ func _build_controls_panel() -> void:
_controls_panel.grow_vertical = Control.GROW_DIRECTION_BEGIN
_controls_panel.offset_left = 20.0
_controls_panel.offset_bottom = -20.0
_controls_panel.visible = false
add_child(_controls_panel)
var vbox := VBoxContainer.new()
@@ -287,7 +306,7 @@ func _build_controls_panel() -> void:
hbox.add_theme_constant_override("separation", 8)
vbox.add_child(hbox)
_toggle_btn = _make_button("Hide controls")
_toggle_btn = _make_button("Show controls")
_toggle_btn.pressed.connect(_toggle_controls)
hbox.add_child(_toggle_btn)