From ab10f5781136dedf825808513edf8a6dffba31e6 Mon Sep 17 00:00:00 2001 From: elle Date: Tue, 17 Sep 2024 15:20:04 +0930 Subject: [PATCH] Tag dtl and dch files with their resource class --- .../Editor/CharacterEditor/character_editor.gd | 1 + .../dialogic/Editor/TimelineEditor/timeline_editor.gd | 1 + addons/dialogic/Resources/CharacterResourceLoader.gd | 11 ++++++++++- addons/dialogic/Resources/TimelineResourceLoader.gd | 11 ++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/addons/dialogic/Editor/CharacterEditor/character_editor.gd b/addons/dialogic/Editor/CharacterEditor/character_editor.gd index cc635cf52..55c14273b 100644 --- a/addons/dialogic/Editor/CharacterEditor/character_editor.gd +++ b/addons/dialogic/Editor/CharacterEditor/character_editor.gd @@ -126,6 +126,7 @@ func new_character(path: String) -> void: resource.default_portrait = "" resource.custom_info = {} ResourceSaver.save(resource, path) + EditorInterface.get_resource_filesystem().update_file(path) DialogicResourceUtil.update_directory('dch') editors_manager.edit_resource(resource) diff --git a/addons/dialogic/Editor/TimelineEditor/timeline_editor.gd b/addons/dialogic/Editor/TimelineEditor/timeline_editor.gd index e5302a7ee..ab6538b55 100644 --- a/addons/dialogic/Editor/TimelineEditor/timeline_editor.gd +++ b/addons/dialogic/Editor/TimelineEditor/timeline_editor.gd @@ -150,6 +150,7 @@ func new_timeline(path:String) -> void: new_timeline.resource_path = path new_timeline.set_meta('timeline_not_saved', true) var err := ResourceSaver.save(new_timeline) + EditorInterface.get_resource_filesystem().update_file(new_timeline.resource_path) DialogicResourceUtil.update_directory('dtl') editors_manager.edit_resource(new_timeline) diff --git a/addons/dialogic/Resources/CharacterResourceLoader.gd b/addons/dialogic/Resources/CharacterResourceLoader.gd index 579aba4fb..1f6ed0f03 100644 --- a/addons/dialogic/Resources/CharacterResourceLoader.gd +++ b/addons/dialogic/Resources/CharacterResourceLoader.gd @@ -9,7 +9,7 @@ func _get_recognized_extensions() -> PackedStringArray: return PackedStringArray(["dch"]) -## Returns "Rrsource" if this file can/should be loaded by this script +## Returns "Resource" if this file can/should be loaded by this script func _get_resource_type(path: String) -> String: var ext := path.get_extension().to_lower() if ext == "dch": @@ -18,6 +18,15 @@ func _get_resource_type(path: String) -> String: return "" +## Returns the script class associated with a Resource +func _get_resource_script_class(path: String) -> String: + var ext := path.get_extension().to_lower() + if ext == "dch": + return "DialogicCharacter" + + return "" + + ## Return true if this type is handled func _handles_type(typename: StringName) -> bool: return ClassDB.is_parent_class(typename, "Resource") diff --git a/addons/dialogic/Resources/TimelineResourceLoader.gd b/addons/dialogic/Resources/TimelineResourceLoader.gd index 65efa1291..0786bda19 100644 --- a/addons/dialogic/Resources/TimelineResourceLoader.gd +++ b/addons/dialogic/Resources/TimelineResourceLoader.gd @@ -8,7 +8,7 @@ func _get_recognized_extensions() -> PackedStringArray: return PackedStringArray(["dtl"]) -## Returns "Rrsource" if this file can/should be loaded by this script +## Returns "Resource" if this file can/should be loaded by this script func _get_resource_type(path: String) -> String: var ext := path.get_extension().to_lower() if ext == "dtl": @@ -17,6 +17,15 @@ func _get_resource_type(path: String) -> String: return "" +## Returns the script class associated with a Resource +func _get_resource_script_class(path: String) -> String: + var ext := path.get_extension().to_lower() + if ext == "dtl": + return "DialogicTimeline" + + return "" + + ## Return true if this type is handled func _handles_type(typename: StringName) -> bool: return ClassDB.is_parent_class(typename, "Resource")