Skip to content

Commit f9b8a6c

Browse files
Make sure character picker is updated when characters are added (#1951)
Useful for first impressions ;)
1 parent efed727 commit f9b8a6c

File tree

7 files changed

+19
-8
lines changed

7 files changed

+19
-8
lines changed

addons/dialogic/Editor/Events/EventBlock/event_block.gd

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
262262

263263
### --------------------------------------------------------------------
264264
### 2. ADD IT TO THE RIGHT PLACE (HEADER/BODY)
265-
var location :Control = %HeaderContent
265+
var location: Control = %HeaderContent
266266
if p.location == 1:
267267
location = current_body_container
268268
location.add_child(editor_node)
@@ -280,8 +280,8 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
280280
if editor_node.has_signal('value_changed'):
281281
editor_node.value_changed.connect(set_property)
282282
editor_node.tooltip_text = p.display_info.get('tooltip', '')
283-
var left_label :Label = null
284-
var right_label :Label = null
283+
var left_label: Label = null
284+
var right_label: Label = null
285285
if !p.get('left_text', '').is_empty():
286286
left_label = Label.new()
287287
left_label.text = p.get('left_text')
@@ -310,9 +310,7 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
310310
editor_node.call_deferred('take_autofocus')
311311

312312
if build_body:
313-
# has_body_content = true
314313
if current_body_container.get_child_count() == 0:
315-
# has_body_content = false
316314
expanded = false
317315
body_container.visible = false
318316

@@ -352,8 +350,9 @@ func set_property(property_name:String, value:Variant) -> void:
352350

353351
func _on_resource_ui_update_needed() -> void:
354352
for node_info in field_list:
355-
if node_info.node.has_method('set_value'):
353+
if node_info.node and node_info.node.has_method('set_value'):
356354
node_info.node.set_value(resource.get(node_info.property))
355+
recalculate_field_visibility()
357356

358357

359358
func _update_color() -> void:

addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ func add_event_node(event_resource:DialogicEvent, at_index:int = -1, auto_select
335335
var piece :Control = event_node.instantiate()
336336
piece.resource = event_resource
337337
event_resource._editor_node = piece
338+
event_resource._enter_visual_editor(timeline_editor)
338339
piece.content_changed.connect(something_changed)
340+
339341
if event_resource.event_name == "Label":
340342
piece.content_changed.connect(update_content_list)
341343
if at_index == -1:

addons/dialogic/Editor/dialogic_editor.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ extends Control
88
signal resource_saved()
99
signal resource_unsaved()
1010

11+
signal opened
12+
1113
var current_resource: Resource
1214

1315
## State of the current resource

addons/dialogic/Editor/editors_manager.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func open_editor(editor:DialogicEditor, save_previous: bool = true, extra_info:V
160160
previous_editor = current_editor
161161

162162
editor._open(extra_info)
163+
editor.opened.emit()
163164
current_editor = editor
164165
editor.show()
165166
tabbar.current_tab = editor.get_index()

addons/dialogic/Modules/Text/event_text.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ func _get_property_original_translation(property:String) -> String:
326326
## EVENT EDITOR
327327
################################################################################
328328

329+
func _enter_visual_editor(editor:DialogicEditor):
330+
editor.opened.connect(func(): ui_update_needed.emit())
331+
332+
329333
func build_event_editor():
330334
add_header_edit('character_identifier', ValueType.COMPLEX_PICKER,
331335
{'file_extension' : '.dch',

addons/dialogic/Other/DialogicResourceUtil.gd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ class_name DialogicResourceUtil
44
static var label_cache := {}
55
static var event_cache: Array[DialogicEvent] = []
66

7-
87
static func update() -> void:
98
update_directory('.dch')
109
update_directory('.dtl')
@@ -52,7 +51,6 @@ static func add_resource_to_directory(file_path:String, directory:Dictionary) ->
5251
var suggested_name := file_path.get_file().trim_suffix("."+file_path.get_extension())
5352
while suggested_name in directory:
5453
suggested_name = file_path.trim_suffix("/"+suggested_name+"."+file_path.get_extension()).get_file().path_join(suggested_name)
55-
5654
directory[suggested_name] = file_path
5755
return directory
5856

@@ -97,6 +95,7 @@ static func remove_resource(file_path:String) -> void:
9795
var key := directory.find_key(file_path)
9896
while key != null:
9997
directory.erase(key)
98+
key = directory.find_key(file_path)
10099
set_directory(file_path.get_extension(), directory)
101100

102101
static func is_identifier_unused(extension:String, identifier:String) -> bool:

addons/dialogic/Resources/event.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ func set_default_color(value) -> void:
359359
event_color = DialogicUtil.get_color(value)
360360

361361

362+
## Called when the resource is assigned to a event block in the visual editor
363+
func _enter_visual_editor(timeline_editor:DialogicEditor) -> void:
364+
pass
365+
362366
####################### CODE COMPLETION ########################################
363367
################################################################################
364368

0 commit comments

Comments
 (0)