prompt_container.gd 577 B

12345678910111213141516171819202122232425262728
  1. class_name PromptContainer
  2. extends Control
  3. ## Free itself when every prompt has been used
  4. var _nb_prompts: int
  5. func _ready() -> void:
  6. _nb_prompts = 0
  7. for child in get_children():
  8. if child is InputPrompt:
  9. child.pressed.connect(child.queue_free)
  10. child.tree_exited.connect(_on_child_exited_tree)
  11. _nb_prompts += 1
  12. func remove_if_no_more_prompt():
  13. _nb_prompts -= 1
  14. print(_nb_prompts, " remaining prompts")
  15. if _nb_prompts <= 0:
  16. # Only label remaining
  17. print("Destruction !")
  18. queue_free()
  19. func _on_child_exited_tree() -> void:
  20. remove_if_no_more_prompt()