-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Change AssetPaths args #2575
Change AssetPaths args #2575
Conversation
This way users aren't forced to use regexes, but can opt in if they want to. Plus we don't break backwards compatibility.
IMO the old system was practically unusable, it was rare that this tool was actually worthwhile. There's still some stuff I want to try and do to improve this. but even with these changes my gut says to just remove AssetPaths from the templates/demos and reinforce the usage of string paths, which is even easier for new programmers to understand, imo. especially since VSC has "right click->copy relative path" |
that said, input is absolutely welcome as I'm still not 100% sure what the best solution is. So far this is my best guess |
I'd say the best solution is to allow both wildcard strings and regexes. To distinguish, just check if the user wrote |
Co-authored-by: George FunBook <gkurelic@gmail.com>
Co-authored-by: George FunBook <gkurelic@gmail.com>
Add more options for asset path args.
Another thing I was wondering, since include/exclude will always have to match the Project.xml include/excludes, is it possible to auto-apply those filters and only check the files that will actually be exported? Even if we could, I wonder if there are drawbacks to this. |
fixes #2547
AssetPaths has always been a clunky system, whenever people come to me with issues regarding it, I tell them just to delete it and use String paths.
Problems
rename
arg only takes the file name, and ignores the directorySolutions
Excerpt from the 5.0.0 migration guide
AssetPaths (or any class built using
FlxAssets.buildFileReferences
) will no longer throw an error when two files have the same file name. Now it will give a warning and ignore whichever file is nested more deeply in the folder, or whichever file was found later.The
filterExtensions
arg was removed and replaced withinclude
andexclude
args. These new args can either be anEReg
, or a wildcard string, similar to openfl's project.xml args. For example to exclude everything in a folder called "test", as well as any .psd files, you would either use"*/test/*|*.ase"
or~/\/test\/|\.ase/
.Lastly, the
rename
arg was changed, significantly. Custom renaming is already a relatively new and unknown feature of AssetPaths, but now it may be the most powerful! Therename
arg is a function that will take a filepath (a relative filepath from the project.xml) and returns a field name used to access that path. The previous versions there would be no way to include two files with the same name, for instance, "assets/images/mario/walk.png" and "assets/images/luigi/walk.png" wouldn't be allowed, now you can call themmario_walk.png
andluigi_walk.png
. Additionally, you can returnnull
to exclude a specific file.