Update pause menu
This commit is contained in:
parent
43bd8cb8fc
commit
fc1f024fdd
|
|
@ -1,35 +1,61 @@
|
||||||
extends CanvasLayer
|
extends CanvasLayer
|
||||||
|
|
||||||
func _ready() -> void:
|
@export var pause_sound : AudioStream
|
||||||
$".".visible = false
|
@export var resume_sound : AudioStream
|
||||||
$AnimationPlayer.play("RESET")
|
@export var click_sound : AudioStream
|
||||||
|
|
||||||
func resume() -> void:
|
@onready var resume_button: Button = $PanelContainer/VBoxContainer/Resume
|
||||||
$".".visible = false
|
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||||
get_tree().paused = false
|
|
||||||
$AnimationPlayer.play_backwards("blur")
|
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:
|
func pause() -> void:
|
||||||
$".".visible = true
|
if is_transitioning: return
|
||||||
get_tree().paused = true
|
is_transitioning = true
|
||||||
$AnimationPlayer.play("blur")
|
|
||||||
$PanelContainer/VBoxContainer/Resume.grab_focus.call_deferred()
|
|
||||||
|
|
||||||
func testEsc() -> void:
|
visible = true
|
||||||
if Input.is_action_just_pressed("pause") and !get_tree().paused:
|
get_tree().paused = true
|
||||||
pause()
|
UiAudio.play(pause_sound)
|
||||||
elif Input.is_action_just_pressed("pause") and get_tree().paused:
|
animation_player.play("blur")
|
||||||
resume()
|
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:
|
func _on_resume_pressed() -> void:
|
||||||
resume()
|
resume()
|
||||||
|
|
||||||
func _on_restart_pressed() -> void:
|
func _on_restart_pressed() -> void:
|
||||||
resume()
|
UiAudio.play(click_sound)
|
||||||
|
get_tree().paused = false
|
||||||
|
visible = false
|
||||||
get_tree().reload_current_scene()
|
get_tree().reload_current_scene()
|
||||||
|
|
||||||
func _on_quit_pressed() -> void:
|
func _on_quit_pressed() -> void:
|
||||||
|
UiAudio.play(click_sound)
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
|
||||||
testEsc()
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue