fix #106: pause menu can be closed via the button

This commit is contained in:
betalars 2025-03-03 15:29:52 +01:00
parent 9926e60aeb
commit b187bf241d
2 changed files with 15 additions and 11 deletions

View File

@ -9,7 +9,7 @@ class_name PauseManu extends PanelContainer
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
resume_button.pressed.connect(_process)
resume_button.pressed.connect(owner.toggle_pause_menu)
to_menu_button.pressed.connect(_process)
to_desktop_button.pressed.connect(func(): get_tree().quit())
to_settings_button.pressed.connect(_process)
@ -21,5 +21,6 @@ func _ready() -> void:
func _process(delta: float) -> void:
pass
func _on_help_pressed():
OS.shell_open("https://findahelpline.com/")

View File

@ -56,16 +56,19 @@ func _process(delta: float) -> void:
_return_to_menu()
$"Messe-Menue".show()
if Input.is_action_just_pressed("ui_menu") and in_game:
if not get_tree().paused:
get_tree().paused = true
var state_machine = menu_animation["parameters/playback"]
state_machine.travel("reveal_pause_menu")
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
get_tree().paused = false
var state_machine = menu_animation["parameters/playback"]
state_machine.travel("start_game")
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
toggle_pause_menu()
func toggle_pause_menu():
if not get_tree().paused:
get_tree().paused = true
var state_machine = menu_animation["parameters/playback"]
state_machine.travel("reveal_pause_menu")
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
get_tree().paused = false
var state_machine = menu_animation["parameters/playback"]
state_machine.travel("start_game")
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
func debug_youth():
get_child(1).hide()