Support for Document file model and OS integration with exported/readable file types #7835
lostminds
started this conversation in
Engine Core
Replies: 1 comment
-
After some further research I've found one feature that covers some of this functionality, it seems the Window class has a signal for events when the user has dropped files onto the window: files_dropped( files ) which provides some means of file input from the OS file system by the user. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm considering making a sort of editor in Godot and I'm currently investigating if this will be viable. As I have some experience with Godot and much more experience from other projects working with document based editor-type applications I'd like to discuss the possibility of adding support for this in Godot. I think it could have a lot of benefits to non-game projects, or game adjacent (like resource / level editors) and perhaps to the main Godot editor.
What I mean with "Document model" is a data model where you have a Document object that represents a file you're currently working on, separate from your application. Each document is separate and it retains all the data in the document, as well as information on what file it is stored as in the file system. Allowing you to open a file, represent it as a document in your application and then save the document back to the same file.
While this is something you could implement yourself in Godot, the tricky part now is that to ensure cross-platform compatibility retaining this link to the file system file is no longer as trivial as a file path. For example in macOS sandboxed applications (and perhaps other platforms) we need to maintain this relation with the document file correctly to be allowed to write back to it when saving. The recent additions of support for native file dialogs using FileDialog.use_native_dialog helps a lot in this, but I think it could be expanded on:
An addition of a new "Document" class, which can serve as a wrapper around this file system document-file link could help with initiating new documents based on opened files and keep track of where/if they are stored in the file system, what file type they have. Automatically handling loading and save/save as as needed. Typically the use case would be that you initiate a document as the result of an open dialogue or an event from the OS which sends you a file to be opened.
This new "Document" class could also be linked to new project settings for exported file types, to allow the game/application to be appropriately registered in the OS as the owner/editor of a certain file type. This in turn could also enable a new signal/event to listen for for when the application should open a file sent from the OS. For example your "com.company.levelfile" file type so that double clicking them in the file system opens your application, or the user can drag and drop them onto your application icon. For the Godot editor this seems to be currently implemented for godot project files and scene files, but I've found no way to specify this in project or export settings, and I've found no such events or signals to listen to for opened files. The editor obviously also has some such Document-like structure as it keeps track of open scripts and scenes and allows loading and saving them, but I've not found this available for use in Godot projects.
So, to sum things up I'd propose:
Do you think this could be a useful addition? Is some or all of this already implemented and I've just not found it?
How does the editor currently handle these things?
Please let me know what you think.
Beta Was this translation helpful? Give feedback.
All reactions