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

Have source files be relative to a project's root #3427

Open
duarm opened this issue Jul 29, 2022 · 1 comment
Open

Have source files be relative to a project's root #3427

duarm opened this issue Jul 29, 2022 · 1 comment
Labels
feature It's a feature, not a bug.

Comments

@duarm
Copy link

duarm commented Jul 29, 2022

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 duarm added the feature It's a feature, not a bug. label Jul 29, 2022
@eishiya
Copy link
Contributor

eishiya commented Jul 30, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

No branches or pull requests

2 participants