68 lines
1.5 KiB
GDScript
68 lines
1.5 KiB
GDScript
tool
|
|
extends VBoxContainer
|
|
|
|
class_name Infobox
|
|
|
|
signal infobox_changed(new_json_structure)
|
|
signal infobox_removed()
|
|
|
|
onready var _TextEdit: TextEdit = self.get_node("HBoxContainer/VBoxContainer/TextEdit")
|
|
onready var _CreateButton: Button = self.get_node("CreateButton")
|
|
onready var _HBoxContainer: HBoxContainer = self.get_node("HBoxContainer")
|
|
onready var _ConditionsList: ConditionsList = self.get_node("HBoxContainer/VBoxContainer/ConditionsList")
|
|
|
|
var _json_structure = {
|
|
"text": "",
|
|
"conditions": []
|
|
}
|
|
|
|
#Virtual Methods
|
|
|
|
func _ready():
|
|
_CreateButton.show()
|
|
_HBoxContainer.hide()
|
|
|
|
|
|
#Callback Methods
|
|
|
|
func _on_RemoveInfoboxButton_pressed():
|
|
_disable_infobox()
|
|
emit_signal("infobox_removed")
|
|
|
|
func _on_ConditionsList_conditions_changed(new_json_structure):
|
|
_json_structure.conditions = new_json_structure
|
|
_emit_changed_signal()
|
|
|
|
func _on_TextEdit_text_changed():
|
|
_json_structure.text = self._TextEdit.get_text()
|
|
_emit_changed_signal()
|
|
|
|
|
|
func _on_CreateButton_pressed():
|
|
_enable_infobox()
|
|
_emit_changed_signal()
|
|
|
|
#Public Methods
|
|
|
|
func set_structure(new_json_structure):
|
|
_json_structure = new_json_structure
|
|
_TextEdit.set_text(_json_structure.text)
|
|
_ConditionsList.set_structure(_json_structure.conditions)
|
|
_enable_infobox()
|
|
|
|
#Private Methods
|
|
|
|
func _enable_infobox():
|
|
_CreateButton.hide()
|
|
_HBoxContainer.show()
|
|
|
|
|
|
func _disable_infobox():
|
|
_CreateButton.show()
|
|
_HBoxContainer.hide()
|
|
|
|
|
|
func _emit_changed_signal():
|
|
emit_signal("infobox_changed", _json_structure)
|
|
|
|
|