12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- tool
- extends VBoxContainer
-
- class_name Choice
-
- signal choice_changed(index, new_json_structure)
- signal choice_removed(index)
-
- onready var _ChoiceTitleLineEdit: LineEdit = self.get_node("HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/ChoiceTitleLineEdit")
- onready var _ChoiceLabel: Label = self.get_node("HBoxContainer/MarginContainer/VBoxContainer/ChoiceLabel")
- onready var _Infobox: Infobox = self.get_node("HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/Infobox")
- onready var _ConditionsList: ConditionsList = self.get_node("HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MarginContainer/ConditionsList")
-
- var _id : int = 0;
-
- var _json_structure := {
- "title": "",
- "conditions": []
- }
-
- #Callback Methods
-
- func _on_ChoiceTitleLineEdit_text_changed(new_text):
- _json_structure.title = new_text
- _emit_changed_signal()
-
-
- func _on_ChoiceRemoveButton_pressed():
- emit_signal("choice_removed", _id)
-
-
- func _on_ConditionsList_conditions_changed(new_json_structure):
- _json_structure.conditions = new_json_structure
- _emit_changed_signal()
-
-
- func _on_Infobox_infobox_removed():
- _json_structure.erase("infobox")
- _emit_changed_signal()
-
-
- func _on_Infobox_infobox_changed(new_json_structure):
- _json_structure.infobox = new_json_structure
- _emit_changed_signal()
-
-
- #Public Methods
-
- func set_structure(new_json_structure):
- _json_structure = new_json_structure
- _ChoiceTitleLineEdit.set_text(_json_structure.title)
- if ("infobox" in _json_structure):
- _Infobox.set_structure(_json_structure.infobox)
- _ConditionsList.set_structure(_json_structure.conditions)
-
-
- func set_id(new_id):
- self._id = new_id;
- _ChoiceLabel.set_text("Choice #" + str(new_id + 1))
-
- #Private Methods
-
- func _emit_changed_signal():
- emit_signal("choice_changed", _id, _json_structure)
|