Browse Source

Update json structure from new controls

Arnaud Vergnet 3 years ago
parent
commit
04dac568d0

+ 14
- 17
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Line_Node.tscn View File

@@ -17,12 +17,6 @@ slot/0/left_color = Color( 1, 1, 1, 1 )
17 17
 slot/0/right_enabled = true
18 18
 slot/0/right_type = 0
19 19
 slot/0/right_color = Color( 1, 1, 1, 1 )
20
-slot/1/left_enabled = false
21
-slot/1/left_type = 0
22
-slot/1/left_color = Color( 1, 1, 1, 1 )
23
-slot/1/right_enabled = false
24
-slot/1/right_type = 0
25
-slot/1/right_color = Color( 1, 1, 1, 1 )
26 20
 script = ExtResource( 1 )
27 21
 __meta__ = {
28 22
 "_edit_use_anchors_": false
@@ -30,9 +24,9 @@ __meta__ = {
30 24
 
31 25
 [node name="MarginContainer" type="MarginContainer" parent="."]
32 26
 margin_left = 16.0
33
-margin_top = 39.0
27
+margin_top = 24.0
34 28
 margin_right = 308.0
35
-margin_bottom = 285.0
29
+margin_bottom = 270.0
36 30
 custom_constants/margin_right = 10
37 31
 custom_constants/margin_top = 10
38 32
 custom_constants/margin_left = 10
@@ -58,7 +52,7 @@ margin_right = 272.0
58 52
 margin_bottom = 42.0
59 53
 size_flags_horizontal = 3
60 54
 
61
-[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"]
55
+[node name="SpeakerLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer"]
62 56
 margin_right = 272.0
63 57
 margin_bottom = 14.0
64 58
 text = "Speaker"
@@ -68,18 +62,18 @@ margin_top = 18.0
68 62
 margin_right = 272.0
69 63
 margin_bottom = 42.0
70 64
 
71
-[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
65
+[node name="SpeakerIdLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
72 66
 margin_top = 5.0
73 67
 margin_right = 12.0
74 68
 margin_bottom = 19.0
75 69
 text = "id"
76 70
 
77
-[node name="SpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
71
+[node name="SpeakerIdSpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
78 72
 margin_left = 16.0
79 73
 margin_right = 90.0
80 74
 margin_bottom = 24.0
81 75
 
82
-[node name="TextEdit2" type="TextEdit" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
76
+[node name="SpeakerEmotionTextEdit" type="TextEdit" parent="MarginContainer/VBoxContainer/HBoxContainer3/VBoxContainer/HBoxContainer"]
83 77
 margin_left = 94.0
84 78
 margin_right = 272.0
85 79
 margin_bottom = 24.0
@@ -105,7 +99,7 @@ margin_right = 272.0
105 99
 margin_bottom = 42.0
106 100
 size_flags_horizontal = 3
107 101
 
108
-[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer"]
102
+[node name="SceneLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer"]
109 103
 margin_right = 272.0
110 104
 margin_bottom = 14.0
111 105
 text = "Scene"
@@ -121,13 +115,13 @@ margin_left = 91.0
121 115
 margin_right = 181.0
122 116
 margin_bottom = 24.0
123 117
 
124
-[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer"]
118
+[node name="SceneIdLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer"]
125 119
 margin_top = 5.0
126 120
 margin_right = 12.0
127 121
 margin_bottom = 19.0
128 122
 text = "id"
129 123
 
130
-[node name="SpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer"]
124
+[node name="SceneIdSpinBox" type="SpinBox" parent="MarginContainer/VBoxContainer/HBoxContainer4/VBoxContainer/CenterContainer/HBoxContainer"]
131 125
 margin_left = 16.0
132 126
 margin_right = 90.0
133 127
 margin_bottom = 24.0
@@ -147,7 +141,7 @@ margin_right = 272.0
147 141
 margin_bottom = 82.0
148 142
 size_flags_horizontal = 3
149 143
 
150
-[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
144
+[node name="DialogLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer"]
151 145
 margin_right = 272.0
152 146
 margin_bottom = 14.0
153 147
 text = "Dialog"
@@ -226,7 +220,10 @@ allow_greater = true
226 220
 [connection signal="close_request" from="." to="." method="_on_Line_close_request"]
227 221
 [connection signal="offset_changed" from="." to="." method="_on_Line_offset_changed"]
228 222
 [connection signal="resize_request" from="." to="." method="_on_Line_resize_request"]
229
-[connection signal="text_changed" from="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MessageTextEdit" to="." method="_on_TextEdit_text_changed"]
223
+[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"]
226
+[connection signal="text_changed" from="MarginContainer/VBoxContainer/HBoxContainer2/VBoxContainer/MessageTextEdit" to="." method="_on_MessageTextEdit_text_changed"]
230 227
 [connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer2/Editor_BTN" to="." method="_on_Editor_BTN_pressed"]
231 228
 [connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Save_BTN" to="." method="_on_Save_BTN_pressed"]
232 229
 [connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Load_BTN" to="." method="_on_Load_BTN_pressed"]

+ 29
- 18
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd View File

@@ -11,7 +11,11 @@ signal pressed_save(this)
11 11
 signal text_changed(nid, new_text)
12 12
 
13 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")
14
+
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")
15 19
 
16 20
 var _nid : int = 0
17 21
 var _slot_amount : int = 1
@@ -38,19 +42,9 @@ var json_structure = {
38 42
 				"infobox": {
39 43
 					"title": "",
40 44
 					"text": "",
41
-					"conditions": [
42
-						{
43
-							"id": "education",
44
-							"value": 0
45
-						}  
46
-					],
45
+					"conditions": [],
47 46
 				},
48
-				"conditions": [
49
-					{
50
-						"id": "open_mindeness",
51
-						"value": 0
52
-					}     
53
-				]
47
+				"conditions": []
54 48
 			}
55 49
 		
56 50
 		]
@@ -96,10 +90,25 @@ func _on_Save_BTN_pressed():
96 90
 	self.emit_signal("pressed_save", self)
97 91
 
98 92
 
99
-func _on_TextEdit_text_changed():
100
-	json_structure.dialog.message = self._Text_Editor.text
93
+func _on_MessageTextEdit_text_changed():
94
+	json_structure.dialog.message = self._MessageTextEdit.text
95
+	emit_text()
96
+
97
+func _on_SceneIdSpinBox_value_changed(value):
98
+	json_structure.scene.id = value
99
+	emit_text()
100
+
101
+
102
+func _on_SpeakerEmotionTextEdit_text_changed():
103
+	json_structure.speaker.emotion = self._SpeakerEmotionTextEdit.text
101 104
 	emit_text()
102 105
 
106
+
107
+func _on_SpeakerIdSpinBox_value_changed(value):
108
+	json_structure.speaker.id = value
109
+	emit_text()
110
+
111
+
103 112
 #Public Methods
104 113
 
105 114
 func get_nid() -> int:
@@ -111,7 +120,7 @@ func get_slot_amount() -> int:
111 120
 
112 121
 
113 122
 func get_text() -> String:
114
-	return self._Text_Editor.text
123
+	return JSON.print(json_structure)
115 124
 
116 125
 
117 126
 func set_nid(new_nid):
@@ -126,13 +135,15 @@ func set_slot_amount(new_amount : int):
126 135
 
127 136
 
128 137
 func set_text(new_text : String):
129
-	self._Text_Editor.text = new_text
138
+	json_structure = JSON.parse(new_text)
139
+	# TODO update components
130 140
 	self.emit_signal("text_changed", self._nid, new_text)
131 141
 
132 142
 #Private Methods
133 143
 
134 144
 func emit_text():
135
-	self.emit_signal("text_changed", self._nid, JSON.print(json_structure))
145
+	print(get_text())
146
+	self.emit_signal("text_changed", self._nid, get_text())
136 147
 	
137 148
 
138 149
 func _clear_link_labels():

+ 32
- 0
test_story.tres View File

@@ -0,0 +1,32 @@
1
+[gd_resource type="Resource" load_steps=2 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Resource_EditorStory/EXP_EditorStory.gd" type="Script" id=1]
4
+
5
+[resource]
6
+script = ExtResource( 1 )
7
+TYPE = "EXP_Story_editor"
8
+names = {
9
+"TEST": 1
10
+}
11
+story = {
12
+1: {
13
+"available_nid": [  ],
14
+"groups": [  ],
15
+"human_readable_description": "This is a test dialog",
16
+"name": "TEST",
17
+"nodes": {
18
+1: {
19
+"graph_offset": Vector2( 200, 40 ),
20
+"links": {
21
+
22
+},
23
+"rect_size": Vector2( 324, 181 ),
24
+"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\":[]}]}}",
26
+"type": "line"
27
+}
28
+}
29
+}
30
+}
31
+available_dids = [  ]
32
+groups = [  ]

Loading…
Cancel
Save