interface.gd 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. extends Control
  2. var dialogue_node = null
  3. func _ready():
  4. hide()
  5. func show_dialogue(player, dialogue):
  6. show()
  7. $Button.grab_focus()
  8. dialogue_node = dialogue
  9. for c in dialogue.get_signal_connection_list("dialogue_started"):
  10. if player == c.callable.get_object():
  11. dialogue_node.start_dialogue()
  12. $Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
  13. $Text.text = dialogue_node.dialogue_text
  14. return
  15. dialogue_node.connect("dialogue_started", Callable(player, "set_active").bind(false))
  16. dialogue_node.connect("dialogue_finished", Callable(player, "set_active").bind(true))
  17. dialogue_node.connect("dialogue_finished", Callable(self, "hide"))
  18. dialogue_node.connect("dialogue_finished", Callable(self, "_on_dialogue_finished").bind(player))
  19. dialogue_node.start_dialogue()
  20. $Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
  21. $Text.text = dialogue_node.dialogue_text
  22. func _on_Button_button_up():
  23. dialogue_node.next_dialogue()
  24. $Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
  25. $Text.text = dialogue_node.dialogue_text
  26. func _on_dialogue_finished(player):
  27. dialogue_node.disconnect("dialogue_started", Callable(player, "set_active"))
  28. dialogue_node.disconnect("dialogue_finished", Callable(player, "set_active"))
  29. dialogue_node.disconnect("dialogue_finished", Callable(self, "hide"))
  30. dialogue_node.disconnect("dialogue_finished", Callable(self, "_on_dialogue_finished"))