Updated dialogic

This commit is contained in:
MaddoScientisto 2026-01-05 16:00:41 +01:00
commit cbb82512ee
483 changed files with 5743 additions and 2177 deletions

View file

@ -73,7 +73,7 @@ func _open_resource(resource:Resource) -> void:
EditorMode.TEXT:
%TextEditor.load_timeline(current_resource)
$NoTimelineScreen.hide()
%TimelineName.text = DialogicResourceUtil.get_unique_identifier(current_resource.resource_path)
%TimelineName.text = current_resource.get_identifier()
play_timeline_button.disabled = false
@ -100,16 +100,20 @@ func _input(event: InputEvent) -> void:
if is_ancestor_of(get_viewport().gui_get_focus_owner()):
search_timeline()
if event.keycode == KEY_R and event.pressed:
if Input.is_key_pressed(KEY_CTRL):
if is_ancestor_of(get_viewport().gui_get_focus_owner()):
replace_in_timeline(true)
## Method to play the current timeline. Connected to the button in the sidebar.
func play_timeline() -> void:
func play_timeline(index := -1) -> void:
_save()
var dialogic_plugin := DialogicUtil.get_dialogic_plugin()
# Save the current opened timeline
DialogicUtil.set_editor_setting('current_timeline_path', current_resource.resource_path)
DialogicUtil.set_editor_setting('play_from_index', index)
DialogicUtil.get_dialogic_plugin().get_editor_interface().play_custom_scene("res://addons/dialogic/Editor/TimelineEditor/test_timeline_scene.tscn")
@ -118,19 +122,25 @@ func toggle_editor_mode() -> void:
match current_editor_mode:
EditorMode.VISUAL:
current_editor_mode = EditorMode.TEXT
%VisualEditor.save_timeline()
if %VisualEditor.is_loading_timeline():
%VisualEditor.cancel_loading()
else:
%VisualEditor.save_timeline()
%VisualEditor.hide()
%TextEditor.show()
%TextEditor.load_timeline(current_resource)
%SwitchEditorMode.text = "Visual Editor"
_on_search_text_changed(%Search.text)
EditorMode.TEXT:
_on_search_text_changed.bind("")
current_editor_mode = EditorMode.VISUAL
%TextEditor.save_timeline()
%TextEditor.hide()
%VisualEditor.load_timeline(current_resource)
%VisualEditor.show()
%SwitchEditorMode.text = "Text Editor"
_on_search_text_changed(%Search.text)
if not %VisualEditor.timeline_loaded.is_connected(_on_search_text_changed):
%VisualEditor.timeline_loaded.connect(_on_search_text_changed.bind(%Search.text), CONNECT_ONE_SHOT)
DialogicUtil.set_editor_setting('timeline_editor_mode', current_editor_mode)
@ -147,6 +157,9 @@ func _on_resource_saved() -> void:
func new_timeline(path:String) -> void:
_save()
var new_timeline := DialogicTimeline.new()
if not path.ends_with(".dtl"):
path = path.trim_suffix(".")
path += ".dtl"
new_timeline.resource_path = path
new_timeline.set_meta('timeline_not_saved', true)
var err := ResourceSaver.save(new_timeline)
@ -155,6 +168,20 @@ func new_timeline(path:String) -> void:
editors_manager.edit_resource(new_timeline)
func update_audio_channel_cache(list:PackedStringArray) -> void:
var timeline_directory := DialogicResourceUtil.get_timeline_directory()
var channel_directory := DialogicResourceUtil.get_audio_channel_cache()
if current_resource != null:
for i in timeline_directory:
if timeline_directory[i] == current_resource.resource_path:
channel_directory[i] = list
# also always store the current timelines channels for easy access
channel_directory[""] = list
DialogicResourceUtil.set_audio_channel_cache(channel_directory)
func _ready() -> void:
$NoTimelineScreen.add_theme_stylebox_override("panel", get_theme_stylebox("Background", "EditorStyles"))
@ -164,10 +191,19 @@ func _ready() -> void:
%SwitchEditorMode.pressed.connect(toggle_editor_mode)
%SwitchEditorMode.custom_minimum_size.x = 200 * DialogicUtil.get_editor_scale()
%Shortcuts.icon = get_theme_icon("InputEventShortcut", "EditorIcons")
%Shortcuts.pressed.connect(%ShortcutsPanel.open)
%SearchClose.icon = get_theme_icon("Close", "EditorIcons")
%SearchUp.icon = get_theme_icon("MoveUp", "EditorIcons")
%SearchDown.icon = get_theme_icon("MoveDown", "EditorIcons")
%ReplaceGlobal.icon = get_theme_icon("ExternalLink", "EditorIcons")
%ProgressSection.hide()
%SearchReplaceSection.hide()
%SearchReplaceSection.add_theme_stylebox_override("panel", get_theme_stylebox("PanelForeground", "EditorStyles"))
func _on_create_timeline_button_pressed() -> void:
@ -199,24 +235,25 @@ func get_current_editor() -> Node:
#region SEARCH
func search_timeline() -> void:
%SearchReplaceSection.show()
%SearchSection.show()
%ReplaceSection.hide()
if get_viewport().gui_get_focus_owner() is TextEdit:
%Search.text = get_viewport().gui_get_focus_owner().get_selected_text()
_on_search_text_changed(%Search.text)
else:
%Search.text = ""
if get_viewport().gui_get_focus_owner().get_selected_text():
%Search.text = get_viewport().gui_get_focus_owner().get_selected_text()
_on_search_text_changed(%Search.text)
%Search.grab_focus()
func _on_close_search_pressed() -> void:
%SearchSection.hide()
%SearchReplaceSection.hide()
%Search.text = ""
_on_search_text_changed('')
func _on_search_text_changed(new_text: String) -> void:
var editor: Node = null
var anything_found: bool = get_current_editor()._search_timeline(new_text)
var anything_found: bool = get_current_editor()._search_timeline(new_text, %MatchCase.button_pressed, %WholeWords.button_pressed)
if anything_found or new_text.is_empty():
%SearchLabel.hide()
%Search.add_theme_color_override("font_color", get_theme_color("font_color", "Editor"))
@ -234,6 +271,51 @@ func _on_search_down_pressed() -> void:
func _on_search_up_pressed() -> void:
get_current_editor()._search_navigate_up()
func _on_match_case_toggled(toggled_on: bool) -> void:
_on_search_text_changed(%Search.text)
func _on_whole_words_toggled(toggled_on: bool) -> void:
_on_search_text_changed(%Search.text)
#endregion
#region REPLACE
func replace_in_timeline(focus_grab:=false) -> void:
search_timeline()
%ReplaceSection.show()
if focus_grab:
%ReplaceText.grab_focus()
%ReplaceText.select_all()
func _on_replace_button_pressed() -> void:
get_current_editor().replace(%ReplaceText.text)
func _on_replace_all_button_pressed() -> void:
get_current_editor().replace_all(%ReplaceText.text)
func _on_replace_global_pressed() -> void:
editors_manager.reference_manager.add_ref_change(%Search.text, %ReplaceText.text, 0, 0, [],
%WholeWords.button_pressed, %MatchCase.button_pressed)
editors_manager.reference_manager.open()
#endregion
#region PROGRESS
func set_progress(percentage:float, text := "") -> void:
%ProgressSection.visible = percentage != 1
%ProgressBar.value = percentage
%ProgressLabel.text = text
%ProgressLabel.visible = not text.is_empty()
#endregion