restart_notification.gd 650 B

12345678910111213141516171819202122232425262728293031323334
  1. extends Control
  2. @export var wait_time := 20.0
  3. @onready var timer_label: Label = %TimerLabel
  4. @onready var timer: Timer = %Timer
  5. @onready var restart_button: Button = %RestartButton
  6. @onready var cancel_button: Button = %CancelButton
  7. func _ready() -> void:
  8. cancel_button.pressed.connect(cancel)
  9. restart_button.pressed.connect(restart)
  10. restart_button.grab_focus()
  11. timer.timeout.connect(restart)
  12. timer.start(wait_time)
  13. func _process(delta: float) -> void:
  14. timer_label.text = "%d" % (timer.time_left -1)
  15. func cancel() -> void:
  16. timer.stop()
  17. hide()
  18. queue_free()
  19. func restart() -> void:
  20. OS.set_restart_on_exit(true)
  21. get_tree().quit()