Browse Source

Allow full control over json from node

Arnaud Vergnet 3 years ago
parent
commit
0ce0bc8986

+ 64
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/Choice/Choice.gd View File

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

+ 107
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/Choice/Choice.tscn View File

1
+[gd_scene load_steps=4 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/Choice/Choice.gd" type="Script" id=1]
4
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/ConditionsList.tscn" type="PackedScene" id=2]
5
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Infobox/Infobox.tscn" type="PackedScene" id=3]
6
+
7
+[node name="Choice" type="VBoxContainer"]
8
+margin_right = 272.0
9
+margin_bottom = 156.0
10
+script = ExtResource( 1 )
11
+__meta__ = {
12
+"_edit_use_anchors_": false
13
+}
14
+
15
+[node name="HBoxContainer" type="HBoxContainer" parent="."]
16
+margin_right = 272.0
17
+margin_bottom = 230.0
18
+
19
+[node name="MarginContainer" type="MarginContainer" parent="HBoxContainer"]
20
+margin_right = 272.0
21
+margin_bottom = 230.0
22
+size_flags_horizontal = 3
23
+custom_constants/margin_right = 5
24
+custom_constants/margin_top = 5
25
+custom_constants/margin_left = 5
26
+custom_constants/margin_bottom = 5
27
+__meta__ = {
28
+"_edit_use_anchors_": false
29
+}
30
+
31
+[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/MarginContainer"]
32
+margin_left = 5.0
33
+margin_top = 5.0
34
+margin_right = 267.0
35
+margin_bottom = 225.0
36
+size_flags_horizontal = 3
37
+__meta__ = {
38
+"_edit_use_anchors_": false
39
+}
40
+
41
+[node name="ChoiceLabel" type="Label" parent="HBoxContainer/MarginContainer/VBoxContainer"]
42
+margin_right = 262.0
43
+margin_bottom = 14.0
44
+text = "Choice #1"
45
+align = 1
46
+
47
+[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/MarginContainer/VBoxContainer"]
48
+margin_top = 18.0
49
+margin_right = 262.0
50
+margin_bottom = 220.0
51
+
52
+[node name="HBoxContainer2" type="HBoxContainer" parent="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer"]
53
+margin_right = 262.0
54
+margin_bottom = 202.0
55
+
56
+[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2"]
57
+margin_right = 238.0
58
+margin_bottom = 202.0
59
+size_flags_horizontal = 3
60
+
61
+[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
62
+margin_right = 238.0
63
+margin_bottom = 24.0
64
+size_flags_horizontal = 3
65
+
66
+[node name="ChoiceTitleLabel" type="Label" parent="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer"]
67
+margin_top = 5.0
68
+margin_right = 32.0
69
+margin_bottom = 19.0
70
+text = "Title:"
71
+
72
+[node name="ChoiceTitleLineEdit" type="LineEdit" parent="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer"]
73
+margin_left = 36.0
74
+margin_right = 238.0
75
+margin_bottom = 24.0
76
+size_flags_horizontal = 3
77
+
78
+[node name="Infobox" parent="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer" instance=ExtResource( 3 )]
79
+margin_bottom = 164.0
80
+
81
+[node name="MarginContainer" type="MarginContainer" parent="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
82
+margin_top = 168.0
83
+margin_right = 238.0
84
+margin_bottom = 202.0
85
+custom_constants/margin_right = 5
86
+custom_constants/margin_top = 5
87
+custom_constants/margin_left = 5
88
+custom_constants/margin_bottom = 5
89
+
90
+[node name="ConditionsList" parent="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MarginContainer" instance=ExtResource( 2 )]
91
+margin_bottom = 29.0
92
+
93
+[node name="ChoiceRemoveButton" type="Button" parent="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2"]
94
+margin_left = 242.0
95
+margin_right = 262.0
96
+margin_bottom = 202.0
97
+text = "X"
98
+
99
+[node name="HSeparator" type="HSeparator" parent="."]
100
+margin_top = 234.0
101
+margin_right = 272.0
102
+margin_bottom = 238.0
103
+[connection signal="text_changed" from="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/HBoxContainer/ChoiceTitleLineEdit" to="." method="_on_ChoiceTitleLineEdit_text_changed"]
104
+[connection signal="infobox_changed" from="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/Infobox" to="." method="_on_Infobox_infobox_changed"]
105
+[connection signal="infobox_removed" from="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/Infobox" to="." method="_on_Infobox_infobox_removed"]
106
+[connection signal="conditions_changed" from="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MarginContainer/ConditionsList" to="." method="_on_ConditionsList_conditions_changed"]
107
+[connection signal="pressed" from="HBoxContainer/MarginContainer/VBoxContainer/VBoxContainer/HBoxContainer2/ChoiceRemoveButton" to="." method="_on_ChoiceRemoveButton_pressed"]

+ 66
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/ChoicesList.gd View File

1
+tool
2
+extends VBoxContainer
3
+
4
+class_name ChoicesList
5
+
6
+signal choices_changed(new_json_structure)
7
+
8
+var _choice_scene = preload("res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/Choice/Choice.tscn")
9
+
10
+onready var _VBoxContainer: VBoxContainer = self.get_node("VBoxContainer")
11
+
12
+var _json_structure: Array = []
13
+var _nodes: Array = []
14
+
15
+#Callback Methods
16
+
17
+func _on_choice_changed(index, new_structure):
18
+	_json_structure[index] = new_structure
19
+	_emit_changed_signal()
20
+
21
+func _on_choice_removed(index):
22
+	_json_structure.remove(index)
23
+	_remove_choice_node(index)
24
+	_emit_changed_signal()
25
+
26
+func _on_ChoiceAddButton_pressed():
27
+	add_choice()
28
+
29
+
30
+#Public Methods
31
+
32
+func add_choice():
33
+	_json_structure.append({
34
+		"title": "",
35
+		"conditions": []
36
+	})
37
+	_add_choice_node(_json_structure.size() - 1)
38
+	_emit_changed_signal()
39
+
40
+func set_structure(new_json_structure):
41
+	_json_structure = new_json_structure
42
+	for i in range(0, _json_structure.size()):
43
+		var node: Choice = _add_choice_node(i)
44
+		node.set_structure(_json_structure[i])
45
+
46
+#Private Methods
47
+
48
+func _emit_changed_signal():
49
+	emit_signal("choices_changed", _json_structure)
50
+
51
+func _add_choice_node(id: int):
52
+	var node: Choice = _choice_scene.instance()
53
+	_VBoxContainer.add_child(node)
54
+	node.set_id(id)
55
+	_nodes.append(node)
56
+	node.connect("choice_changed", self, "_on_choice_changed")
57
+	node.connect("choice_removed", self, "_on_choice_removed")
58
+	return node
59
+
60
+func _remove_choice_node(index):
61
+	# Remove the node
62
+	_nodes[index].queue_free()
63
+	_nodes.remove(index)
64
+	# Update remaining nodes indexes
65
+	for i in range(0, _nodes.size()):
66
+		_nodes[i].set_id(i)

+ 23
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/ChoicesList.tscn View File

1
+[gd_scene load_steps=2 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/ChoicesList.gd" type="Script" id=2]
4
+
5
+[node name="ChoicesList" type="VBoxContainer"]
6
+margin_top = 242.0
7
+margin_right = 272.0
8
+margin_bottom = 422.0
9
+script = ExtResource( 2 )
10
+__meta__ = {
11
+"_edit_use_anchors_": false
12
+}
13
+
14
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
15
+margin_right = 272.0
16
+size_flags_horizontal = 3
17
+
18
+[node name="ChoiceAddButton" type="Button" parent="."]
19
+margin_top = 4.0
20
+margin_right = 272.0
21
+margin_bottom = 24.0
22
+text = "Add choice"
23
+[connection signal="pressed" from="ChoiceAddButton" to="." method="_on_ChoiceAddButton_pressed"]

+ 47
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/Condition/Condition.gd View File

1
+tool
2
+extends VBoxContainer
3
+
4
+class_name Condition
5
+
6
+signal condition_changed(index, new_json_structure)
7
+signal condition_removed(index)
8
+
9
+onready var _ConditionLabel: Label = self.get_node("ContitionLabel")
10
+onready var _ContitionNameLineEdit: LineEdit = self.get_node("HBoxContainer2/ContitionNameLineEdit")
11
+onready var _ContitionValueSpinBox: SpinBox = self.get_node("HBoxContainer2/ContitionValueSpinBox")
12
+
13
+var _id : int = 0;
14
+
15
+var _json_structure = {
16
+	"id": "",
17
+	"value": 0
18
+}
19
+
20
+#Callback Methods
21
+
22
+func _on_ContitionNameLineEdit_text_changed(new_text):
23
+	_json_structure.id = new_text
24
+	emit_signal("condition_changed", _id, _json_structure)
25
+
26
+
27
+func _on_ContitionValueSpinBox_value_changed(value):
28
+	_json_structure.value = value
29
+	emit_signal("condition_changed", _id, _json_structure)
30
+
31
+
32
+func _on_ContitionRemoveButton_pressed():
33
+	emit_signal("condition_removed", _id)
34
+
35
+#Public Methods
36
+
37
+func set_structure(new_json_structure):
38
+	_json_structure = new_json_structure
39
+	_ContitionNameLineEdit.text = _json_structure.id
40
+	_ContitionValueSpinBox.value = _json_structure.value
41
+	
42
+
43
+
44
+func set_id(new_id):
45
+	self._id = new_id;
46
+	_ConditionLabel.set_text("Condition #" + str(new_id + 1))
47
+

+ 50
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/Condition/Condition.tscn View File

1
+[gd_scene load_steps=2 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/Condition/Condition.gd" type="Script" id=1]
4
+
5
+[node name="Condition" type="VBoxContainer"]
6
+margin_right = 228.0
7
+margin_bottom = 50.0
8
+size_flags_horizontal = 3
9
+script = ExtResource( 1 )
10
+__meta__ = {
11
+"_edit_use_anchors_": false
12
+}
13
+
14
+[node name="HSeparator2" type="HSeparator" parent="."]
15
+margin_right = 228.0
16
+margin_bottom = 4.0
17
+__meta__ = {
18
+"_edit_use_anchors_": false
19
+}
20
+
21
+[node name="ContitionLabel" type="Label" parent="."]
22
+margin_top = 8.0
23
+margin_right = 228.0
24
+margin_bottom = 22.0
25
+text = "Condition #1"
26
+
27
+[node name="HBoxContainer2" type="HBoxContainer" parent="."]
28
+margin_top = 26.0
29
+margin_right = 228.0
30
+margin_bottom = 50.0
31
+size_flags_horizontal = 3
32
+
33
+[node name="ContitionNameLineEdit" type="LineEdit" parent="HBoxContainer2"]
34
+margin_right = 127.0
35
+margin_bottom = 24.0
36
+size_flags_horizontal = 3
37
+
38
+[node name="ContitionValueSpinBox" type="SpinBox" parent="HBoxContainer2"]
39
+margin_left = 131.0
40
+margin_right = 205.0
41
+margin_bottom = 24.0
42
+
43
+[node name="ContitionRemoveButton" type="Button" parent="HBoxContainer2"]
44
+margin_left = 209.0
45
+margin_right = 228.0
46
+margin_bottom = 24.0
47
+text = "x"
48
+[connection signal="text_changed" from="HBoxContainer2/ContitionNameLineEdit" to="." method="_on_ContitionNameLineEdit_text_changed"]
49
+[connection signal="value_changed" from="HBoxContainer2/ContitionValueSpinBox" to="." method="_on_ContitionValueSpinBox_value_changed"]
50
+[connection signal="pressed" from="HBoxContainer2/ContitionRemoveButton" to="." method="_on_ContitionRemoveButton_pressed"]

+ 69
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/ConditionsList.gd View File

1
+tool
2
+extends VBoxContainer
3
+
4
+class_name ConditionsList
5
+
6
+signal conditions_changed(new_json_structure)
7
+
8
+var _condition_scene = preload("res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/Condition/Condition.tscn")
9
+
10
+onready var _VBoxContainer = self.get_node("VBoxContainer")
11
+
12
+var _json_structure = []
13
+var _nodes = []
14
+
15
+#Callback Methods
16
+
17
+func _on_condition_changed(index, new_structure):
18
+	_json_structure[index] = new_structure
19
+	_emit_changed_signal()
20
+
21
+func _on_condition_removed(index):
22
+	_json_structure.remove(index)
23
+	_remove_choice_node(index)
24
+	_emit_changed_signal()
25
+
26
+func _on_ContitionAddButton_pressed():
27
+	add_condition(
28
+		{
29
+			"id": "",
30
+			"value": 0
31
+		}, 
32
+		_json_structure.size() - 1
33
+	)
34
+
35
+#Public Methods
36
+
37
+func set_structure(new_json_structure):
38
+	_json_structure = new_json_structure
39
+	for i in range(0, _json_structure.size()):
40
+		add_condition(_json_structure[0], i)
41
+
42
+
43
+func add_condition(structure: Dictionary, id: int):
44
+	_json_structure.append(structure)
45
+	_add_choice_node(structure, id)
46
+	_emit_changed_signal()
47
+
48
+#Private Methods
49
+
50
+func _emit_changed_signal():
51
+	emit_signal("conditions_changed", _json_structure)
52
+
53
+func _add_choice_node(structure: Dictionary, id: int):
54
+	var node: Condition = _condition_scene.instance()
55
+	_VBoxContainer.add_child(node)
56
+	node.set_id(id)
57
+	node.set_structure(structure)
58
+	_nodes.append(node)
59
+	node.connect("condition_changed", self, "_on_condition_changed")
60
+	node.connect("condition_removed", self, "_on_condition_removed")
61
+	return node
62
+
63
+func _remove_choice_node(index):
64
+	# Remove the node
65
+	_nodes[index].queue_free()
66
+	_nodes.remove(index)
67
+	# Update remaining nodes indexes
68
+	for i in range(0, _nodes.size()):
69
+		_nodes[i].set_id(i)

+ 25
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/ConditionsList.tscn View File

1
+[gd_scene load_steps=2 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/ConditionsList.gd" type="Script" id=1]
4
+
5
+[node name="ConditionsList" type="VBoxContainer"]
6
+margin_left = 5.0
7
+margin_top = 5.0
8
+margin_right = 233.0
9
+margin_bottom = 79.0
10
+size_flags_horizontal = 3
11
+script = ExtResource( 1 )
12
+__meta__ = {
13
+"_edit_use_anchors_": false
14
+}
15
+
16
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
17
+margin_right = 228.0
18
+size_flags_horizontal = 3
19
+
20
+[node name="ContitionAddButton" type="Button" parent="."]
21
+margin_top = 4.0
22
+margin_right = 228.0
23
+margin_bottom = 24.0
24
+text = "Add condition"
25
+[connection signal="pressed" from="ContitionAddButton" to="." method="_on_ContitionAddButton_pressed"]

+ 68
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Infobox/Infobox.gd View File

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

+ 67
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Infobox/Infobox.tscn View File

1
+[gd_scene load_steps=3 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Infobox/Infobox.gd" type="Script" id=1]
4
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/ConditionsList.tscn" type="PackedScene" id=2]
5
+
6
+[node name="Infobox" type="VBoxContainer"]
7
+margin_top = 28.0
8
+margin_right = 238.0
9
+margin_bottom = 112.0
10
+script = ExtResource( 1 )
11
+__meta__ = {
12
+"_edit_use_anchors_": false
13
+}
14
+
15
+[node name="HBoxContainer" type="HBoxContainer" parent="."]
16
+margin_right = 238.0
17
+margin_bottom = 112.0
18
+
19
+[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
20
+margin_right = 215.0
21
+margin_bottom = 112.0
22
+size_flags_horizontal = 3
23
+
24
+[node name="HSeparator" type="HSeparator" parent="HBoxContainer/VBoxContainer"]
25
+margin_right = 215.0
26
+margin_bottom = 4.0
27
+
28
+[node name="Label" type="Label" parent="HBoxContainer/VBoxContainer"]
29
+margin_top = 8.0
30
+margin_right = 215.0
31
+margin_bottom = 22.0
32
+text = "Infobox"
33
+align = 1
34
+
35
+[node name="TextEdit" type="TextEdit" parent="HBoxContainer/VBoxContainer"]
36
+margin_top = 26.0
37
+margin_right = 215.0
38
+margin_bottom = 76.0
39
+rect_min_size = Vector2( 0, 50 )
40
+size_flags_horizontal = 3
41
+
42
+[node name="ConditionsList" parent="HBoxContainer/VBoxContainer" instance=ExtResource( 2 )]
43
+margin_left = 0.0
44
+margin_top = 80.0
45
+margin_right = 215.0
46
+margin_bottom = 104.0
47
+
48
+[node name="HSeparator2" type="HSeparator" parent="HBoxContainer/VBoxContainer"]
49
+margin_top = 108.0
50
+margin_right = 215.0
51
+margin_bottom = 112.0
52
+
53
+[node name="RemoveInfoboxButton" type="Button" parent="HBoxContainer"]
54
+margin_left = 219.0
55
+margin_right = 238.0
56
+margin_bottom = 112.0
57
+text = "x"
58
+
59
+[node name="CreateButton" type="Button" parent="."]
60
+margin_top = 116.0
61
+margin_right = 238.0
62
+margin_bottom = 136.0
63
+text = "Create Infobox"
64
+[connection signal="text_changed" from="HBoxContainer/VBoxContainer/TextEdit" to="." method="_on_TextEdit_text_changed"]
65
+[connection signal="conditions_changed" from="HBoxContainer/VBoxContainer/ConditionsList" to="." method="_on_ConditionsList_conditions_changed"]
66
+[connection signal="pressed" from="HBoxContainer/RemoveInfoboxButton" to="." method="_on_RemoveInfoboxButton_pressed"]
67
+[connection signal="pressed" from="CreateButton" to="." method="_on_CreateButton_pressed"]

+ 67
- 96
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Line_Node.tscn View File

1
-[gd_scene load_steps=3 format=2]
1
+[gd_scene load_steps=4 format=2]
2
 
2
 
3
 [ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd" type="Script" id=1]
3
 [ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd" type="Script" id=1]
4
 [ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/icon_distraction_free.svg" type="Texture" id=2]
4
 [ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/icon_distraction_free.svg" type="Texture" id=2]
5
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/ChoicesList.tscn" type="PackedScene" id=3]
5
 
6
 
6
 [node name="Line" type="GraphNode"]
7
 [node name="Line" type="GraphNode"]
7
 margin_right = 324.0
8
 margin_right = 324.0
8
-margin_bottom = 181.0
9
+margin_bottom = 375.0
9
 rect_min_size = Vector2( 324, 137 )
10
 rect_min_size = Vector2( 324, 137 )
10
 title = "Line"
11
 title = "Line"
11
 offset = Vector2( 40, 40 )
12
 offset = Vector2( 40, 40 )
17
 slot/0/right_enabled = true
18
 slot/0/right_enabled = true
18
 slot/0/right_type = 0
19
 slot/0/right_type = 0
19
 slot/0/right_color = Color( 1, 1, 1, 1 )
20
 slot/0/right_color = Color( 1, 1, 1, 1 )
21
+slot/1/left_enabled = false
22
+slot/1/left_type = 0
23
+slot/1/left_color = Color( 1, 1, 1, 1 )
24
+slot/1/right_enabled = false
25
+slot/1/right_type = 0
26
+slot/1/right_color = Color( 1, 1, 1, 1 )
20
 script = ExtResource( 1 )
27
 script = ExtResource( 1 )
21
 __meta__ = {
28
 __meta__ = {
22
 "_edit_use_anchors_": false
29
 "_edit_use_anchors_": false
24
 
31
 
25
 [node name="MarginContainer" type="MarginContainer" parent="."]
32
 [node name="MarginContainer" type="MarginContainer" parent="."]
26
 margin_left = 16.0
33
 margin_left = 16.0
27
-margin_top = 24.0
34
+margin_top = 39.0
28
 margin_right = 308.0
35
 margin_right = 308.0
29
-margin_bottom = 270.0
36
+margin_bottom = 329.0
30
 custom_constants/margin_right = 10
37
 custom_constants/margin_right = 10
31
 custom_constants/margin_top = 10
38
 custom_constants/margin_top = 10
32
 custom_constants/margin_left = 10
39
 custom_constants/margin_left = 10
36
 margin_left = 10.0
43
 margin_left = 10.0
37
 margin_top = 10.0
44
 margin_top = 10.0
38
 margin_right = 282.0
45
 margin_right = 282.0
39
-margin_bottom = 236.0
46
+margin_bottom = 280.0
40
 size_flags_horizontal = 3
47
 size_flags_horizontal = 3
41
 size_flags_vertical = 3
48
 size_flags_vertical = 3
42
 __meta__ = {
49
 __meta__ = {
45
 
52
 
46
 [node name="HBoxContainer3" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
53
 [node name="HBoxContainer3" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
47
 margin_right = 272.0
54
 margin_right = 272.0
48
-margin_bottom = 42.0
55
+margin_bottom = 70.0
49
 
56
 
50
 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3"]
57
 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3"]
51
 margin_right = 272.0
58
 margin_right = 272.0
52
-margin_bottom = 42.0
59
+margin_bottom = 70.0
53
 size_flags_horizontal = 3
60
 size_flags_horizontal = 3
54
 
61
 
55
 [node name="SpeakerLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"]
62
 [node name="SpeakerLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"]
56
 margin_right = 272.0
63
 margin_right = 272.0
57
 margin_bottom = 14.0
64
 margin_bottom = 14.0
58
 text = "Speaker"
65
 text = "Speaker"
66
+align = 1
59
 
67
 
60
 [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"]
68
 [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"]
69
+margin_left = 89.0
61
 margin_top = 18.0
70
 margin_top = 18.0
62
-margin_right = 272.0
71
+margin_right = 183.0
63
 margin_bottom = 42.0
72
 margin_bottom = 42.0
73
+size_flags_horizontal = 4
64
 
74
 
65
 [node name="SpeakerIdLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
75
 [node name="SpeakerIdLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
66
 margin_top = 5.0
76
 margin_top = 5.0
67
-margin_right = 12.0
77
+margin_right = 16.0
68
 margin_bottom = 19.0
78
 margin_bottom = 19.0
69
-text = "id"
79
+text = "id:"
70
 
80
 
71
 [node name="SpeakerIdSpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
81
 [node name="SpeakerIdSpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
72
-margin_left = 16.0
73
-margin_right = 90.0
82
+margin_left = 20.0
83
+margin_right = 94.0
74
 margin_bottom = 24.0
84
 margin_bottom = 24.0
75
 
85
 
76
-[node name="SpeakerEmotionTextEdit" type="TextEdit" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
77
-margin_left = 94.0
86
+[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"]
87
+margin_top = 46.0
88
+margin_right = 272.0
89
+margin_bottom = 70.0
90
+
91
+[node name="SpeakerEmotionLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer2"]
92
+margin_top = 5.0
93
+margin_right = 57.0
94
+margin_bottom = 19.0
95
+text = "Emotion:"
96
+
97
+[node name="SpeakerEmotionLineEdit" type="LineEdit" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer2"]
98
+margin_left = 61.0
78
 margin_right = 272.0
99
 margin_right = 272.0
79
 margin_bottom = 24.0
100
 margin_bottom = 24.0
80
-rect_min_size = Vector2( 0, 20 )
81
 size_flags_horizontal = 3
101
 size_flags_horizontal = 3
82
-text = "emotion"
83
-__meta__ = {
84
-"_edit_use_anchors_": false
85
-}
86
 
102
 
87
 [node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"]
103
 [node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"]
88
-margin_top = 46.0
104
+margin_top = 74.0
89
 margin_right = 272.0
105
 margin_right = 272.0
90
-margin_bottom = 50.0
106
+margin_bottom = 78.0
91
 
107
 
92
 [node name="HBoxContainer4" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
108
 [node name="HBoxContainer4" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
93
-margin_top = 54.0
109
+margin_top = 82.0
94
 margin_right = 272.0
110
 margin_right = 272.0
95
-margin_bottom = 96.0
111
+margin_bottom = 124.0
96
 
112
 
97
 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer4"]
113
 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer4"]
98
 margin_right = 272.0
114
 margin_right = 272.0
103
 margin_right = 272.0
119
 margin_right = 272.0
104
 margin_bottom = 14.0
120
 margin_bottom = 14.0
105
 text = "Scene"
121
 text = "Scene"
122
+align = 1
106
 
123
 
107
-[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer"]
124
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer"]
125
+margin_left = 89.0
108
 margin_top = 18.0
126
 margin_top = 18.0
109
-margin_right = 272.0
127
+margin_right = 183.0
110
 margin_bottom = 42.0
128
 margin_bottom = 42.0
111
-size_flags_horizontal = 3
129
+size_flags_horizontal = 4
112
 
130
 
113
-[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer"]
114
-margin_left = 91.0
115
-margin_right = 181.0
116
-margin_bottom = 24.0
117
-
118
-[node name="SceneIdLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer"]
131
+[node name="SceneIdLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/HBoxContainer"]
119
 margin_top = 5.0
132
 margin_top = 5.0
120
-margin_right = 12.0
133
+margin_right = 16.0
121
 margin_bottom = 19.0
134
 margin_bottom = 19.0
122
-text = "id"
135
+text = "id:"
123
 
136
 
124
-[node name="SceneIdSpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer"]
125
-margin_left = 16.0
126
-margin_right = 90.0
137
+[node name="SceneIdSpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/HBoxContainer"]
138
+margin_left = 20.0
139
+margin_right = 94.0
127
 margin_bottom = 24.0
140
 margin_bottom = 24.0
128
 
141
 
129
 [node name="HSeparator2" type="HSeparator" parent="MarginContainer/VBoxContainer"]
142
 [node name="HSeparator2" type="HSeparator" parent="MarginContainer/VBoxContainer"]
130
-margin_top = 100.0
143
+margin_top = 128.0
131
 margin_right = 272.0
144
 margin_right = 272.0
132
-margin_bottom = 104.0
145
+margin_bottom = 132.0
133
 
146
 
134
 [node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
147
 [node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
135
-margin_top = 108.0
148
+margin_top = 136.0
136
 margin_right = 272.0
149
 margin_right = 272.0
137
-margin_bottom = 190.0
150
+margin_bottom = 234.0
138
 
151
 
139
 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
152
 [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
140
 margin_right = 272.0
153
 margin_right = 272.0
141
-margin_bottom = 82.0
154
+margin_bottom = 98.0
142
 size_flags_horizontal = 3
155
 size_flags_horizontal = 3
143
 
156
 
144
 [node name="DialogLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
157
 [node name="DialogLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
145
 margin_right = 272.0
158
 margin_right = 272.0
146
 margin_bottom = 14.0
159
 margin_bottom = 14.0
147
-text = "Dialog"
160
+text = "Message"
161
+align = 1
148
 
162
 
149
 [node name="MessageTextEdit" type="TextEdit" parent="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
163
 [node name="MessageTextEdit" type="TextEdit" parent="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
150
 margin_top = 18.0
164
 margin_top = 18.0
151
 margin_right = 272.0
165
 margin_right = 272.0
152
-margin_bottom = 82.0
153
-rect_min_size = Vector2( 256, 64 )
166
+margin_bottom = 98.0
167
+rect_min_size = Vector2( 256, 80 )
154
 size_flags_horizontal = 3
168
 size_flags_horizontal = 3
155
 size_flags_vertical = 3
169
 size_flags_vertical = 3
156
-text = "Message"
157
 smooth_scrolling = true
170
 smooth_scrolling = true
158
 
171
 
159
 [node name="Editor_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
172
 [node name="Editor_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
167
 expand_icon = true
180
 expand_icon = true
168
 
181
 
169
 [node name="HSeparator3" type="HSeparator" parent="MarginContainer/VBoxContainer"]
182
 [node name="HSeparator3" type="HSeparator" parent="MarginContainer/VBoxContainer"]
170
-margin_top = 194.0
183
+margin_top = 238.0
171
 margin_right = 272.0
184
 margin_right = 272.0
172
-margin_bottom = 198.0
185
+margin_bottom = 242.0
173
 __meta__ = {
186
 __meta__ = {
174
 "_edit_use_anchors_": false
187
 "_edit_use_anchors_": false
175
 }
188
 }
176
 
189
 
177
-[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
178
-margin_top = 202.0
179
-margin_right = 272.0
180
-margin_bottom = 226.0
181
-alignment = 1
182
-
183
-[node name="Save_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
184
-visible = false
185
-margin_right = 125.0
186
-margin_bottom = 24.0
187
-hint_tooltip = "Save the current text as a template that can quickly loaded into new nodes."
188
-text = "Save Template As"
189
-
190
-[node name="Load_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
191
-visible = false
192
-margin_left = 64.0
193
-margin_right = 170.0
194
-margin_bottom = 24.0
195
-hint_tooltip = "Load a template from file."
196
-text = "Load Template"
197
-
198
-[node name="VSeparator" type="VSeparator" parent="MarginContainer/VBoxContainer/HBoxContainer"]
199
-visible = false
200
-margin_left = 119.0
201
-margin_right = 123.0
202
-margin_bottom = 24.0
203
-
204
-[node name="Link_LBL" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
205
-margin_left = 77.0
206
-margin_top = 5.0
207
-margin_right = 116.0
208
-margin_bottom = 19.0
209
-text = "Slots: "
210
-
211
-[node name="Link_SpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer"]
212
-margin_left = 120.0
213
-margin_right = 194.0
214
-margin_bottom = 24.0
215
-hint_tooltip = "Change the number of output slots on this node."
216
-min_value = 1.0
217
-value = 1.0
218
-rounded = true
219
-allow_greater = true
190
+[node name="ChoicesList" parent="MarginContainer/VBoxContainer" instance=ExtResource( 3 )]
191
+margin_top = 246.0
192
+margin_bottom = 270.0
220
 [connection signal="close_request" from="." to="." method="_on_Line_close_request"]
193
 [connection signal="close_request" from="." to="." method="_on_Line_close_request"]
221
 [connection signal="offset_changed" from="." to="." method="_on_Line_offset_changed"]
194
 [connection signal="offset_changed" from="." to="." method="_on_Line_offset_changed"]
222
 [connection signal="resize_request" from="." to="." method="_on_Line_resize_request"]
195
 [connection signal="resize_request" from="." to="." method="_on_Line_resize_request"]
223
 [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer/SpeakerIdSpinBox" to="." method="_on_SpeakerIdSpinBox_value_changed"]
196
 [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer/SpeakerIdSpinBox" to="." method="_on_SpeakerIdSpinBox_value_changed"]
224
-[connection signal="text_changed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer/SpeakerEmotionTextEdit" to="." method="_on_SpeakerEmotionTextEdit_text_changed"]
225
-[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer/SceneIdSpinBox" to="." method="_on_SceneIdSpinBox_value_changed"]
197
+[connection signal="text_changed" from="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer2/SpeakerEmotionLineEdit" to="." method="_on_SpeakerEmotionLineEdit_text_changed"]
198
+[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/HBoxContainer/SceneIdSpinBox" to="." method="_on_SceneIdSpinBox_value_changed"]
226
 [connection signal="text_changed" from="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MessageTextEdit" to="." method="_on_MessageTextEdit_text_changed"]
199
 [connection signal="text_changed" from="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MessageTextEdit" to="." method="_on_MessageTextEdit_text_changed"]
227
 [connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/Editor_BTN" to="." method="_on_Editor_BTN_pressed"]
200
 [connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/Editor_BTN" to="." method="_on_Editor_BTN_pressed"]
228
-[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Save_BTN" to="." method="_on_Save_BTN_pressed"]
229
-[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Load_BTN" to="." method="_on_Load_BTN_pressed"]
230
-[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Link_SpinBox" to="." method="_on_Link_SpinBox_value_changed"]
201
+[connection signal="choices_changed" from="MarginContainer/VBoxContainer/ChoicesList" to="." method="_on_ChoicesList_choices_changed"]

+ 48
- 41
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd View File

1
 tool
1
 tool
2
 extends GraphNode
2
 extends GraphNode
3
 
3
 
4
+class_name LineNode
5
+
4
 signal changed_offset(nid, vec2)
6
 signal changed_offset(nid, vec2)
5
 signal changed_size(this)
7
 signal changed_size(this)
6
 signal changed_slots(this)
8
 signal changed_slots(this)
10
 signal pressed_save(this)
12
 signal pressed_save(this)
11
 signal text_changed(nid, new_text)
13
 signal text_changed(nid, new_text)
12
 
14
 
13
-onready var _Link_SpinBox = self.get_node("MarginContainer/VBoxContainer/HBoxContainer/Link_SpinBox")
14
 
15
 
15
-onready var _MessageTextEdit = self.get_node("MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MessageTextEdit")
16
-onready var _SpeakerEmotionTextEdit = self.get_node("MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer/SpeakerEmotionTextEdit")
17
-onready var _SpeakerIdSpinBox = self.get_node("MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer/SpeakerIdSpinBox")
18
-onready var _SceneIdSpinBox = self.get_node("MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer/SceneIdSpinBox")
16
+onready var _SpeakerIdSpinBox: SpinBox = self.get_node("MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer/SpeakerIdSpinBox")
17
+onready var _SpeakerEmotionLineEdit: LineEdit = self.get_node("MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer2/SpeakerEmotionLineEdit")
18
+onready var _SceneIdSpinBox: SpinBox = self.get_node("MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/HBoxContainer/SceneIdSpinBox")
19
+onready var _MessageTextEdit : TextEdit= self.get_node("MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MessageTextEdit")
20
+onready var _ChoicesList: ChoicesList = self.get_node("MarginContainer/VBoxContainer/ChoicesList")
19
 
21
 
20
 var _nid : int = 0
22
 var _nid : int = 0
21
 var _slot_amount : int = 1
23
 var _slot_amount : int = 1
22
 
24
 
23
-
24
 var json_structure = {
25
 var json_structure = {
25
 	"speaker": {
26
 	"speaker": {
26
 		"id": 0,
27
 		"id": 0,
31
 	},
32
 	},
32
 	"dialog": {
33
 	"dialog": {
33
 		"message": "",
34
 		"message": "",
34
-		"choices_free": {
35
-			"placeholder": "",
36
-			"global_var_name": "",
37
-		},
38
-		"choices_multiple": [
39
-			{
40
-				"title": "",
41
-				"arc": 0,
42
-				"infobox": {
43
-					"title": "",
44
-					"text": "",
45
-					"conditions": [],
46
-				},
47
-				"conditions": []
48
-			}
49
-		
50
-		]
35
+		"choices_multiple": []
51
 	}
36
 	}
52
 }
37
 }
53
 
38
 
76
 	self.emit_signal("changed_size", self)
61
 	self.emit_signal("changed_size", self)
77
 
62
 
78
 
63
 
79
-func _on_Link_SpinBox_value_changed(value):
80
-	self._slot_amount = int(self._Link_SpinBox.value)
81
-	self._update_slots()
82
-	self.emit_signal("changed_slots", self)
83
-
84
-
85
 func _on_Load_BTN_pressed():
64
 func _on_Load_BTN_pressed():
86
 	self.emit_signal("pressed_load", self)
65
 	self.emit_signal("pressed_load", self)
87
 
66
 
92
 
71
 
93
 func _on_MessageTextEdit_text_changed():
72
 func _on_MessageTextEdit_text_changed():
94
 	json_structure.dialog.message = self._MessageTextEdit.text
73
 	json_structure.dialog.message = self._MessageTextEdit.text
95
-	emit_text()
74
+	_emit_text()
96
 
75
 
97
 func _on_SceneIdSpinBox_value_changed(value):
76
 func _on_SceneIdSpinBox_value_changed(value):
98
 	json_structure.scene.id = value
77
 	json_structure.scene.id = value
99
-	emit_text()
78
+	_emit_text()
100
 
79
 
101
 
80
 
102
-func _on_SpeakerEmotionTextEdit_text_changed():
103
-	json_structure.speaker.emotion = self._SpeakerEmotionTextEdit.text
104
-	emit_text()
81
+func _on_SpeakerEmotionLineEdit_text_changed(new_text):
82
+	json_structure.speaker.emotion = new_text
83
+	_emit_text()
105
 
84
 
106
 
85
 
107
 func _on_SpeakerIdSpinBox_value_changed(value):
86
 func _on_SpeakerIdSpinBox_value_changed(value):
108
 	json_structure.speaker.id = value
87
 	json_structure.speaker.id = value
109
-	emit_text()
88
+	_emit_text()
89
+
90
+func _on_ChoicesList_choices_changed(new_json_structure):
91
+	json_structure.dialog.choices_multiple = new_json_structure
92
+	var slot_number = json_structure.dialog.choices_multiple.size()
93
+	# Always have at least one slot
94
+	if slot_number == 0:
95
+		slot_number = 1
96
+	if (self.get_slot_amount() != slot_number):
97
+		self.set_slot_amount(slot_number)
98
+		self._update_slots()
99
+		# TODO fix slots resetting when editing choice data
100
+	self.emit_signal("changed_slots", self)
101
+	_emit_text()
110
 
102
 
111
 
103
 
112
 #Public Methods
104
 #Public Methods
120
 
112
 
121
 
113
 
122
 func get_text() -> String:
114
 func get_text() -> String:
123
-	return JSON.print(json_structure)
115
+	return JSON.print(json_structure, "\t")
124
 
116
 
125
 
117
 
126
 func set_nid(new_nid):
118
 func set_nid(new_nid):
135
 
127
 
136
 
128
 
137
 func set_text(new_text : String):
129
 func set_text(new_text : String):
138
-	json_structure = JSON.parse(new_text)
139
-	# TODO update components
130
+	print("New text received:")
131
+	print(new_text)
132
+	json_structure = JSON.parse(new_text).get_result()
133
+	print(JSON.print(json_structure, "\t"))
134
+	_update_components()
140
 	self.emit_signal("text_changed", self._nid, new_text)
135
 	self.emit_signal("text_changed", self._nid, new_text)
141
 
136
 
142
 #Private Methods
137
 #Private Methods
143
 
138
 
144
-func emit_text():
139
+func _update_components():
140
+	_SpeakerIdSpinBox.set_value(json_structure.speaker.id)
141
+	_SpeakerEmotionLineEdit.set_text(json_structure.speaker.emotion);
142
+	_SceneIdSpinBox.set_value(json_structure.scene.id)
143
+	_MessageTextEdit.set_text(json_structure.dialog.message)
144
+	_ChoicesList.set_structure(json_structure.dialog.choices_multiple)
145
+
146
+func _emit_text():
145
 	print(get_text())
147
 	print(get_text())
146
 	self.emit_signal("text_changed", self._nid, get_text())
148
 	self.emit_signal("text_changed", self._nid, get_text())
147
 	
149
 	
158
 	self._clear_link_labels()
160
 	self._clear_link_labels()
159
 	self.set_slot(0, true, 0, Color(1.0, 1.0, 1.0, 1.0), true, 0, Color(1.0, 1.0, 1.0, 1.0), null, null)
161
 	self.set_slot(0, true, 0, Color(1.0, 1.0, 1.0, 1.0), true, 0, Color(1.0, 1.0, 1.0, 1.0), null, null)
160
 	var base_link_label = Label.new()
162
 	var base_link_label = Label.new()
161
-	base_link_label.text = "0"
163
+	if (json_structure.dialog.choices_multiple.size() == 0):
164
+		base_link_label.text = "Next"
165
+	else:
166
+		base_link_label.text = "Choice #1"
162
 	base_link_label.align = Label.ALIGN_RIGHT
167
 	base_link_label.align = Label.ALIGN_RIGHT
163
 	self.add_child(base_link_label)
168
 	self.add_child(base_link_label)
164
 	self.move_child(base_link_label, 0)
169
 	self.move_child(base_link_label, 0)
166
 	for slot in range(1, self._slot_amount):
171
 	for slot in range(1, self._slot_amount):
167
 		self.set_slot(slot, false, 0, Color(1.0, 1.0, 1.0, 1.0), true, 0, Color(1.0, 1.0, 1.0, 1.0), null, null)
172
 		self.set_slot(slot, false, 0, Color(1.0, 1.0, 1.0, 1.0), true, 0, Color(1.0, 1.0, 1.0, 1.0), null, null)
168
 		var output_link_label = Label.new()
173
 		var output_link_label = Label.new()
169
-		output_link_label.text = str(slot)
174
+		output_link_label.text = "Choice #" + str(slot + 1)
170
 		output_link_label.align = Label.ALIGN_RIGHT
175
 		output_link_label.align = Label.ALIGN_RIGHT
171
 		self.add_child_below_node(last_output_link_label, output_link_label)
176
 		self.add_child_below_node(last_output_link_label, output_link_label)
172
 		last_output_link_label = output_link_label
177
 		last_output_link_label = output_link_label
178
+
179
+

+ 37
- 1
project.godot View File

9
 config_version=4
9
 config_version=4
10
 
10
 
11
 _global_script_classes=[ {
11
 _global_script_classes=[ {
12
+"base": "VBoxContainer",
13
+"class": "Choice",
14
+"language": "GDScript",
15
+"path": "res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/Choice/Choice.gd"
16
+}, {
17
+"base": "VBoxContainer",
18
+"class": "ChoicesList",
19
+"language": "GDScript",
20
+"path": "res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ChoicesList/ChoicesList.gd"
21
+}, {
22
+"base": "VBoxContainer",
23
+"class": "Condition",
24
+"language": "GDScript",
25
+"path": "res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/Condition/Condition.gd"
26
+}, {
27
+"base": "VBoxContainer",
28
+"class": "ConditionsList",
29
+"language": "GDScript",
30
+"path": "res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/ConditionsList/ConditionsList.gd"
31
+}, {
12
 "base": "",
32
 "base": "",
13
 "class": "GitAPI",
33
 "class": "GitAPI",
14
 "language": "NativeScript",
34
 "language": "NativeScript",
15
 "path": "res://git_api.gdns"
35
 "path": "res://git_api.gdns"
36
+}, {
37
+"base": "VBoxContainer",
38
+"class": "Infobox",
39
+"language": "GDScript",
40
+"path": "res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Infobox/Infobox.gd"
41
+}, {
42
+"base": "GraphNode",
43
+"class": "LineNode",
44
+"language": "GDScript",
45
+"path": "res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd"
16
 } ]
46
 } ]
17
 _global_script_class_icons={
47
 _global_script_class_icons={
18
-"GitAPI": ""
48
+"Choice": "",
49
+"ChoicesList": "",
50
+"Condition": "",
51
+"ConditionsList": "",
52
+"GitAPI": "",
53
+"Infobox": "",
54
+"LineNode": ""
19
 }
55
 }
20
 
56
 
21
 [application]
57
 [application]

+ 115
- 6
test_story.tres View File

6
 script = ExtResource( 1 )
6
 script = ExtResource( 1 )
7
 TYPE = "EXP_Story_editor"
7
 TYPE = "EXP_Story_editor"
8
 names = {
8
 names = {
9
-"TEST": 1
9
+
10
 }
10
 }
11
 story = {
11
 story = {
12
 1: {
12
 1: {
13
 "available_nid": [  ],
13
 "available_nid": [  ],
14
 "groups": [  ],
14
 "groups": [  ],
15
-"human_readable_description": "This is a test dialog",
16
-"name": "TEST",
15
+"human_readable_description": "New Dialog - Enter Human Readable Description.",
17
 "nodes": {
16
 "nodes": {
18
 1: {
17
 1: {
19
-"graph_offset": Vector2( 200, 40 ),
18
+"graph_offset": Vector2( 120, 80 ),
19
+"links": {
20
+0: 2
21
+},
22
+"rect_size": Vector2( 324, 375 ),
23
+"slot_amount": 1,
24
+"text": "{
25
+	\"speaker\": {
26
+		\"id\": 1,
27
+		\"emotion\": \"happy\"
28
+	},
29
+	\"scene\": {
30
+		\"id\": 1
31
+	},
32
+	\"dialog\": {
33
+		\"message\": \"Bonjour !\",
34
+		\"choices_multiple\": [
35
+
36
+		]
37
+	}
38
+}",
39
+"type": "line"
40
+},
41
+2: {
42
+"graph_offset": Vector2( 540, -180 ),
43
+"links": {
44
+0: 3,
45
+1: 4
46
+},
47
+"rect_size": Vector2( 324, 375 ),
48
+"slot_amount": 2,
49
+"text": "{
50
+	\"speaker\": {
51
+		\"id\": 1,
52
+		\"emotion\": \"happy\"
53
+	},
54
+	\"scene\": {
55
+		\"id\": 1
56
+	},
57
+	\"dialog\": {
58
+		\"message\": \"Comment vas tu ?\",
59
+		\"choices_multiple\": [
60
+			{
61
+				\"title\": \"Super !\",
62
+				\"conditions\": [
63
+					{
64
+						\"id\": \"wellness\",
65
+						\"value\": 50
66
+					}
67
+				]
68
+			},
69
+			{
70
+				\"title\": \"Pas ouf\",
71
+				\"conditions\": [
72
+
73
+				],
74
+				\"infobox\": {
75
+					\"text\": \"Dire une telle chose est impensable\",
76
+					\"conditions\": [
77
+						{
78
+							\"id\": \"intelligence\",
79
+							\"value\": 10
80
+						}
81
+					]
82
+				}
83
+			}
84
+		]
85
+	}
86
+}",
87
+"type": "line"
88
+},
89
+3: {
90
+"graph_offset": Vector2( 980, -60 ),
91
+"links": {
92
+
93
+},
94
+"rect_size": Vector2( 324, 375 ),
95
+"slot_amount": 1,
96
+"text": "{
97
+	\"speaker\": {
98
+		\"id\": 1,
99
+		\"emotion\": \"happy\"
100
+	},
101
+	\"scene\": {
102
+		\"id\": 1
103
+	},
104
+	\"dialog\": {
105
+		\"message\": \"Cool !\",
106
+		\"choices_multiple\": [
107
+
108
+		]
109
+	}
110
+}",
111
+"type": "line"
112
+},
113
+4: {
114
+"graph_offset": Vector2( 980, 460 ),
20
 "links": {
115
 "links": {
21
 
116
 
22
 },
117
 },
23
-"rect_size": Vector2( 324, 181 ),
118
+"rect_size": Vector2( 324, 375 ),
24
 "slot_amount": 1,
119
 "slot_amount": 1,
25
-"text": "{\"speaker\":{\"id\":1,\"emotion\":\"test\"},\"scene\":{\"id\":3},\"dialog\":{\"message\":\"message\",\"choices_free\":{\"placeholder\":\"\",\"global_var_name\":\"\"},\"choices_multiple\":[{\"title\":\"\",\"arc\":0,\"infobox\":{\"title\":\"\",\"text\":\"\",\"conditions\":[]},\"conditions\":[]}]}}",
120
+"text": "{
121
+	\"speaker\": {
122
+		\"id\": 1,
123
+		\"emotion\": \"sad\"
124
+	},
125
+	\"scene\": {
126
+		\"id\": 1
127
+	},
128
+	\"dialog\": {
129
+		\"message\": \"Triste\",
130
+		\"choices_multiple\": [
131
+
132
+		]
133
+	}
134
+}",
26
 "type": "line"
135
 "type": "line"
27
 }
136
 }
28
 }
137
 }

+ 44
- 0
tests/NodeTest.gd View File

1
+extends Node
2
+
3
+onready var _LineNode: LineNode = self.get_node("Line")
4
+
5
+var _json_structure = {
6
+	"speaker": {
7
+		"id": 5,
8
+		"emotion": "happy"
9
+	},
10
+	"scene": {
11
+		"id": 2
12
+	},
13
+	"dialog": {
14
+		"message": "plop",
15
+		"choices_multiple": [
16
+			{
17
+				"title": "test",
18
+				"conditions": [
19
+					{
20
+						"id": "coucou",
21
+						"value": 5
22
+					}
23
+				],
24
+				"infobox": {
25
+					"text": "info info",
26
+					"conditions": [
27
+						{
28
+							"id": "zzzz",
29
+							"value": 1
30
+						}
31
+					]
32
+				}
33
+			},
34
+			{
35
+				"title": "cc",
36
+				"conditions": []
37
+			}
38
+
39
+		]
40
+	}
41
+}
42
+
43
+func _on_Button_pressed():
44
+	_LineNode.set_text(JSON.print(_json_structure))

+ 20
- 0
tests/NodeTest.tscn View File

1
+[gd_scene load_steps=3 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Line_Node.tscn" type="PackedScene" id=1]
4
+[ext_resource path="res://tests/NodeTest.gd" type="Script" id=2]
5
+
6
+[node name="NodeTest" type="Node"]
7
+script = ExtResource( 2 )
8
+
9
+[node name="Line" parent="." instance=ExtResource( 1 )]
10
+
11
+[node name="Button" type="Button" parent="."]
12
+margin_left = 378.27
13
+margin_top = 132.451
14
+margin_right = 427.27
15
+margin_bottom = 152.451
16
+text = "LOAD"
17
+__meta__ = {
18
+"_edit_use_anchors_": false
19
+}
20
+[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]

Loading…
Cancel
Save