62 lines
1.4 KiB
GDScript
62 lines
1.4 KiB
GDScript
extends CanvasLayer
|
|
|
|
@export var pause_sound : AudioStream
|
|
@export var resume_sound : AudioStream
|
|
@export var click_sound : AudioStream
|
|
|
|
@onready var resume_button: Button = $PanelContainer/VBoxContainer/Resume
|
|
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
|
|
|
var is_transitioning : bool = false
|
|
|
|
func _ready() -> void:
|
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
|
visible = false
|
|
animation_player.play("RESET")
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if is_transitioning: return
|
|
if event.is_action_pressed("pause"):
|
|
if get_tree().paused:
|
|
resume()
|
|
else:
|
|
pause()
|
|
|
|
func pause() -> void:
|
|
if is_transitioning: return
|
|
is_transitioning = true
|
|
|
|
visible = true
|
|
get_tree().paused = true
|
|
UiAudio.play(pause_sound)
|
|
animation_player.play("blur")
|
|
await animation_player.animation_finished
|
|
|
|
resume_button.grab_focus()
|
|
is_transitioning = false
|
|
|
|
func resume() -> void:
|
|
if is_transitioning: return
|
|
is_transitioning = true
|
|
|
|
UiAudio.play(resume_sound)
|
|
animation_player.play_backwards("blur")
|
|
await animation_player.animation_finished
|
|
|
|
visible = false
|
|
get_tree().paused = false
|
|
is_transitioning = false
|
|
|
|
func _on_resume_pressed() -> void:
|
|
resume()
|
|
|
|
func _on_restart_pressed() -> void:
|
|
UiAudio.play(click_sound)
|
|
get_tree().paused = false
|
|
visible = false
|
|
get_tree().reload_current_scene()
|
|
|
|
func _on_quit_pressed() -> void:
|
|
UiAudio.play(click_sound)
|
|
get_tree().quit()
|