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

42 lines
1 KiB
GDScript3
Raw Normal View History

2023-04-15 11:30:52 +00:00
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()
2023-04-16 07:18:42 +00:00
settings_scene_instance.on_back = Callable(func(): default_focus.grab_focus())
2023-04-15 11:30:52 +00:00
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