Skip to content
Open
6 changes: 6 additions & 0 deletions addons/dialogic/Core/DialogicResourceUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ static func update_directory(extension:String) -> void:

var keys_to_remove := []
for key in directory:
if not typeof(directory[key]) == TYPE_STRING:
continue
if not ResourceLoader.exists(directory[key]):
keys_to_remove.append(key)
for key in keys_to_remove:
Expand All @@ -54,6 +56,10 @@ static func update_directory(extension:String) -> void:
set_directory(extension, directory)


static func is_resource_in_directory(file_path:String) -> bool:
var directory := get_directory(file_path.get_extension())
return file_path in directory.values()

static func add_resource_to_directory(file_path:String, directory:Dictionary) -> Dictionary:
var suggested_name := file_path.get_file().trim_suffix("."+file_path.get_extension())
var temp := suggested_name
Expand Down
18 changes: 17 additions & 1 deletion addons/dialogic/Core/DialogicUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ class_name DialogicUtil
## Script that container helper methods for both editor and game execution.
## Used whenever the same thing is needed in different parts of the plugin.


static var editor_settings_cache := {}

#region EDITOR

## This method should be used instead of EditorInterface.get_editor_scale(), because if you use that
Expand Down Expand Up @@ -148,16 +151,25 @@ static func set_editor_setting(setting:String, value:Variant) -> void:


static func get_editor_setting(setting:String, default:Variant=null) -> Variant:
if setting in editor_settings_cache:
return editor_settings_cache[setting]

var cfg := ConfigFile.new()
if !FileAccess.file_exists('user://dialogic/editor_settings.cfg'):
return default

if !cfg.load('user://dialogic/editor_settings.cfg') == OK:
return default

if cfg.has_section_key('DES', setting):
editor_settings_cache[setting] = cfg.get_value('DES', setting, default)
return cfg.get_value('DES', setting, default)


static func clear_editor_settings_cache() -> void:
editor_settings_cache.clear()


static func get_color_palette(default:bool = false) -> Dictionary:
var defaults := {
'Color1': Color('#3b8bf2'), # Blue
Expand Down Expand Up @@ -633,7 +645,11 @@ static func get_character_suggestions(_search_text:String, current_value:Dialogi

var character_directory := DialogicResourceUtil.get_character_directory()
for resource in character_directory.keys():
suggestions[resource] = {'value': resource, 'tooltip': character_directory[resource], 'icon': icon}
suggestions[resource] = {
'value': resource,
'tooltip': character_directory[resource],
'icon': icon,
}

return suggestions

Expand Down
5 changes: 2 additions & 3 deletions addons/dialogic/Editor/CharacterEditor/character_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ func _ready() -> void:
if get_parent() is SubViewport:
return

DialogicUtil.get_dialogic_plugin().resource_saved.connect(_on_some_resource_saved)
# NOTE: This check is required because up to 4.2 this signal is not exposed.
if DialogicUtil.get_dialogic_plugin().has_signal("scene_saved"):
if Engine.is_editor_hint():
DialogicUtil.get_dialogic_plugin().resource_saved.connect(_on_some_resource_saved)
DialogicUtil.get_dialogic_plugin().scene_saved.connect(_on_some_resource_saved)

$NoCharacterScreen.color = get_theme_color("dark_color_2", "Editor")
Expand Down
5 changes: 3 additions & 2 deletions addons/dialogic/Editor/Common/reference_manager_window.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ func _ready() -> void:

hide()

get_parent().plugin_reference.get_editor_interface().get_file_system_dock().files_moved.connect(_on_file_moved)
get_parent().plugin_reference.get_editor_interface().get_file_system_dock().file_removed.connect(_on_file_removed)
if get_parent().plugin_reference:
get_parent().plugin_reference.get_editor_interface().get_file_system_dock().files_moved.connect(_on_file_moved)
get_parent().plugin_reference.get_editor_interface().get_file_system_dock().file_removed.connect(_on_file_removed)
get_parent().get_node('ResourceRenameWarning').confirmed.connect(open)


Expand Down
3 changes: 2 additions & 1 deletion addons/dialogic/Editor/Common/update_install_window.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ func _ready() -> void:
%LoadingIcon.texture = editor_view.get_theme_icon("KeyTrackScale", "EditorIcons")
%InstallWarning.modulate = editor_view.get_theme_color("warning_color", "Editor")
%CloseButton.icon = editor_view.get_theme_icon("Close", "EditorIcons")
DialogicUtil.get_dialogic_plugin().get_editor_interface().get_resource_filesystem().resources_reimported.connect(_on_resources_reimported)
if DialogicUtil.get_dialogic_plugin():
DialogicUtil.get_dialogic_plugin().get_editor_interface().get_resource_filesystem().resources_reimported.connect(_on_resources_reimported)


func open() -> void:
Expand Down
Loading