Description
Describe the project you are working on
Creating a typing game requiring runtime loading of numerous text files.
Describe the problem or limitation you are having in your project
Unable to utilize FileAccess, load, or preload for reading text files in an exported project due to godotengine/godot#21787 (comment)
FileAccess
docs:
Note: To access project resources once exported, it is recommended to use ResourceLoader instead of FileAccess, as some files are converted to engine-specific formats and their original source files might not be present in the exported PCK package.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Expose text_file.cpp as a Resource and implement a ResourceFormatLoaderText to allow straightforward loading of text files using ResourceLoader. This enhancement will simplify text file loading, overcoming the current limitations.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I've devised a solution to streamline the process of accessing text data within Godot. Initially, I convert text files to JSON format using an external tool. Subsequently, within Godot, the JSON files are loaded using ResourceLoader.load(json_path). However, the current method of converting the JSON data into an array to extract the text from the original text file is proving to be inefficient
Convert Text files to Json in an external tool → Code reads that Json with ResourceLoader.load(json_path) → Custom function extracts the original text from the JSON Resource
Additionally, with the proposed enhancement of ResourceLoaderTextFile, the workflow becomes even more straightforward:
Read textFiles with ResourceLoader.load(txt_path) → text_file.get_text() DONE!!!!!
If this enhancement will not be used often, can it be worked around with a few lines of script?
As previously mentioned, one could bypass the need for this enhancement by converting the text file to an already implemented resource format like JSON. However, this approach is a very slow workflow and necessitates the creation of a custom function to extract the text from the JSON file.
Is there a reason why this should be core and not an add-on in the asset library?
The text_file.cpp already exists as a Resource within Godot, albeit not yet exposed in the engine. Hence, the integration of this enhancement merely involves exposing it and implementing the ResourceFormatLoader abstract class.