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

GDevelop integration #126

Open
deepnight opened this issue Oct 2, 2020 · 7 comments
Open

GDevelop integration #126

deepnight opened this issue Oct 2, 2020 · 7 comments
Assignees
Milestone

Comments

@deepnight
Copy link
Owner

Follow up of #101, quoting @blurymind :


I see the idea :)

The best approach would definitely to write a simple LEd JSON parser, rather than relying on Tiled for that, because of all Tiled limitations (the conversion from LEd to Tiled isn't lossless).

Yes the more I look into it, the more it makes sense to parse Led's json format sepparately from our tiled json parsing - to keep all of its perks. We use pixi-tilemap for rendering. So the process is we get the json file, parse it and then pass the data in the right format that pixi-tilemap understands

I can also add support for extra app parameters to start the editor on a specified map directly, for example.

Yes please, that will help a lot for integrating it. We need a way to initiate it with a map by passing the json parsed object or a path to the json file it. We need a way to initiate it with a new document with a specified name and a way to tell it to save its document.

You can see how we have done it for the currently bundled external editors
https://github.com/4ian/GDevelop/tree/master/newIDE/app/public/external

The xxx-main.js file is what is bridging the external editor and gdevelop. For example piskel's
https://github.com/4ian/GDevelop/blob/master/newIDE/app/public/external/piskel/piskel-main.js

We wait for piskel to load (load callback would be helpful too), then we tell it to either open a file that gdevelop sent it or start a new one. We also add a custom header for saving the file or changing the path to save it to.
This only works in the electron version of gdevelop atm - spawning the editor as a modal window.

My hope is that one day we will embed external editors as tabs inside the IDE's react interface instead

Originally posted by @blurymind in #101 (comment)

@blurymind
Copy link

Thanks for opening a ticket. Probably worth mentioning the related ones on the gdevelop tracker:

LED bundling in GD
4ian/GDevelop#2002

pixi-tilemap rendering - tiled files request/pr on GD
4ian/GDevelop#503
4ian/GDevelop#1901

@Silver-Streak
Copy link

Just chiming in an update here for @deepnight that @blurymind fully implemented Pixi-tilemap into GDevelop.

We're having some conversations around LDtk bundling, didn't know if you wanted to peek at 4ian/GDevelop#2002 to see if the info there makes sense?

Because Pixi-Tilemap only supports Tiled JSON (rather than TMX), unless you also add the ability to export to tiled formatted json in LDtk (which I could imagine might be a big lift), it's sounding like they'll need to do some kind of interpreter in the engine. Does that sound right?

@deepnight
Copy link
Owner Author

That would be amazing 😍 I forgot to update this thread but you can pass a path to a ldtk file to open it automatically, and even add a level UID to open some specific level.

@Silver-Streak
Copy link

@deepnight If you have any insight you can provide there (or if there is something that could be done to transcibe the json formats more easily), your post would be greatly appreciated. I'm likely to post a bounty to get this implemented, but if a bounty on both sides would help (if the json transcribe is possible, but the time is harsh), I could probably do that too. 😄

@blurymind
Copy link

blurymind commented Feb 6, 2021

Perhaps I need to clarify a bit about pixi-tilemap. The truth is that it doesnt support parsing any json formats out of the box. The reason this works in gdevelop is because I wrote a custom parser that gives it the tiles in the format it expects. Pixi-tilemap only knows about rendering a tilemap and you have to even manually create its tileset in a way that it can stomach from the atlas. You can see how that is done in the helper class
https://github.com/4ian/GDevelop/blob/master/Extensions/TileMap/pixi-tilemap-helper.js
Pixi-tilemap has a few limitations, which we described in the gdevelop wiki here
http://wiki.compilgames.net/doku.php/gdevelop5/objects/tilemap
notably about isometric tilemaps and also animation frames on a tileset atlas needing to be arranged in a sequence

The plan from my point of view is to write a similar parser for the ldtk json format - reason mainly being that ldtk can only load/save the xml (tmx) tiled format and gdevelop doesnt see that as a resource type- it only sees json.

Now the reason we wish we could embed it as a react component is to integrate it as smoothly as possible with gdevelop - not just as an external editor like piskel is.
For that to happen we need someone to write a reactjs wrapper component - so really ldtk could exist in any reactjs app as a component. It could exist as an npm module that can be a part of other apps.
If that is not that desired or even possible we can pursue the external editor route but that would mean it will only work in the desktop version of gdevelop - not the web one.

There is another challenge to overcome and that is resource dependencies. A map created in ldtk can have several tilemaps, which can have several tilesets, which can have several atlases/image resources.
The current implementation in gdevelop lets you only use one tilemap, one tileset and one atlas.
In order to have a smooth UX experience, I think gdevelop needs to load one tilemap and that tilemap should be giving the relative paths of all the other assets it needs in order to be rendered. Unfortunately gdevelop's resource manager will not even copy a file if its not registered - so we need to teach it about these resource dependencies - so as to load all the files it needs using a single input file that has the paths.

@Silver-Streak
Copy link

Thanks for the detail Blurymind. Just for reference incase anyone is watching this thread, I've started a bounty for this: https://www.bountysource.com/issues/93298046-idea-add-new-externral-editor-to-edit-tilemaps-ldtk

Although not quite as high as I would like, I'm hoping it drives interest.

@blurymind
Copy link

I have started implementing a parser for ldtk files in gdevelop. Issue here
4ian/GDevelop#2434

here is an early days render
tiledVsLdtk-output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants