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.

Choice.gd 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. tool
  2. extends VBoxContainer
  3. class_name Choice
  4. signal choice_changed(index, new_json_structure)
  5. signal choice_removed(index)
  6. onready var _ChoiceTitleLineEdit: LineEdit = self.get_node("HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/ChoiceTitleLineEdit")
  7. onready var _ChoiceLabel: Label = self.get_node("HBoxContainer/MarginContainer/VBoxContainer/ChoiceLabel")
  8. onready var _Infobox: Infobox = self.get_node("HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/Infobox")
  9. onready var _ConditionsList: ConditionsList = self.get_node("HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MarginContainer/ConditionsList")
  10. var _id : int = 0;
  11. var _json_structure := {
  12. "title": "",
  13. "conditions": []
  14. }
  15. #Callback Methods
  16. func _on_ChoiceTitleLineEdit_text_changed(new_text):
  17. _json_structure.title = new_text
  18. _emit_changed_signal()
  19. func _on_ChoiceRemoveButton_pressed():
  20. emit_signal("choice_removed", _id)
  21. func _on_ConditionsList_conditions_changed(new_json_structure):
  22. _json_structure.conditions = new_json_structure
  23. _emit_changed_signal()
  24. func _on_Infobox_infobox_removed():
  25. _json_structure.erase("infobox")
  26. _emit_changed_signal()
  27. func _on_Infobox_infobox_changed(new_json_structure):
  28. _json_structure.infobox = new_json_structure
  29. _emit_changed_signal()
  30. #Public Methods
  31. func set_structure(new_json_structure):
  32. _json_structure = new_json_structure
  33. _ChoiceTitleLineEdit.set_text(_json_structure.title)
  34. if ("infobox" in _json_structure):
  35. _Infobox.set_structure(_json_structure.infobox)
  36. _ConditionsList.set_structure(_json_structure.conditions)
  37. func set_id(new_id):
  38. self._id = new_id;
  39. _ChoiceLabel.set_text("Choice #" + str(new_id + 1))
  40. #Private Methods
  41. func _emit_changed_signal():
  42. emit_signal("choice_changed", _id, _json_structure)