No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Infobox.gd 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. tool
  2. extends VBoxContainer
  3. class_name Infobox
  4. signal infobox_changed(new_json_structure)
  5. signal infobox_removed()
  6. onready var _TextEdit: TextEdit = self.get_node("HBoxContainer/VBoxContainer/TextEdit")
  7. onready var _CreateButton: Button = self.get_node("CreateButton")
  8. onready var _HBoxContainer: HBoxContainer = self.get_node("HBoxContainer")
  9. onready var _ConditionsList: ConditionsList = self.get_node("HBoxContainer/VBoxContainer/ConditionsList")
  10. var _json_structure = {
  11. "text": "",
  12. "conditions": []
  13. }
  14. #Virtual Methods
  15. func _ready():
  16. _CreateButton.show()
  17. _HBoxContainer.hide()
  18. #Callback Methods
  19. func _on_RemoveInfoboxButton_pressed():
  20. _disable_infobox()
  21. emit_signal("infobox_removed")
  22. func _on_ConditionsList_conditions_changed(new_json_structure):
  23. _json_structure.conditions = new_json_structure
  24. _emit_changed_signal()
  25. func _on_TextEdit_text_changed():
  26. _json_structure.text = self._TextEdit.get_text()
  27. _emit_changed_signal()
  28. func _on_CreateButton_pressed():
  29. _enable_infobox()
  30. _emit_changed_signal()
  31. #Public Methods
  32. func set_structure(new_json_structure):
  33. _json_structure = new_json_structure
  34. _TextEdit.set_text(_json_structure.text)
  35. _ConditionsList.set_structure(_json_structure.conditions)
  36. _enable_infobox()
  37. #Private Methods
  38. func _enable_infobox():
  39. _CreateButton.hide()
  40. _HBoxContainer.show()
  41. func _disable_infobox():
  42. _CreateButton.show()
  43. _HBoxContainer.hide()
  44. func _emit_changed_signal():
  45. emit_signal("infobox_changed", _json_structure)