Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In exported games, a FileDialog in Resource mode cannot open resources in subfolders #53339

Open
Poobslag opened this issue Oct 2, 2021 · 8 comments

Comments

@Poobslag
Copy link

Poobslag commented Oct 2, 2021

Godot version

v3.3.4.stable.official [faf3f88]

System information

Windows 10

Issue description

After exporting a project, opening a FileDialog to select resources only lets you select resources in the root directory. Attempting to select a resource outside the root directory does not close the dialog, and does not emit the file_selected signal.

If you open a resource in the root directory, the dialog works properly.

If the dialog is set to File System instead of Resources, the dialog works properly.

If the game is launched directly from the Godot editor instead of being exported, the dialog works properly.

I am unsure whether this bug only affects Windows exports, or whether it affects other platforms as well.

Steps to reproduce

Reproducing the bug by yourself:

Create a FileDialog. Ensure the Access is set to Resources, and that there are resources in a subdirectory which it can access.

Export the project for Windows. Open your FileDialog and attempt to access a resource from a subdirectory. Double-click the resource or click the "Open" button to select it. It is expected that the dialog should close and emit the file_selected signal. However, the dialog does not respond and no signal is fired.

Reproducing the bug with the attached minimal reproduction project:

Export the project for windows. Click the "Open Resource Dialog" button and attempt to access a resource from the "dir" subdirectory. It is expected that the dialog should close and emit the file_selected signal. However, the dialog does not respond and no signal is fired.

If you close the dialog, you can experiment by accessing files in the root directory, or by launching a FileDialog which access files, instead of resources. Both of these cases will work OK. The FileDialog closes and the file path is printed to the screen.

Minimal reproduction project

Dialogs.zip

image

@akien-mga
Copy link
Member

akien-mga commented Oct 2, 2021

I think you misunderstood the API, if you set the access property to ACCESS_RESOURCES ("Resources" in the enum), it specifically restricts it to the project resource folder (res://). That's the point of this enum value.

https://docs.godotengine.org/en/stable/classes/class_filedialog.html#enum-filedialog-access

The documentation is a bit misleading though as it mentions the [Resource] class, which is probably what caused the confusion.

It could maybe be renamed to ACCESS_PROJECT.

@Poobslag
Copy link
Author

Poobslag commented Oct 2, 2021

I think you misunderstood the API, if you set the access property to ACCESS_RESOURCES ("Resources" in the enum), it specifically restricts it to the project resource folder (res://). That's the point of this enum value.

https://docs.godotengine.org/en/stable/classes/class_filedialog.html#enum-filedialog-access

The documentation is a bit misleading though as it mentions the [Resource] class, which is probably what caused the confusion.

It could maybe be renamed to ACCESS_PROJECT.

This does not strike me as a usability problem, or an API documentation issue.

The current behavior is that if you have two resources, res://foo.txt, res://dir1/bar.txt, you can open both resources if you launch your game from within the Godot editor, but if you export your project, you can open "foo.txt" but not "bar.txt". The dialog will let you navigate to "bar.txt" but upon double clicking it or opening it, the dialog will not respond. Additionally, the dialog's behavior changes based on whether it is launched within the Godot editor, or whether it is exported.

This really seems like a bug to me, and not a documentation/usability issue. The amount of documentation which would be needed would be absurd and confusing, but I suppose it would be read something like:

  • ACCESS_RESOURCES = 0 --- The dialog only allows accessing files under the Resource path (res://), and sometimes allows for access in subdirectories as well. Files under subdirectores of the resource path, (res://foo/bar) can be accessed from within the Godot editor. However, they cannot be accessed when the game is exported.

@Poobslag
Copy link
Author

Poobslag commented Oct 2, 2021

Additionally, it's possible the title of this bug was misleading. Perhaps a less misleading title would be a FileDialog in Resource mode will not select resources within subfolders

@akien-mga
Copy link
Member

I see. I can't reproduce that bug, I suspect that you don't have any resource in that specific sufolder, so Godot doesn't include it in the resource access.

A .txt file is not a resource, unless you explicitly add a filter to include it in the export preset. "Resources" are a specific object type which is known to Godot and that can be loaded via the ResourceLoader/load(), such as scenes, imported textures and samples, etc.

Here's an updated MRP tested successfully on 3.3.3-stable:
Dialogs.zip

Your own project contains another project (+ exported PCK) in the subfolder, that might be the problem? Godot probably doesn't import its files as resources as they belong to another project.

@Poobslag
Copy link
Author

Poobslag commented Oct 2, 2021

I see. I can't reproduce that bug, I suspect that you don't have any resource in that specific sufolder, so Godot doesn't include it in the resource access.

Did you export the project for Windows, for Linux, or run the project within the Godot editor? I've only verified the bug exists when exporting the project for Windows.

Here's an updated MRP tested successfully on 3.3.3-stable:
Dialogs.zip

I have duplicated the bug with your updated MRP. After exporting the project for Windows, I cannot open the res://foo/Spatial.tscn file using the Resource Dialog. I can open files in the root folder, however. Here is a screenshot.

image

Your own project contains another project (+ exported PCK) in the subfolder, that might be the problem? Godot probably doesn't import its files as resources as they belong to another project.

The specific files in the subdirectory aren't important, I just wanted files which Godot would export by default. You can see them in the screenshot attached to the issue (https://user-images.githubusercontent.com/5902413/135727463-6318e289-3e10-461d-8857-f7e5fbeddfc8.png). Your example project works fine at duplicating the bug as well.

@akien-mga
Copy link
Member

I see, I can confirm the bug with an export on Linux too. I had managed to select files in subfolders successfully so I thought it was fine. But indeed I can't open them either.

@akien-mga akien-mga changed the title In exported games, a FileDialog in Resource mode will not select resources outside the root directory In exported games, a FileDialog in Resource mode cannot open resources in subfolders Oct 2, 2021
@Poobslag
Copy link
Author

Poobslag commented Oct 2, 2021

Excellent, thanks for confirming.

@ChrisJefferson
Copy link

This bug is still present as of 4.2 and 4.3 beta 2. I just wasted 2 hours of my life wondering why I couldn't open files in subdirectories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants