Browse Source

Add basic commponents to node editor plugin

Arnaud Vergnet 10 months ago
parent
commit
b7cd887c5e

+ 159
- 37
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Line_Node.tscn View File

@@ -3,10 +3,9 @@
3 3
 [ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd" type="Script" id=1]
4 4
 [ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/icon_distraction_free.svg" type="Texture" id=2]
5 5
 
6
-
7 6
 [node name="Line" type="GraphNode"]
8 7
 margin_right = 324.0
9
-margin_bottom = 137.0
8
+margin_bottom = 181.0
10 9
 rect_min_size = Vector2( 324, 137 )
11 10
 title = "Line"
12 11
 offset = Vector2( 40, 40 )
@@ -29,72 +28,195 @@ __meta__ = {
29 28
 "_edit_use_anchors_": false
30 29
 }
31 30
 
32
-[node name="VBoxContainer" type="VBoxContainer" parent="."]
31
+[node name="MarginContainer" type="MarginContainer" parent="."]
33 32
 margin_left = 16.0
34 33
 margin_top = 39.0
35
-margin_right = 380.0
36
-margin_bottom = 131.0
34
+margin_right = 308.0
35
+margin_bottom = 285.0
36
+custom_constants/margin_right = 10
37
+custom_constants/margin_top = 10
38
+custom_constants/margin_left = 10
39
+custom_constants/margin_bottom = 10
40
+
41
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
42
+margin_left = 10.0
43
+margin_top = 10.0
44
+margin_right = 282.0
45
+margin_bottom = 236.0
37 46
 size_flags_horizontal = 3
38 47
 size_flags_vertical = 3
39 48
 __meta__ = {
40 49
 "_edit_use_anchors_": false
41 50
 }
42 51
 
43
-[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
44
-margin_right = 364.0
45
-margin_bottom = 64.0
52
+[node name="HBoxContainer3" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
53
+margin_right = 272.0
54
+margin_bottom = 42.0
55
+
56
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3"]
57
+margin_right = 272.0
58
+margin_bottom = 42.0
59
+size_flags_horizontal = 3
60
+
61
+[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"]
62
+margin_right = 272.0
63
+margin_bottom = 14.0
64
+text = "Speaker"
65
+
66
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"]
67
+margin_top = 18.0
68
+margin_right = 272.0
69
+margin_bottom = 42.0
70
+
71
+[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
72
+margin_top = 5.0
73
+margin_right = 12.0
74
+margin_bottom = 19.0
75
+text = "id"
76
+
77
+[node name="SpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
78
+margin_left = 16.0
79
+margin_right = 90.0
80
+margin_bottom = 24.0
81
+
82
+[node name="TextEdit2" type="TextEdit" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
83
+margin_left = 94.0
84
+margin_right = 272.0
85
+margin_bottom = 24.0
86
+rect_min_size = Vector2( 0, 20 )
87
+size_flags_horizontal = 3
88
+text = "emotion"
89
+__meta__ = {
90
+"_edit_use_anchors_": false
91
+}
92
+
93
+[node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"]
94
+margin_top = 46.0
95
+margin_right = 272.0
96
+margin_bottom = 50.0
97
+
98
+[node name="HBoxContainer4" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
99
+margin_top = 54.0
100
+margin_right = 272.0
101
+margin_bottom = 96.0
102
+
103
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer4"]
104
+margin_right = 272.0
105
+margin_bottom = 42.0
106
+size_flags_horizontal = 3
107
+
108
+[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer"]
109
+margin_right = 272.0
110
+margin_bottom = 14.0
111
+text = "Scene"
112
+
113
+[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer"]
114
+margin_top = 18.0
115
+margin_right = 272.0
116
+margin_bottom = 42.0
117
+size_flags_horizontal = 3
118
+
119
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer"]
120
+margin_left = 91.0
121
+margin_right = 181.0
122
+margin_bottom = 24.0
46 123
 
47
-[node name="TextEdit" type="TextEdit" parent="VBoxContainer/HBoxContainer2"]
48
-margin_right = 328.0
49
-margin_bottom = 64.0
124
+[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer"]
125
+margin_top = 5.0
126
+margin_right = 12.0
127
+margin_bottom = 19.0
128
+text = "id"
129
+
130
+[node name="SpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer"]
131
+margin_left = 16.0
132
+margin_right = 90.0
133
+margin_bottom = 24.0
134
+
135
+[node name="HSeparator2" type="HSeparator" parent="MarginContainer/VBoxContainer"]
136
+margin_top = 100.0
137
+margin_right = 272.0
138
+margin_bottom = 104.0
139
+
140
+[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
141
+margin_top = 108.0
142
+margin_right = 272.0
143
+margin_bottom = 190.0
144
+
145
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
146
+margin_right = 272.0
147
+margin_bottom = 82.0
148
+size_flags_horizontal = 3
149
+
150
+[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
151
+margin_right = 272.0
152
+margin_bottom = 14.0
153
+text = "Dialog"
154
+
155
+[node name="MessageTextEdit" type="TextEdit" parent="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
156
+margin_top = 18.0
157
+margin_right = 272.0
158
+margin_bottom = 82.0
50 159
 rect_min_size = Vector2( 256, 64 )
51 160
 size_flags_horizontal = 3
52 161
 size_flags_vertical = 3
162
+text = "Message"
53 163
 smooth_scrolling = true
54 164
 
55
-[node name="Editor_BTN" type="Button" parent="VBoxContainer/HBoxContainer2"]
56
-margin_left = 332.0
57
-margin_right = 364.0
58
-margin_bottom = 64.0
165
+[node name="Editor_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer2"]
166
+visible = false
167
+margin_left = 260.0
168
+margin_right = 292.0
169
+margin_bottom = 82.0
59 170
 rect_min_size = Vector2( 32, 0 )
60 171
 hint_tooltip = "Expand this node's text editor."
61 172
 icon = ExtResource( 2 )
62 173
 expand_icon = true
63 174
 
64
-[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
65
-margin_top = 68.0
66
-margin_right = 364.0
67
-margin_bottom = 92.0
175
+[node name="HSeparator3" type="HSeparator" parent="MarginContainer/VBoxContainer"]
176
+margin_top = 194.0
177
+margin_right = 272.0
178
+margin_bottom = 198.0
179
+__meta__ = {
180
+"_edit_use_anchors_": false
181
+}
182
+
183
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
184
+margin_top = 202.0
185
+margin_right = 272.0
186
+margin_bottom = 226.0
68 187
 alignment = 1
69 188
 
70
-[node name="Save_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
189
+[node name="Save_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
190
+visible = false
71 191
 margin_right = 125.0
72 192
 margin_bottom = 24.0
73 193
 hint_tooltip = "Save the current text as a template that can quickly loaded into new nodes."
74 194
 text = "Save Template As"
75 195
 
76
-[node name="Load_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
77
-margin_left = 129.0
78
-margin_right = 235.0
196
+[node name="Load_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
197
+visible = false
198
+margin_left = 64.0
199
+margin_right = 170.0
79 200
 margin_bottom = 24.0
80 201
 hint_tooltip = "Load a template from file."
81 202
 text = "Load Template"
82 203
 
83
-[node name="VSeparator" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
84
-margin_left = 239.0
85
-margin_right = 243.0
204
+[node name="VSeparator" type="VSeparator" parent="MarginContainer/VBoxContainer/HBoxContainer"]
205
+visible = false
206
+margin_left = 119.0
207
+margin_right = 123.0
86 208
 margin_bottom = 24.0
87 209
 
88
-[node name="Link_LBL" type="Label" parent="VBoxContainer/HBoxContainer"]
89
-margin_left = 247.0
210
+[node name="Link_LBL" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
211
+margin_left = 77.0
90 212
 margin_top = 5.0
91
-margin_right = 286.0
213
+margin_right = 116.0
92 214
 margin_bottom = 19.0
93 215
 text = "Slots: "
94 216
 
95
-[node name="Link_SpinBox" type="SpinBox" parent="VBoxContainer/HBoxContainer"]
96
-margin_left = 290.0
97
-margin_right = 364.0
217
+[node name="Link_SpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer"]
218
+margin_left = 120.0
219
+margin_right = 194.0
98 220
 margin_bottom = 24.0
99 221
 hint_tooltip = "Change the number of output slots on this node."
100 222
 min_value = 1.0
@@ -104,8 +226,8 @@ allow_greater = true
104 226
 [connection signal="close_request" from="." to="." method="_on_Line_close_request"]
105 227
 [connection signal="offset_changed" from="." to="." method="_on_Line_offset_changed"]
106 228
 [connection signal="resize_request" from="." to="." method="_on_Line_resize_request"]
107
-[connection signal="text_changed" from="VBoxContainer/HBoxContainer2/TextEdit" to="." method="_on_TextEdit_text_changed"]
108
-[connection signal="pressed" from="VBoxContainer/HBoxContainer2/Editor_BTN" to="." method="_on_Editor_BTN_pressed"]
109
-[connection signal="pressed" from="VBoxContainer/HBoxContainer/Save_BTN" to="." method="_on_Save_BTN_pressed"]
110
-[connection signal="pressed" from="VBoxContainer/HBoxContainer/Load_BTN" to="." method="_on_Load_BTN_pressed"]
111
-[connection signal="value_changed" from="VBoxContainer/HBoxContainer/Link_SpinBox" to="." method="_on_Link_SpinBox_value_changed"]
229
+[connection signal="text_changed" from="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MessageTextEdit" to="." method="_on_TextEdit_text_changed"]
230
+[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/Editor_BTN" to="." method="_on_Editor_BTN_pressed"]
231
+[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Save_BTN" to="." method="_on_Save_BTN_pressed"]
232
+[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Load_BTN" to="." method="_on_Load_BTN_pressed"]
233
+[connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Link_SpinBox" to="." method="_on_Link_SpinBox_value_changed"]

+ 50
- 3
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd View File

@@ -10,12 +10,54 @@ signal pressed_load(this)
10 10
 signal pressed_save(this)
11 11
 signal text_changed(nid, new_text)
12 12
 
13
-onready var _Link_SpinBox = self.get_node("VBoxContainer/HBoxContainer/Link_SpinBox")
14
-onready var _Text_Editor = self.get_node("VBoxContainer/HBoxContainer2/TextEdit")
13
+onready var _Link_SpinBox = self.get_node("MarginContainer/VBoxContainer/HBoxContainer/Link_SpinBox")
14
+onready var _Text_Editor = self.get_node("MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer/TextEdit")
15 15
 
16 16
 var _nid : int = 0
17 17
 var _slot_amount : int = 1
18 18
 
19
+
20
+var json_structure = {
21
+	"speaker": {
22
+		"id": 0,
23
+		"emotion": "happy"
24
+	},
25
+	"scene": {
26
+		"id": 0
27
+	},
28
+	"dialog": {
29
+		"message": "",
30
+		"choices_free": {
31
+			"placeholder": "",
32
+			"global_var_name": "",
33
+		},
34
+		"choices_multiple": [
35
+			{
36
+				"title": "",
37
+				"arc": 0,
38
+				"infobox": {
39
+					"title": "",
40
+					"text": "",
41
+					"conditions": [
42
+						{
43
+							"id": "education",
44
+							"value": 0
45
+						}  
46
+					],
47
+				},
48
+				"conditions": [
49
+					{
50
+						"id": "open_mindeness",
51
+						"value": 0
52
+					}     
53
+				]
54
+			}
55
+		
56
+		]
57
+	}
58
+}
59
+
60
+
19 61
 #Virtual Methods
20 62
 
21 63
 func _ready():
@@ -55,7 +97,8 @@ func _on_Save_BTN_pressed():
55 97
 
56 98
 
57 99
 func _on_TextEdit_text_changed():
58
-	self.emit_signal("text_changed", self._nid, self._Text_Editor.text)
100
+	json_structure.dialog.message = self._Text_Editor.text
101
+	emit_text()
59 102
 
60 103
 #Public Methods
61 104
 
@@ -88,6 +131,10 @@ func set_text(new_text : String):
88 131
 
89 132
 #Private Methods
90 133
 
134
+func emit_text():
135
+	self.emit_signal("text_changed", self._nid, JSON.print(json_structure))
136
+	
137
+
91 138
 func _clear_link_labels():
92 139
 	var children = self.get_children()
93 140
 	for child in children:

Loading…
Cancel
Save