Skip to main content
Version: 1.2.0

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 TypeMethod
Stringget_recent_file_path(file_type: String)
voidset_recent_file_path(file_type: String, path: String)
boolcheck_valid_extension(path: String, extensions: Array)
boolcheck_valid_uid_path(uid: int)
Stringensure_unique_name(name: String, existing_names: Array, empty_name: String = "Unnamed")
voidopen_scene_in_editor(scene_path: String, scene_tree: SceneTree)
voidcreate_new_scene_file(scene_path: String, scene_type: String)
Arrayget_resources_of_type(type: String = "dialogue", path: String = "res://")

Method Descriptions​

func get_recent_file_path(file_type: String) -> String

Get the last used path for a file type in a file dialog.


func set_recent_file_path(file_type: String, path: String) -> void

Set the last used path for a file type in a file dialog.


func check_valid_extension(path: String, extensions: Array) -> bool

Check if the path has valid extension.


func check_valid_uid_path(uid: int) -> bool

Check if a UID has a valid resource path associated with it.


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.


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.


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.