Skip to content

Commit e098088

Browse files
Various Fixes (#2564)
Through some extensive testing, all of these issues were found and removed: - Background Transitions being broken in export - Backgrounds broken when quickly skipping - Remove warning on container sizes - Suggest fade and fade_length in character update event (text editor) - Improve/Fix fading on portraits and mirrored portraits - Fix warning about character suffix/prefix - Fix weird headings in portrait settings - Slightly improve character suggestions (text editor) - Avoid a bunch of unnecessary warnings - Fix character styles not loading - Performance improvements (hopefully) and introduction of DialogicStylesUtil - Enabled folding gutter in text editor - Improve auto-indentation in text editor - Update unit tests to be using godot 4.3 and work again
1 parent 29b45af commit e098088

40 files changed

+283
-163
lines changed

.github/workflows/unit_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
# Insert here the Godot version you want to run your tests with.
25-
godot-version: ['4.2.1']
25+
godot-version: ['4.3']
2626

2727
name: "CI Unit Test v${{ matrix.godot-version }}"
2828
runs-on: 'ubuntu-22.04'

Tests/Unit/glossary_resource_test.gd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const NAME_ENTRY := "Example Name"
66
const EXAMPLE_TITLE := "Example Title"
77
const ALTERNATIVE_ENTRIES := ["A", "BE", "VERY LONG ENTRY"]
88

9-
const SAMPLE_ENTRY := {
9+
var SAMPLE_ENTRY := {
1010
DialogicGlossary.TITLE_PROPERTY: EXAMPLE_TITLE,
1111
DialogicGlossary.NAME_PROPERTY: NAME_ENTRY,
1212
DialogicGlossary.ALTERNATIVE_PROPERTY: ALTERNATIVE_ENTRIES
@@ -18,7 +18,7 @@ const SAMPLE_ENTRY := {
1818
func test_add_entry() -> void:
1919
var glossary: DialogicGlossary = DialogicGlossary.new()
2020

21-
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
21+
assert(glossary.try_add_entry(SAMPLE_ENTRY.duplicate()), "Unable to add entry.")
2222

2323
const NAME_COUNTER := 1
2424
var total_entry_count := ALTERNATIVE_ENTRIES.size() + NAME_COUNTER
@@ -36,7 +36,7 @@ func test_add_entry() -> void:
3636
func test_replace_entries() -> void:
3737
var glossary: DialogicGlossary = DialogicGlossary.new()
3838

39-
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
39+
assert(glossary.try_add_entry(SAMPLE_ENTRY.duplicate()), "Unable to add entry.")
4040

4141
const NEW_NAME := "NEW NAME"
4242

@@ -55,7 +55,7 @@ func test_replace_entries() -> void:
5555
func test_remove_entry() -> void:
5656
var glossary: DialogicGlossary = DialogicGlossary.new()
5757

58-
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
58+
assert(glossary.try_add_entry(SAMPLE_ENTRY.duplicate()), "Unable to add entry.")
5959

6060
const NAME_COUNTER := 1
6161
var total_entry_count := ALTERNATIVE_ENTRIES.size() + NAME_COUNTER
@@ -72,5 +72,5 @@ func test_remove_entry() -> void:
7272
func test_add_duplicates() -> void:
7373
var glossary: DialogicGlossary = DialogicGlossary.new()
7474

75-
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
76-
assert(not glossary.try_add_entry(SAMPLE_ENTRY), "Entry should not have been added.")
75+
assert(glossary.try_add_entry(SAMPLE_ENTRY.duplicate()), "Unable to add entry.")
76+
assert(not glossary.try_add_entry(SAMPLE_ENTRY.duplicate()), "Entry should not have been added.")

addons/dialogic/Core/DialogicGameHandler.gd

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ signal timeline_ended
9191
signal event_handled(resource: DialogicEvent)
9292

9393
## Emitted when a [class SignalEvent] event was reached.
94+
@warning_ignore("unused_signal") # This is emitted by the signal event.
9495
signal signal_event(argument: Variant)
96+
9597
## Emitted when a signal event gets fired from a [class TextEvent] event.
98+
@warning_ignore("unused_signal") # This is emitted by the text subsystem.
9699
signal text_signal(argument: String)
97100

98101

@@ -162,6 +165,8 @@ func _ready() -> void:
162165

163166
clear()
164167

168+
DialogicResourceUtil.update_event_cache()
169+
165170
dialog_ending_timeline = DialogicTimeline.new()
166171
dialog_ending_timeline.from_text("[clear]")
167172

@@ -204,10 +209,10 @@ func start_timeline(timeline:Variant, label_or_idx:Variant = "") -> void:
204209
# load the resource if only the path is given
205210
if typeof(timeline) == TYPE_STRING:
206211
#check the lookup table if it's not a full file name
207-
if (timeline as String).contains("res://") or (timeline as String).contains("uid://"):
208-
timeline = load((timeline as String))
212+
if "://" in timeline:
213+
timeline = load(timeline)
209214
else:
210-
timeline = DialogicResourceUtil.get_timeline_resource((timeline as String))
215+
timeline = DialogicResourceUtil.get_timeline_resource(timeline)
211216

212217
if timeline == null:
213218
printerr("[Dialogic] There was an error loading this timeline. Check the filename, and the timeline for errors")
@@ -228,10 +233,10 @@ func start_timeline(timeline:Variant, label_or_idx:Variant = "") -> void:
228233
elif typeof(label_or_idx) == TYPE_INT:
229234
if label_or_idx >-1:
230235
current_event_idx = label_or_idx -1
231-
236+
232237
if not current_timeline == dialog_ending_timeline:
233238
timeline_started.emit()
234-
239+
235240
handle_next_event()
236241

237242

@@ -240,7 +245,11 @@ func start_timeline(timeline:Variant, label_or_idx:Variant = "") -> void:
240245
func preload_timeline(timeline_resource:Variant) -> Variant:
241246
# I think ideally this should be on a new thread, will test
242247
if typeof(timeline_resource) == TYPE_STRING:
243-
timeline_resource = load((timeline_resource as String))
248+
if "://" in timeline_resource:
249+
timeline_resource = load(timeline_resource)
250+
else:
251+
timeline_resource = DialogicResourceUtil.get_timeline_resource(timeline_resource)
252+
244253
if timeline_resource == null:
245254
printerr("[Dialogic] There was an error preloading this timeline. Check the filename, and the timeline for errors")
246255
return null

addons/dialogic/Core/DialogicResourceUtil.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ static func update() -> void:
1313
update_directory('.dtl')
1414
update_label_cache()
1515
update_audio_channel_cache()
16+
DialogicStylesUtil.update_style_directory()
1617

1718

1819
#region RESOURCE DIRECTORIES

addons/dialogic/Core/DialogicUtil.gd

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@ static func _update_autoload_subsystem_access() -> void:
100100

101101

102102
static func get_indexers(include_custom := true, force_reload := false) -> Array[DialogicIndexer]:
103-
if Engine.get_main_loop().has_meta('dialogic_indexers') and !force_reload:
103+
if Engine.get_main_loop().has_meta('dialogic_indexers') and not force_reload:
104104
return Engine.get_main_loop().get_meta('dialogic_indexers')
105105

106106
var indexers: Array[DialogicIndexer] = []
107-
108107
for file in listdir(DialogicUtil.get_module_path(''), false):
109108
var possible_script: String = DialogicUtil.get_module_path(file).path_join("index.gd")
110109
if ResourceLoader.exists(possible_script):
@@ -297,40 +296,6 @@ static func _get_value_in_dictionary(path:String, dictionary:Dictionary, default
297296
#endregion
298297

299298

300-
301-
#region STYLES
302-
################################################################################
303-
304-
static func get_default_layout_base() -> PackedScene:
305-
return load(DialogicUtil.get_module_path('DefaultLayoutParts').path_join("Base_Default/default_layout_base.tscn"))
306-
307-
308-
static func get_fallback_style() -> DialogicStyle:
309-
return load(DialogicUtil.get_module_path('DefaultLayoutParts').path_join("Style_VN_Default/default_vn_style.tres"))
310-
311-
312-
static func get_default_style() -> DialogicStyle:
313-
var default: String = ProjectSettings.get_setting('dialogic/layout/default_style', '')
314-
if !ResourceLoader.exists(default):
315-
return get_fallback_style()
316-
return load(default)
317-
318-
319-
static func get_style_by_name(name:String) -> DialogicStyle:
320-
if name.is_empty():
321-
return get_default_style()
322-
323-
var styles: Array = ProjectSettings.get_setting('dialogic/layout/style_list', [])
324-
for style in styles:
325-
if not ResourceLoader.exists(style):
326-
continue
327-
if load(style).name == name:
328-
return load(style)
329-
330-
return get_default_style()
331-
#endregion
332-
333-
334299
#region SCENE EXPORT OVERRIDES
335300
################################################################################
336301

@@ -692,9 +657,9 @@ static func get_autoload_suggestions(filter:String="") -> Dictionary:
692657

693658
for prop in ProjectSettings.get_property_list():
694659
if prop.name.begins_with('autoload/'):
695-
var autoload: String = prop.name.trim_prefix('autoload/')
696-
suggestions[autoload] = {'value': autoload, 'tooltip':autoload, 'editor_icon': ["Node", "EditorIcons"]}
697-
if filter.begins_with(autoload):
660+
var some_autoload: String = prop.name.trim_prefix('autoload/')
661+
suggestions[some_autoload] = {'value': some_autoload, 'tooltip':some_autoload, 'editor_icon': ["Node", "EditorIcons"]}
662+
if filter.begins_with(some_autoload):
698663
suggestions[filter] = {'value': filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]}
699664
return suggestions
700665

@@ -729,7 +694,7 @@ static func get_autoload_method_suggestions(filter:String, autoload_name:String)
729694
return suggestions
730695

731696

732-
static func get_autoload_property_suggestions(filter:String, autoload_name:String) -> Dictionary:
697+
static func get_autoload_property_suggestions(_filter:String, autoload_name:String) -> Dictionary:
733698
var suggestions := {}
734699
var script := get_autoload_script_resource(autoload_name)
735700
if script:
@@ -741,7 +706,7 @@ static func get_autoload_property_suggestions(filter:String, autoload_name:Strin
741706
return suggestions
742707

743708

744-
static func get_audio_bus_suggestions(filter:= "") -> Dictionary:
709+
static func get_audio_bus_suggestions(_filter:= "") -> Dictionary:
745710
var bus_name_list := {}
746711
for i in range(AudioServer.bus_count):
747712
if i == 0:
@@ -751,9 +716,7 @@ static func get_audio_bus_suggestions(filter:= "") -> Dictionary:
751716
return bus_name_list
752717

753718

754-
static func get_audio_channel_suggestions(search_text:String) -> Dictionary:
755-
756-
719+
static func get_audio_channel_suggestions(_search_text:String) -> Dictionary:
757720
var suggestions := {}
758721
var channel_defaults := DialogicUtil.get_audio_channel_defaults()
759722
var cached_names := DialogicResourceUtil.get_channel_list()

addons/dialogic/Core/index_class.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func list_dir(subdir:='') -> Array:
7878
func list_special_resources(subdir:='', extension:="") -> Dictionary:
7979
var dict := {}
8080
for i in list_dir(subdir):
81-
if extension.is_empty() or i.ends_with(extension):
81+
if extension.is_empty() or i.ends_with(extension) or (extension == ".gd" and i.ends_with(".gdc")):
8282
dict[DialogicUtil.pretty_name(i).to_lower()] = {"path":i}
8383
return dict
8484

addons/dialogic/Editor/CharacterEditor/character_editor_main_settings_section.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ extends Control
55
## Base class for all character editor main sections. Methods should be overriden.
66

77
## Emit this, if something changed
8+
@warning_ignore("unused_signal") # this is used by extending scripts
89
signal changed
910

1011
## Reference to the character editor, set when instantiated
@@ -30,7 +31,7 @@ func _start_opened() -> bool:
3031

3132

3233
## Overwrite to load all the information from the character into this section.
33-
func _load_character(resource:DialogicCharacter) -> void:
34+
func _load_character(_resource:DialogicCharacter) -> void:
3435
pass
3536

3637

addons/dialogic/Editor/CharacterEditor/character_prefix_suffix.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func _load_prefix_data(data: Dictionary) -> void:
6969

7070
## Whenever the user makes a save to the character, we save the prefix and suffix.
7171
func _save_changes(character: DialogicCharacter) -> DialogicCharacter:
72-
if not character.custom_info:
72+
if not character:
7373
printerr("[Dialogic] Unable to save Prefix and Suffix, the character is missing.")
7474
return character
7575

addons/dialogic/Editor/Events/Fields/dictionary_part.gd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ func _on_flex_value_value_changed() -> void:
4141
func _on_delete_pressed() -> void:
4242
queue_free()
4343
value_changed.emit()
44-

addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func change_to_empty() -> void:
127127

128128
func validate() -> void:
129129
if mode == Modes.ANY_VALID_STRING and validation_func:
130-
var validation_result := validation_func.call(current_value)
130+
var validation_result: Dictionary = validation_func.call(current_value)
131131
current_value = validation_result.get('valid_text', current_value)
132132
update_error_tooltip(validation_result.get('error_tooltip', ''))
133133

@@ -152,7 +152,7 @@ func update_error_tooltip(text: String) -> void:
152152
func _on_Search_text_entered(new_text:String) -> void:
153153
if mode == Modes.ANY_VALID_STRING:
154154
if validation_func:
155-
var validation_result := validation_func.call(new_text)
155+
var validation_result: Dictionary = validation_func.call(new_text)
156156
new_text = validation_result.get('valid_text', new_text)
157157
update_error_tooltip(validation_result.get('error_tooltip', ''))
158158

@@ -182,7 +182,7 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void:
182182

183183
if mode == Modes.ANY_VALID_STRING and !just_update:
184184
if validation_func:
185-
var validation_result := validation_func.call(new_text)
185+
var validation_result: Dictionary = validation_func.call(new_text)
186186
new_text = validation_result.get('valid_text', new_text)
187187
update_error_tooltip(validation_result.get('error_tooltip', ''))
188188

@@ -207,9 +207,9 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void:
207207
for element in suggestions:
208208
if new_text.is_empty() or new_text.to_lower() in element.to_lower() or new_text.to_lower() in str(suggestions[element].value).to_lower() or new_text.to_lower() in suggestions[element].get('tooltip', '').to_lower():
209209
var curr_line_length: int = 0
210-
curr_line_length = get_theme_font('font', 'Label').get_string_size(
210+
curr_line_length = int(get_theme_font('font', 'Label').get_string_size(
211211
element, HORIZONTAL_ALIGNMENT_LEFT, -1, get_theme_font_size("font_size", 'Label')
212-
).x
212+
).x)
213213

214214
%Suggestions.add_item(element)
215215
if suggestions[element].has('icon'):
@@ -238,7 +238,7 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void:
238238

239239
var total_height: int = 0
240240
for item in %Suggestions.item_count:
241-
total_height += _line_height * DialogicUtil.get_editor_scale() + _v_separation
241+
total_height += int(_line_height * DialogicUtil.get_editor_scale() + _v_separation)
242242
total_height += _v_separation * 2
243243
if total_height > _max_height:
244244
line_length += %Suggestions.get_v_scroll_bar().get_minimum_size().x
@@ -254,7 +254,7 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void:
254254
%Suggestions.size.x = max(%PanelContainer.size.x, line_length)
255255

256256

257-
func suggestion_selected(index: int, position := Vector2(), button_index := MOUSE_BUTTON_LEFT) -> void:
257+
func suggestion_selected(index: int, _position := Vector2(), button_index := MOUSE_BUTTON_LEFT) -> void:
258258
if button_index != MOUSE_BUTTON_LEFT:
259259
return
260260
if %Suggestions.is_item_disabled(index):
@@ -348,7 +348,7 @@ func _on_search_focus_exited() -> void:
348348
#region DRAG AND DROP
349349
################################################################################
350350

351-
func _can_drop_data(position:Vector2, data:Variant) -> bool:
351+
func _can_drop_data(_position:Vector2, data:Variant) -> bool:
352352
if typeof(data) == TYPE_DICTIONARY and data.has('files') and len(data.files) == 1:
353353
if valid_file_drop_extension:
354354
if data.files[0].ends_with(valid_file_drop_extension):
@@ -358,7 +358,7 @@ func _can_drop_data(position:Vector2, data:Variant) -> bool:
358358
return false
359359

360360

361-
func _drop_data(position:Vector2, data:Variant) -> void:
361+
func _drop_data(_position:Vector2, data:Variant) -> void:
362362
var path := str(data.files[0])
363363
if mode == Modes.IDENTIFIER:
364364
path = DialogicResourceUtil.get_unique_identifier_by_path(path)

0 commit comments

Comments
 (0)