This repository has been archived on 2024-07-02. You can view files and clone it, but cannot push or open issues or pull requests.
HoppyEaster/Scripts/UI/PauseMenu.gd
2023-04-17 02:25:23 +05:30

42 lines
1 KiB
GDScript

extends Control
@export var menu_scene : String = "res://Scenes/Main Menu.tscn"
@export var settings_scene : Resource
@export var default_focus : Button
func _ready():
for child in get_children():
child.visible = false
pass
func _input(event):
if (event.is_action_pressed("ui_cancel")):
if get_tree().paused: default_focus.grab_focus()
get_tree().paused = !get_tree().paused
for child in get_children():
child.visible = get_tree().paused
pass
func _on_resume_button_pressed():
get_tree().paused = false
for child in get_children():
child.visible = false
pass
func _on_settings_button_pressed():
var settings_scene_instance = load(settings_scene.resource_path).instantiate()
settings_scene_instance.on_back = Callable(func(): default_focus.grab_focus())
get_tree().current_scene.add_child(settings_scene_instance)
pass
func _on_quit_button_pressed():
get_tree().quit()
pass
func _on_main_menu_button_pressed():
get_tree().paused = false
load(menu_scene)
get_tree().change_scene_to_file(menu_scene)
pass