interface.gd 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. extends Control
  2. var dialogue_node: Node = null
  3. func _ready() -> void:
  4. visible = false
  5. func show_dialogue(player: Pawn, dialogue: Node) -> void:
  6. visible = true
  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.dialogue_started.connect(player.set_active.bind(false))
  16. dialogue_node.dialogue_finished.connect(player.set_active.bind(true))
  17. dialogue_node.dialogue_finished.connect(hide)
  18. dialogue_node.dialogue_finished.connect(_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() -> void:
  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: Pawn) -> void:
  27. dialogue_node.dialogue_started.disconnect(player.set_active)
  28. dialogue_node.dialogue_finished.disconnect(player.set_active)
  29. dialogue_node.dialogue_finished.disconnect(hide)
  30. dialogue_node.dialogue_finished.disconnect(_on_dialogue_finished)