flixel icon indicating copy to clipboard operation
flixel copied to clipboard

AssetPaths changes

Open Geokureli opened this issue 3 years ago • 2 comments

In my opinion, this util in its current state is more problems than it's worth, it seems to be a barrier for newcomers, and throws a lot of errors for stupid reasons. My default response to people asking for help with AssetPaths issues is "just delete it and use string paths", especially since VSCode's file tree has a simple "copy relative path" tool.

The simplest solution is just to remove it from the template and change tutorials to use string paths.

Of course, we could try fixing it. The main problem now is that it throws errors whenever two files have the same name, even when they are in different folders, and there's no way exclude certain subfolders as a way to alleviate this. We recently added a custom renaming arg but the errors seem to be thrown before renaming.

Features starting with the highest priority:

  • downgrade duplicate AssetPaths fields to warnings, and assign the value of whichever was processed first
  • allow specific paths or subfolders to be excluded
  • check for duplicates among the final result of the renaming, rather than the filename
  • create a default renaming method that allows

The current rename func is passed the filename and extension, without the directory. I want to change this to take the entire file path.

This would allow:

  • return null to exclude files based of subfolder or any other arbitrary culling method
  • directory tiebreakers for identically named files in different directories

Ideally, we could change the current rename func from:

(String)->String

to

(ReadOnlyArray<String>)->Array<Null<String>>

Meaning we give them a list of file paths and they return a list of valid haxe field names.

Geokureli avatar May 01 '22 19:05 Geokureli

For user's whose main advantage of AssetPaths is that it gives you a compile-time check that the asset you're accessing really exists, an ultra-simple improvement would be to add a macro that takes a string path arg, checks the asset folders for the file, and just returns the same string.

NQNStudios avatar Jun 08 '22 12:06 NQNStudios

what happens if it's invalid? there's also openfl.utils.Assets.exists(): https://github.com/openfl/openfl/blob/develop/src/openfl/utils/Assets.hx#L75

Geokureli avatar Jun 08 '22 15:06 Geokureli