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

Modified FileSystemDock so folders can be selected for reimport. #41242

Merged
merged 1 commit into from
Aug 14, 2020

Conversation

geekrelief
Copy link
Contributor

Now, you can select folders from the file system dock, and as long as the directory contains importable files all of the same type, the Import dock will allow them to be reimported.

@geekrelief geekrelief force-pushed the folder_reimport branch 2 times, most recently from 30ba631 to 7e862fe Compare August 14, 2020 06:53
@realkotob
Copy link
Contributor

This will be very useful! Selecting files one by one is very tedious.

My only comment is: why should be it limited to only re-importing files of same type? That does not seem necessary.

Copy link
Member

@groud groud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@akien-mga akien-mga merged commit f165761 into godotengine:master Aug 14, 2020
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged contribution 🎉

@geekrelief
Copy link
Contributor Author

geekrelief commented Aug 14, 2020

This will be very useful! Selecting files one by one is very tedious.

My only comment is: why should be it limited to only re-importing files of same type? That does not seem necessary.

@asheraryam
I considered allowing different import types in the same directory. If I detect multiple import types (.png and .wav) how do I represent the import options for both in the UI? Would it be confusing because if you currently select a directory with all different kinds of files you see the number of files listed? But your import options should only affect a subset of those files. So now you have to filter the selection and it no longer matches the FileSystem dock.

A UI fix might require something more sophisticated. Also how is it currently done in code?

I wanted to solve my original problem which was to import files all of the same import type in a folder which I think is like a 99% solution. I think most people would put all textures in a folder, sounds in another, etc. And if you organize by "game object" e.g. animals directory contains lion, tiger, bear I think you can filter by extension then select the parent animal folder and this will still work. Also this was very quick to implement.

Updated: I just tested sorting by extension and it doesn't quite work because I forgot the import type could be different even with the same extension. For example a png could be a Bitmap or a Texture. You can probably get around this issue with a naming convention for your files like texture_bear.png bitmap_bear.png.

Update2: Testing the naming convention idea and the code needs an update to properly filter the selected files.

@geekrelief geekrelief deleted the folder_reimport branch August 14, 2020 16:29
@geekrelief
Copy link
Contributor Author

Thanks! And congrats for your first merged contribution 🎉

@akien-mga Is this worthy of cherry picking for 3.2? :)

@realkotob
Copy link
Contributor

@geekrelief The idea is that the import settings are already in the .import files, we don't need to re-show the options for all the different file types, just a re-import option.

I can see that this is also limiting, so perhaps we can have both: show the import options when files have the same type and only show the re-import button if they are of mixed types.

Either way, I think this a good change and is already a great improvement.

@geekrelief
Copy link
Contributor Author

@asheraryam Maybe it's because I'm new to Godot, but I don't understand what you're suggesting. As before and now, you can't reimport a selection of mixed import types.

Can you give a use case? Or explain with greater detail?

I don't understand what you mean by "only show the re-import button if they are of mixed types".

geekrelief added a commit to geekrelief/godot that referenced this pull request Mar 27, 2021
In conjunction with PR godotengine#41242, you can have directories
of mixed import types, filter by part of a file name
and select a directory to reimport all the matching files.

Checking for the import type in the FileSystem was removed, since
it's already handled with a dialog informing the user when
reimporting mixed types. Maintainence of the file selection between
changes in the search filter and clicking in the tree has
been improved.

An asset's "import" is reloaded multiple times in the ImportDock code.
ImportDock caches the config files to speed up selection when
the dock is visible (frees the cache when hidden).
When selecting files or folders containing hundreds or thousands
of assets, the editor stalls while the config files are parsed.
This is obviously perceivable on an SSD drive.

I've changed it so if the ImportDock only parses config files when
visible. A thread is used for parsing the multiple import files to
prevent the main thread from blocking, and the Label is updated to
show the number of files being parsed as a progress indicator.
ImportDock processing can safely be interrupted with:
  - a new selection in the FileSystem
  - losing visibility by switching to the Scene tab
  - or closing the editor.

There's a strange crash that can occur if a direct reference from
a String in a Vector<String> is passed to `ImportDock::set_edit_path`.
The accessing `p_path` in the function can lead to random crashing
when attempting to read its size.
The workaround is to create a new variable that references
the String before passing into the function.

Also, added a modification to RemoveDependencyDialog to emit all
the files that were deleted. FileSystemDock connects to this
and passes it to ImportDock to clear the config_cache.

This also includes a fix to tree.cpp where deselect_all fails
to properly deselect all tree items. This is required for proper
deselection in the FileSystemDock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants