Skip to content

Commit dcf0038

Browse files
Fixes for 4.2, textbubble, missing audio files and cleanup (#2532)
* Make sure missing audio files don't crash * Small cleanup * Allow get_editor_scale to function in game * Small textbubble layout improvements Reduced the movement that the textbubbles do on every new text. * Fixes for 4.2 compatibility * Bump required godot version to 4.2.2
1 parent acdcc14 commit dcf0038

File tree

10 files changed

+36
-28
lines changed

10 files changed

+36
-28
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
## Version
2828

29-
Dialogic 2 **requires at least Godot 4.2**.
29+
Dialogic 2 **requires at least Godot 4.2.2**.
3030

3131
[If you are looking for the Godot 3.x version (Dialogic 1.x) you can find it here.](https://github.com/dialogic-godot/dialogic-1)
3232

addons/dialogic/Core/DialogicGameHandler.gd

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ var Choices := preload("res://addons/dialogic/Modules/Choice/subsystem_choices.g
110110
var Expressions := preload("res://addons/dialogic/Modules/Core/subsystem_expression.gd").new():
111111
get: return get_subsystem("Expressions")
112112

113-
114113
var Glossary := preload("res://addons/dialogic/Modules/Glossary/subsystem_glossary.gd").new():
115114
get: return get_subsystem("Glossary")
116115

addons/dialogic/Core/DialogicUtil.gd

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ class_name DialogicUtil
99
## This method should be used instead of EditorInterface.get_editor_scale(), because if you use that
1010
## it will run perfectly fine from the editor, but crash when the game is exported.
1111
static func get_editor_scale() -> float:
12-
return get_dialogic_plugin().get_editor_interface().get_editor_scale()
12+
if Engine.is_editor_hint():
13+
return get_dialogic_plugin().get_editor_interface().get_editor_scale()
14+
return 1.0
1315

1416

1517
## Although this does in fact always return a EditorPlugin node,

addons/dialogic/Editor/Common/toolbar.gd

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extends HBoxContainer
44
# Dialogic Editor toolbar. Works together with editors_mangager.
55

66
################################################################################
7-
## EDITOR BUTTONS/LABELS
7+
## EDITOR BUTTONS/LABELS
88
################################################################################
99
func _ready() -> void:
1010
if owner.get_parent() is SubViewport:
@@ -44,6 +44,3 @@ func add_custom_button(label:String, icon:Texture) -> Button:
4444
func hide_all_custom_buttons() -> void:
4545
for button in %CustomButtons.get_children():
4646
button.hide()
47-
48-
49-

addons/dialogic/Editor/Settings/CoreSettingsPages/settings_general.tscn

-5
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ script = ExtResource("3_dbfvv")
3232
unique_name_in_owner = true
3333
layout_mode = 2
3434

35-
[node name="ResaveTool" type="Button" parent="ToolButtons"]
36-
layout_mode = 2
37-
text = "Resave all timelines"
38-
3935
[node name="ToolProgress" type="ProgressBar" parent="."]
4036
unique_name_in_owner = true
4137
visible = false
@@ -232,7 +228,6 @@ text = "Process timers in physics_process"
232228
unique_name_in_owner = true
233229
layout_mode = 2
234230

235-
[connection signal="pressed" from="ToolButtons/ResaveTool" to="." method="_on_resave_tool_pressed"]
236231
[connection signal="item_selected" from="HBoxContainer3/LayoutNodeEndBehaviour" to="." method="_on_layout_node_end_behaviour_item_selected"]
237232
[connection signal="pressed" from="HBoxContainer6/HBoxContainer4/HBoxContainer5/Reload" to="." method="_on_reload_pressed"]
238233
[connection signal="pressed" from="HBoxContainer6/ExtensionsPanel/VBox/CreateExtensionButton" to="." method="_on_create_extension_button_pressed"]

addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd

+17-11
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,22 @@ func _gui_input(event):
7979
match event.as_text():
8080
"Ctrl+K":
8181
toggle_comment()
82+
83+
# TODO clean this up when dropping 4.2 support
8284
"Alt+Up":
83-
move_lines_up()
85+
if has_method("move_lines_up"):
86+
call("move_lines_up")
8487
"Alt+Down":
85-
move_lines_down()
88+
if has_method("move_lines_down"):
89+
call("move_lines_down")
90+
8691
"Ctrl+Shift+D", "Ctrl+D":
8792
duplicate_lines()
8893
_:
8994
return
9095
get_viewport().set_input_as_handled()
9196

97+
9298
# Toggle the selected lines as comments
9399
func toggle_comment() -> void:
94100
var cursor: Vector2 = Vector2(get_caret_column(), get_caret_line())
@@ -128,14 +134,14 @@ func toggle_comment() -> void:
128134
text_changed.emit()
129135

130136

131-
# Allows dragging files into the editor
137+
## Allows dragging files into the editor
132138
func _can_drop_data(at_position:Vector2, data:Variant) -> bool:
133139
if typeof(data) == TYPE_DICTIONARY and 'files' in data.keys() and len(data.files) == 1:
134140
return true
135141
return false
136142

137143

138-
# Allows dragging files into the editor
144+
## Allows dragging files into the editor
139145
func _drop_data(at_position:Vector2, data:Variant) -> void:
140146
if typeof(data) == TYPE_DICTIONARY and 'files' in data.keys() and len(data.files) == 1:
141147
set_caret_column(get_line_column_at_pos(at_position).x)
@@ -232,19 +238,19 @@ func search_navigate(navigate_up := false) -> void:
232238
## AUTO COMPLETION
233239
################################################################################
234240

235-
# Called if something was typed
241+
## Called if something was typed
236242
func _request_code_completion(force:bool):
237243
code_completion_helper.request_code_completion(force, self)
238244

239245

240-
# Filters the list of all possible options, depending on what was typed
241-
# Purpose of the different Kinds is explained in [_request_code_completion]
246+
## Filters the list of all possible options, depending on what was typed
247+
## Purpose of the different Kinds is explained in [_request_code_completion]
242248
func _filter_code_completion_candidates(candidates:Array) -> Array:
243249
return code_completion_helper.filter_code_completion_candidates(candidates, self)
244250

245251

246-
# Called when code completion was activated
247-
# Inserts the selected item
252+
## Called when code completion was activated
253+
## Inserts the selected item
248254
func _confirm_code_completion(replace:bool) -> void:
249255
code_completion_helper.confirm_code_completion(replace, self)
250256

@@ -253,11 +259,11 @@ func _confirm_code_completion(replace:bool) -> void:
253259
## SYMBOL CLICKING
254260
################################################################################
255261

256-
# Performs an action (like opening a link) when a valid symbol was clicked
262+
## Performs an action (like opening a link) when a valid symbol was clicked
257263
func _on_symbol_lookup(symbol, line, column):
258264
code_completion_helper.symbol_lookup(symbol, line, column)
259265

260266

261-
# Called to test if a symbol can be clicked
267+
## Called to test if a symbol can be clicked
262268
func _on_symbol_validate(symbol:String) -> void:
263269
code_completion_helper.symbol_validate(symbol, self)

addons/dialogic/Modules/Audio/event_audio.gd

+3-2
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,9 @@ func get_audio_channel_suggestions(filter:String) -> Dictionary:
346346
"tooltip": "Used for one shot sounds effects. Plays each sound in its own AudioStreamPlayer.",
347347
"editor_icon": ["GuiRadioUnchecked", "EditorIcons"]
348348
}
349-
return suggestions.merged(DialogicUtil.get_audio_channel_suggestions(filter))
350-
349+
# TODO use .merged after dropping 4.2 support
350+
suggestions.merge(DialogicUtil.get_audio_channel_suggestions(filter))
351+
return suggestions
351352

352353
func get_sync_audio_channel_suggestions(filter:="") -> Dictionary:
353354
return DialogicUtil.get_audio_channel_suggestions(filter)

addons/dialogic/Modules/Audio/subsystem_audio.gd

+8-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ func update_audio(channel_name:= "", path := "", settings_overrides := {}) -> vo
9898
return
9999

100100
## Determine audio settings
101-
var audio_settings: Dictionary = DialogicUtil.get_audio_channel_defaults().get(channel_name, {}).merged(
101+
## TODO use .merged after dropping 4.2 support
102+
var audio_settings: Dictionary = DialogicUtil.get_audio_channel_defaults().get(channel_name, {})
103+
audio_settings.merge(
102104
{"volume":0, "audio_bus":"", "fade_length":0.0, "loop":false, "sync_channel":""}
103105
)
104106
audio_settings.merge(settings_overrides, true)
@@ -138,6 +140,11 @@ func update_audio(channel_name:= "", path := "", settings_overrides := {}) -> vo
138140
new_player.name = "OneShotSFX"
139141
one_shot_audio_node.add_child(new_player)
140142

143+
var file := load(path)
144+
if file == null:
145+
printerr("[Dialogic] Audio file \"%s\" failed to load." % path)
146+
return
147+
141148
new_player.stream = load(path)
142149

143150
## Apply audio settings

addons/dialogic/Modules/DefaultLayoutParts/Base_TextBubble/text_bubble_base.gd

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ func _on_dialogic_text_event(info:Dictionary):
8282

8383
bubble_to_use.current_character = info.character
8484
bubble_to_use.node_to_point_at = node_to_point_at
85-
bubble_to_use.reset()
85+
if not bubble_to_use.visible:
86+
bubble_to_use.reset()
8687
if has_node('TextBubbleLayer'):
8788
get_node("TextBubbleLayer").bubble_apply_overrides(bubble_to_use)
8889
bubble_to_use.open()

addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func reset() -> void:
4242
tail.points = []
4343
bubble_rect = Rect2(0,0,2,2)
4444

45-
base_position = get_speaker_canvas_position()
45+
base_position = get_speaker_canvas_position() + base_direction * safe_zone
4646
position = base_position
4747

4848

0 commit comments

Comments
 (0)