SlimeoosOdyssey/godot/UI/PauseMenu.gd

41 lines
707 B
GDScript3
Raw Normal View History

2023-08-20 14:59:32 -06:00
extends Control
@onready var resume_button = $CenterContainer/HBoxContainer/ResumeButton
@onready var quit_button = $CenterContainer/HBoxContainer/QuitButton
2023-08-20 15:23:11 -06:00
func _input(event):
if Input.is_action_just_pressed("Pause"):
toggle()
func toggle():
if self.visible:
unpause()
else:
pause()
2023-08-20 14:59:32 -06:00
func unpause():
self.hide()
get_tree().paused = false
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func pause():
self.show()
2023-08-20 15:23:11 -06:00
resume_button.grab_focus()
2023-08-20 14:59:32 -06:00
get_tree().paused = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
func quit():
get_tree().quit()
2023-08-20 17:12:21 -06:00
func _on_kill_pressed():
2023-08-20 17:18:44 -06:00
Global.cheating = true
toggle()
2023-08-20 17:12:21 -06:00
func _on_restart_pressed():
toggle()
get_tree().reload_current_scene()