SproutyDialogsFileUtils
Inherits: RefCounted
Description
This module is responsible for some file operations and references. It provides methods to manage recent file paths, check file extensions, validate resource UIDs, and other useful methods.
Methods
| Return Type | Method |
|---|---|
| String | get_recent_file_path(file_type: String) |
| void | set_recent_file_path(file_type: String, path: String) |
| bool | check_valid_extension(path: String, extensions: Array) |
| bool | check_valid_uid_path(uid: int) |
| String | ensure_unique_name(name: String, existing_names: Array, empty_name: String = "Unnamed") |
| void | open_scene_in_editor(scene_path: String, scene_tree: SceneTree) |
| void | create_new_scene_file(scene_path: String, scene_type: String) |
| Array | get_resources_of_type(type: String = "dialogue", path: String = "res://") |
| SproutyDialogsCharacterData | load_character_reference(character_key: String, reference: Variant) |
| SproutyDialogsCharacterData | find_character_resource_by_key(character_key: String, path: String = "res://") |
Method Descriptions
static func get_recent_file_path(file_type: String) -> String
Get the last used path for a file type in a file dialog.
static func set_recent_file_path(file_type: String, path: String) -> void
Set the last used path for a file type in a file dialog.
static func check_valid_extension(path: String, extensions: Array) -> bool
Check if the path has valid extension.
static func check_valid_uid_path(uid: int) -> bool
Check if a UID has a valid resource path associated with it.
static func ensure_unique_name(name: String, existing_names: Array, empty_name: String = "Unnamed") -> String
Ensure a name is unique within a list of existing names.
static func open_scene_in_editor(scene_path: String, scene_tree: SceneTree) -> void
Open a scene in the editor given its path. Also, needs a reference to the SceneTree (using Node.get_tree()) to process a timer.
static func create_new_scene_file(scene_path: String, scene_type: String) -> void
Create a new dialog box or portrait scene file. Needs the path where save the scene file and the type of the scene that can be "dialog_box" or "portrait_scene".
static func get_resources_of_type(type: String = "dialogue", path: String = "res://") -> Array
Return all the resources of a given type in the project. The type can be "dialogue" or "character" resource.
static func load_character_reference(character_key: String, reference: Variant) -> SproutyDialogsCharacterData
Loads a character resource from a character reference of the dialogue data. Legacy references storing only the character UID are also accepted. The reference is tried, in this order: by its stored UID, by its stored file path, and by searching the project for a character whose current file name / key name matches character_key. Returns the loaded character resource, or null when it is not found.
static func find_character_resource_by_key(character_key: String, path: String = "res://") -> SproutyDialogsCharacterData
Search for a character resource by its file name or its key name in the whole project. Used to recover character references when the character file was renamed or moved outside of the plugin editor, so its reference UID is no longer valid. Returns the character resource or null if it is not found.