tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Have source files be relative to a project's root

Open duarm opened this issue 1 year ago • 1 comments

This was briefly brought up on #1665 , couldn't find any discussion about this feature, which would make working with tiled files easier.

Is your feature request related to a problem? Please describe. A common project structure is the follow:

.
├── proj.tiled-project
├── map
│   ├── proj.world
│   ├── test.tsj
│   ├── ts_debug.png
│   └── ts_test.png

With a project, I would expect the source of a test.tsj for example, be relative to the project's root, instead of itself.

Describe the solution you'd like Having the source property be relative to its own location is fine, but when I'm working in a project, I expect more. If no project was created, the old behaviour can still be used. The .tiled-project should have a root, and all sources should be relative to that root.

Advantages:

  • we can have the same root for all our files, locating them are now easier.
  • we can have the root of the project be on our search path, we can now easily find any source on a .tsj/.tmj/.project without searching or extra handling.

here's how I think it should work:

The project file should have a root property, a full path, including a placeholder for the .tiled-project directory, something like

{
    "root": "<PROJ_DIR>"
}

this would expand to the .tiled-project file path. It will default to <PROJ_DIR>. All source files would be relative to this root, a .tsj, on our case, would be:

{
    "image":"map/ts_test.png"
}

Just that, no need for multiple roots, that would complicate things and we want to directly reference our assets, multiple roots would require us to search for it in all possible roots.

I also see no benefit on a per-type root, that would also complicate things, and be unflexible.

Describe alternatives you've considered Currently I'm just working around this by having a convention folder on my projects named map/, when I load anything for a tsj/tmj file, I load it from there.

duarm avatar Jul 29 '22 23:07 duarm

This change would require parsers to have this additional metadata, whereas the current approach allows parsers to deal with files all the same regardless of whether they're in a project or not, without requiring the user to feed them the project file.

While I think this idea sounds useful for some projects, if implemented, this should be an export option or otherwise opt-in, and not a blanket change.

eishiya avatar Jul 30 '22 17:07 eishiya