Browse Source

update dialogic

Arnaud Vergnet 3 years ago
parent
commit
a79c4ba65b

+ 5
- 5
addons/dialogic/Editor/Events/ChangeBackground.gd View File

@@ -6,10 +6,6 @@ var preview_scene = preload("res://addons/dialogic/Editor/Events/Common/Images/I
6 6
 var preview = "..."
7 7
 var image_picker
8 8
 
9
-# This is the information of this event and it will get parsed and saved to the JSON file.
10
-var event_data = {
11
-	'background': ''
12
-}
13 9
 
14 10
 func _ready():
15 11
 	image_picker = get_header()
@@ -17,10 +13,14 @@ func _ready():
17 13
 	image_picker.editor_reference = editor_reference
18 14
 	image_picker.connect("file_selected", self, "_on_file_selected")
19 15
 	image_picker.connect("clear_pressed", self, "_on_clear_pressed")
16
+	# Init the data
17
+	event_data = {
18
+		'background': ''
19
+	}
20 20
 
21 21
 
22 22
 func load_data(data):
23
-	event_data = data
23
+	.load_data(data)
24 24
 	load_image(event_data['background'])
25 25
 
26 26
 

+ 13
- 0
addons/dialogic/Editor/Events/Common/SecondsSelector.gd View File

@@ -0,0 +1,13 @@
1
+tool
2
+extends HBoxContainer
3
+
4
+onready var spinbox := $SpinBox
5
+
6
+signal value_changed(value)
7
+
8
+func set_value(val: float):
9
+	spinbox.value = val
10
+
11
+
12
+func _on_SpinBox_value_changed(value):
13
+	emit_signal("value_changed", value)

+ 37
- 0
addons/dialogic/Editor/Events/Common/SecondsSelector.tscn View File

@@ -0,0 +1,37 @@
1
+[gd_scene load_steps=3 format=2]
2
+
3
+[ext_resource path="res://addons/dialogic/Editor/Events/Common/SpinBoxPreventDnD.gd" type="Script" id=1]
4
+[ext_resource path="res://addons/dialogic/Editor/Events/Common/SecondsSelector.gd" type="Script" id=2]
5
+
6
+[node name="SecondsSelector" type="HBoxContainer"]
7
+margin_right = 139.0
8
+margin_bottom = 28.0
9
+script = ExtResource( 2 )
10
+__meta__ = {
11
+"_edit_use_anchors_": false
12
+}
13
+
14
+[node name="SpinBox" type="SpinBox" parent="."]
15
+margin_right = 74.0
16
+margin_bottom = 28.0
17
+min_value = 0.1
18
+step = 0.1
19
+value = 1.0
20
+allow_greater = true
21
+align = 1
22
+script = ExtResource( 1 )
23
+
24
+[node name="MarginContainer" type="MarginContainer" parent="."]
25
+margin_left = 78.0
26
+margin_right = 141.0
27
+margin_bottom = 28.0
28
+mouse_filter = 1
29
+custom_constants/margin_left = 10
30
+
31
+[node name="Title" type="Label" parent="MarginContainer"]
32
+margin_left = 10.0
33
+margin_top = 7.0
34
+margin_right = 63.0
35
+margin_bottom = 21.0
36
+text = "Seconds"
37
+[connection signal="value_changed" from="SpinBox" to="." method="_on_SpinBox_value_changed"]

+ 7
- 0
addons/dialogic/Editor/Events/Templates/EventTemplate.gd View File

@@ -30,10 +30,17 @@ var indent_size = 25
30 30
 # Useful for making placeholder events in drag and drop
31 31
 var ignore_save = false
32 32
 
33
+# This is the data that is going to be saved to json
34
+var event_data := {}
35
+
33 36
 ## *****************************************************************************
34 37
 ##								PUBLIC METHODS
35 38
 ## *****************************************************************************
36 39
 
40
+# Called when timeline editor loads
41
+func load_data(data):
42
+	event_data = data
43
+
37 44
 
38 45
 func set_event_style(style: StyleBoxFlat):
39 46
 	panel.set('custom_styles/panel', style)

+ 16
- 14
addons/dialogic/Editor/Events/Templates/EventTemplate.tscn View File

@@ -6,6 +6,10 @@
6 6
 [ext_resource path="res://addons/dialogic/Images/Plugin/plugin-editor-icon-dark-theme.svg" type="Texture" id=6]
7 7
 
8 8
 [sub_resource type="StyleBoxFlat" id=1]
9
+content_margin_left = 0.0
10
+content_margin_right = 0.0
11
+content_margin_top = 0.0
12
+content_margin_bottom = 0.0
9 13
 bg_color = Color( 0.262745, 0.262745, 0.262745, 1 )
10 14
 border_width_left = 2
11 15
 border_width_top = 2
@@ -18,8 +22,8 @@ corner_radius_bottom_left = 6
18 22
 
19 23
 [node name="EventTemplate" type="HBoxContainer"]
20 24
 anchor_right = 1.0
21
-margin_bottom = 44.0
22
-rect_min_size = Vector2( 0, 44 )
25
+margin_bottom = 42.0
26
+rect_min_size = Vector2( 0, 42 )
23 27
 size_flags_horizontal = 3
24 28
 size_flags_vertical = 9
25 29
 __meta__ = {
@@ -32,7 +36,7 @@ margin_bottom = 64.0
32 36
 
33 37
 [node name="PanelContainer" type="PanelContainer" parent="."]
34 38
 margin_right = 1024.0
35
-margin_bottom = 46.0
39
+margin_bottom = 42.0
36 40
 mouse_filter = 1
37 41
 mouse_default_cursor_shape = 6
38 42
 size_flags_horizontal = 3
@@ -40,10 +44,8 @@ size_flags_vertical = 3
40 44
 custom_styles/panel = SubResource( 1 )
41 45
 
42 46
 [node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
43
-margin_left = 2.0
44
-margin_top = 2.0
45
-margin_right = 1022.0
46
-margin_bottom = 44.0
47
+margin_right = 1024.0
48
+margin_bottom = 42.0
47 49
 mouse_filter = 1
48 50
 custom_constants/margin_right = 6
49 51
 custom_constants/margin_top = 6
@@ -53,13 +55,13 @@ custom_constants/margin_bottom = 6
53 55
 [node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
54 56
 margin_left = 6.0
55 57
 margin_top = 6.0
56
-margin_right = 1014.0
58
+margin_right = 1018.0
57 59
 margin_bottom = 36.0
58 60
 rect_min_size = Vector2( 0, 30 )
59 61
 size_flags_horizontal = 3
60 62
 
61 63
 [node name="Header" type="HBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer"]
62
-margin_right = 1008.0
64
+margin_right = 1012.0
63 65
 margin_bottom = 30.0
64 66
 rect_min_size = Vector2( 0, 30 )
65 67
 size_flags_horizontal = 3
@@ -126,18 +128,18 @@ margin_right = 230.0
126 128
 
127 129
 [node name="Spacer" parent="PanelContainer/MarginContainer/VBoxContainer/Header" instance=ExtResource( 4 )]
128 130
 margin_left = 178.0
129
-margin_right = 962.0
131
+margin_right = 966.0
130 132
 margin_bottom = 30.0
131 133
 
132 134
 [node name="VSeparator3" type="VSeparator" parent="PanelContainer/MarginContainer/VBoxContainer/Header"]
133
-margin_left = 966.0
134
-margin_right = 970.0
135
+margin_left = 970.0
136
+margin_right = 974.0
135 137
 margin_bottom = 30.0
136 138
 mouse_filter = 1
137 139
 
138 140
 [node name="OptionsControl" parent="PanelContainer/MarginContainer/VBoxContainer/Header" instance=ExtResource( 5 )]
139
-margin_left = 974.0
140
-margin_right = 1008.0
141
+margin_left = 978.0
142
+margin_right = 1012.0
141 143
 margin_bottom = 30.0
142 144
 items = [ "Move Up", null, 0, false, false, 0, 0, null, "", false, "Move Down", null, 0, false, false, 1, 0, null, "", false, "", null, 0, false, false, 2, 0, null, "", false, "Remove", null, 0, false, false, 3, 0, null, "", false ]
143 145
 

+ 10
- 9
addons/dialogic/Editor/Events/WaitSeconds.gd View File

@@ -1,18 +1,19 @@
1 1
 tool
2
-extends Control
2
+extends "res://addons/dialogic/Editor/Events/Templates/EventTemplate.gd"
3 3
 
4
-var editor_reference
5 4
 
6
-# This is the information of this event and it will get parsed and saved to the JSON file.
7
-var event_data = {
8
-	'wait_seconds': 0
9
-}
5
+func _ready():
6
+	event_data = {
7
+		'wait_seconds': 1
8
+	}
9
+	get_header().set_value(float(event_data['wait_seconds']))
10
+	get_header().connect("value_changed", self, "_on_Selector_value_changed")
10 11
 
11 12
 
12 13
 func load_data(data):
13
-	event_data = data
14
-	$PanelContainer/VBoxContainer/Header/SpinBox.value = event_data['wait_seconds']
14
+	.load_data(data)
15
+	get_header().set_value(float(event_data['wait_seconds']))
15 16
 
16 17
 
17
-func _on_SpinBox_value_changed(value):
18
+func _on_Selector_value_changed(value):
18 19
 	event_data['wait_seconds'] = value

+ 34
- 94
addons/dialogic/Editor/Events/WaitSeconds.tscn View File

@@ -1,110 +1,50 @@
1
-[gd_scene load_steps=7 format=2]
1
+[gd_scene load_steps=6 format=2]
2 2
 
3 3
 [ext_resource path="res://addons/dialogic/Images/Event Icons/Main Icons/wait-seconds.svg" type="Texture" id=1]
4 4
 [ext_resource path="res://addons/dialogic/Editor/Events/WaitSeconds.gd" type="Script" id=2]
5
-[ext_resource path="res://addons/dialogic/Editor/Events/Common/Spacer.tscn" type="PackedScene" id=3]
6
-[ext_resource path="res://addons/dialogic/Editor/Events/Common/PieceExtraSettings.tscn" type="PackedScene" id=4]
7
-[ext_resource path="res://addons/dialogic/Editor/Events/Common/SpinBoxPreventDnD.gd" type="Script" id=6]
5
+[ext_resource path="res://addons/dialogic/Editor/Events/Common/SecondsSelector.tscn" type="PackedScene" id=3]
6
+[ext_resource path="res://addons/dialogic/Editor/Events/Templates/EventTemplate.tscn" type="PackedScene" id=4]
7
+[ext_resource path="res://addons/dialogic/Editor/Events/styles/WaitSeconds.tres" type="StyleBox" id=5]
8 8
 
9
-[sub_resource type="StyleBoxFlat" id=1]
10
-content_margin_left = 16.0
11
-content_margin_right = 6.0
12
-content_margin_top = 6.0
13
-content_margin_bottom = 6.0
14
-bg_color = Color( 0.435294, 0.301961, 0.603922, 0.192157 )
15
-border_width_left = 2
16
-border_width_top = 2
17
-border_width_right = 2
18
-border_width_bottom = 2
19
-border_color = Color( 0.12549, 0.12549, 0.12549, 1 )
20
-corner_radius_top_left = 6
21
-corner_radius_top_right = 6
22
-corner_radius_bottom_right = 6
23
-corner_radius_bottom_left = 6
24
-
25
-[node name="WaitSeconds" type="HBoxContainer"]
26
-margin_right = 1004.0
27
-margin_bottom = 42.0
28
-size_flags_horizontal = 3
29
-size_flags_vertical = 9
9
+[node name="EventTemplate" instance=ExtResource( 4 )]
10
+margin_bottom = 46.0
30 11
 script = ExtResource( 2 )
31
-__meta__ = {
32
-"_edit_use_anchors_": false
33
-}
34
-
35
-[node name="Indent" type="Control" parent="."]
36
-visible = false
37
-margin_bottom = 42.0
38
-
39
-[node name="PanelContainer" type="PanelContainer" parent="."]
40
-margin_right = 1004.0
41
-margin_bottom = 42.0
42
-mouse_filter = 1
43
-size_flags_horizontal = 3
44
-size_flags_vertical = 3
45
-custom_styles/panel = SubResource( 1 )
46
-__meta__ = {
47
-"_edit_use_anchors_": false
48
-}
12
+event_style = ExtResource( 5 )
13
+event_icon = ExtResource( 1 )
14
+event_name = "Wait"
15
+header_scene = ExtResource( 3 )
49 16
 
50
-[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
51
-margin_left = 16.0
52
-margin_top = 6.0
53
-margin_right = 998.0
54
-margin_bottom = 36.0
55
-size_flags_horizontal = 3
17
+[node name="PanelContainer" parent="." index="1"]
18
+custom_styles/panel = ExtResource( 5 )
56 19
 
57
-[node name="Header" type="HBoxContainer" parent="PanelContainer/VBoxContainer"]
58
-margin_right = 982.0
59
-margin_bottom = 28.0
20
+[node name="IconMarginContainer" parent="PanelContainer/MarginContainer/VBoxContainer/Header" index="0"]
21
+margin_right = 37.0
60 22
 
61
-[node name="TextureRect" type="TextureRect" parent="PanelContainer/VBoxContainer/Header"]
62
-margin_right = 22.0
63
-margin_bottom = 28.0
23
+[node name="IconTexture" parent="PanelContainer/MarginContainer/VBoxContainer/Header/IconMarginContainer" index="0"]
24
+margin_right = 32.0
64 25
 texture = ExtResource( 1 )
65
-stretch_mode = 6
66 26
 
67
-[node name="Title" type="Label" parent="PanelContainer/VBoxContainer/Header"]
68
-margin_left = 26.0
69
-margin_top = 7.0
70
-margin_right = 75.0
71
-margin_bottom = 21.0
72
-text = "  Wait   "
27
+[node name="TitleHBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer/Header" index="1"]
28
+margin_left = 41.0
29
+margin_right = 96.0
73 30
 
74
-[node name="SpinBox" type="SpinBox" parent="PanelContainer/VBoxContainer/Header"]
75
-margin_left = 79.0
76
-margin_right = 153.0
77
-margin_bottom = 28.0
78
-min_value = 0.1
79
-step = 0.1
80
-value = 1.0
81
-allow_greater = true
82
-align = 1
83
-script = ExtResource( 6 )
31
+[node name="TitleMarginContainer" parent="PanelContainer/MarginContainer/VBoxContainer/Header/TitleHBoxContainer" index="1"]
32
+margin_right = 47.0
84 33
 
85
-[node name="Title2" type="Label" parent="PanelContainer/VBoxContainer/Header"]
86
-margin_left = 157.0
87
-margin_top = 7.0
88
-margin_right = 218.0
89
-margin_bottom = 21.0
90
-text = "  Seconds"
34
+[node name="TitleLabel" parent="PanelContainer/MarginContainer/VBoxContainer/Header/TitleHBoxContainer/TitleMarginContainer" index="0"]
35
+margin_right = 34.0
36
+text = "Wait"
91 37
 
92
-[node name="Preview" type="Label" parent="PanelContainer/VBoxContainer/Header"]
93
-margin_left = 222.0
94
-margin_top = 7.0
95
-margin_right = 222.0
96
-margin_bottom = 21.0
97
-custom_colors/font_color = Color( 1, 1, 1, 0.513726 )
38
+[node name="VSeparator2" parent="PanelContainer/MarginContainer/VBoxContainer/Header/TitleHBoxContainer" index="2"]
39
+margin_left = 51.0
40
+margin_right = 55.0
98 41
 
99
-[node name="Spacer" parent="PanelContainer/VBoxContainer/Header" instance=ExtResource( 3 )]
100
-margin_left = 226.0
101
-margin_right = 941.0
102
-margin_bottom = 28.0
42
+[node name="Content" parent="PanelContainer/MarginContainer/VBoxContainer/Header" index="2"]
43
+margin_left = 100.0
44
+margin_right = 249.0
103 45
 
104
-[node name="OptionButton" parent="PanelContainer/VBoxContainer/Header" instance=ExtResource( 4 )]
105
-margin_left = 945.0
106
-margin_right = 982.0
107
-margin_bottom = 28.0
108
-items = [ "Move Up", null, 0, false, false, 0, 0, null, "", false, "Move Down", null, 0, false, false, 1, 0, null, "", false, "", null, 0, false, false, 2, 0, null, "", true, "Remove", null, 0, false, false, 3, 0, null, "", false ]
46
+[node name="Spacer" parent="PanelContainer/MarginContainer/VBoxContainer/Header" index="4"]
47
+margin_left = 253.0
109 48
 
110
-[connection signal="value_changed" from="PanelContainer/VBoxContainer/Header/SpinBox" to="." method="_on_SpinBox_value_changed"]
49
+[node name="OptionsControl" parent="PanelContainer/MarginContainer/VBoxContainer/Header" index="6"]
50
+items = [ "Move Up", null, 0, false, false, 0, 0, null, "", false, "Move Down", null, 0, false, false, 1, 0, null, "", false, "", null, 0, false, false, 2, 0, null, "", false, "Remove", null, 0, false, false, 3, 0, null, "", false ]

+ 4
- 0
addons/dialogic/Editor/Events/styles/ChangeBackground.tres View File

@@ -1,6 +1,10 @@
1 1
 [gd_resource type="StyleBoxFlat" format=2]
2 2
 
3 3
 [resource]
4
+content_margin_left = 0.0
5
+content_margin_right = 0.0
6
+content_margin_top = 0.0
7
+content_margin_bottom = 0.0
4 8
 bg_color = Color( 0.219608, 0.34902, 0.701961, 0.443137 )
5 9
 border_width_left = 2
6 10
 border_width_top = 2

+ 17
- 0
addons/dialogic/Editor/Events/styles/WaitSeconds.tres View File

@@ -0,0 +1,17 @@
1
+[gd_resource type="StyleBoxFlat" format=2]
2
+
3
+[resource]
4
+content_margin_left = 0.0
5
+content_margin_right = 0.0
6
+content_margin_top = 0.0
7
+content_margin_bottom = 0.0
8
+bg_color = Color( 0.435294, 0.301961, 0.603922, 0.192157 )
9
+border_width_left = 2
10
+border_width_top = 2
11
+border_width_right = 2
12
+border_width_bottom = 2
13
+border_color = Color( 0.12549, 0.12549, 0.12549, 1 )
14
+corner_radius_top_left = 6
15
+corner_radius_top_right = 6
16
+corner_radius_bottom_right = 6
17
+corner_radius_bottom_left = 6

+ 4
- 0
addons/dialogic/Editor/Events/styles/selected_styleboxflat_template.tres View File

@@ -1,6 +1,10 @@
1 1
 [gd_resource type="StyleBoxFlat" format=2]
2 2
 
3 3
 [resource]
4
+content_margin_left = 0.0
5
+content_margin_right = 0.0
6
+content_margin_top = 0.0
7
+content_margin_bottom = 0.0
4 8
 bg_color = Color( 0.0980392, 0.329412, 0.509804, 1 )
5 9
 border_width_left = 2
6 10
 border_width_top = 2

+ 1
- 1
addons/dialogic/Editor/TimelineEditor/TimelineEditor.gd View File

@@ -22,7 +22,7 @@ var moving_piece = null
22 22
 var piece_was_dragged = false
23 23
 
24 24
 func _has_template(event):
25
-	return event.event_data.has("background")
25
+	return event.event_data.has("background") or event.event_data.has("wait_seconds")
26 26
 
27 27
 
28 28
 func _ready():

+ 19
- 12
addons/dialogic/Nodes/dialog_node.gd View File

@@ -15,6 +15,7 @@ var definition_visible: bool = false
15 15
 var settings: ConfigFile
16 16
 var current_theme: ConfigFile
17 17
 var current_timeline: String = ''
18
+var current_event: Dictionary
18 19
 
19 20
 ## The timeline to load when starting the scene
20 21
 export(String, "TimelineDropdown") var timeline: String
@@ -103,9 +104,15 @@ func resize_main():
103 104
 	if current_theme != null:
104 105
 		$TextBubble.rect_position.y = (reference.y) - ($TextBubble.rect_size.y) - current_theme.get_value('box', 'bottom_gap', 40)
105 106
 	
107
+	
106 108
 	var background = get_node_or_null('Background')
107 109
 	if background != null:
108 110
 		background.rect_size = reference
111
+	
112
+	var portraits = get_node_or_null('Portraits')
113
+	if portraits != null:
114
+		portraits.rect_position.x = reference.x / 2
115
+		portraits.rect_position.y = reference.y
109 116
 
110 117
 
111 118
 func set_current_dialog(dialog_path: String):
@@ -160,19 +167,17 @@ func parse_text_lines(unparsed_dialog_script: Dictionary) -> Dictionary:
160 167
 	# Parsing
161 168
 	for event in unparsed_dialog_script['events']:
162 169
 		if event.has('text') and event.has('character') and event.has('portrait'):
163
-			if event['text'] == '' and remove_empty_messages == true:
170
+			if event['text'].empty() and remove_empty_messages == true:
164 171
 				pass
165 172
 			elif '\n' in event['text'] and preview == false and split_new_lines == true:
166 173
 				var lines = event['text'].split('\n')
167
-				var i = 0
168 174
 				for line in lines:
169
-					var _e = {
170
-						'text': lines[i],
171
-						'character': event['character'],
172
-						'portrait': event['portrait']
173
-					}
174
-					new_events.append(_e)
175
-					i += 1
175
+					if not line.empty():
176
+						new_events.append({
177
+							'text': line,
178
+							'character': event['character'],
179
+							'portrait': event['portrait']
180
+						})
176 181
 			else:
177 182
 				new_events.append(event)
178 183
 		else:
@@ -340,6 +345,10 @@ func update_text(text: String) -> String:
340 345
 
341 346
 func _on_text_completed():
342 347
 	finished = true
348
+	if current_event.has('options'):
349
+		for o in current_event['options']:
350
+			add_choice_button(o)
351
+
343 352
 
344 353
 func on_timeline_start():
345 354
 	if not Engine.is_editor_hint():
@@ -423,6 +432,7 @@ func event_handler(event: Dictionary):
423 432
 	reset_options()
424 433
 	
425 434
 	dprint('[D] Current Event: ', event)
435
+	current_event = event
426 436
 	match event:
427 437
 		{'text', 'character', 'portrait'}:
428 438
 			emit_signal("event_start", "text", event)
@@ -444,9 +454,6 @@ func event_handler(event: Dictionary):
444 454
 				update_name(character_data)
445 455
 				grab_portrait_focus(character_data, event)
446 456
 			update_text(event['question'])
447
-			if event.has('options'):
448
-				for o in event['options']:
449
-					add_choice_button(o)
450 457
 		{'choice', 'question_id'}:
451 458
 			emit_signal("event_start", "choice", event)
452 459
 			for q in questions:

Loading…
Cancel
Save