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

Added export to GameMaker Studio 2 #2979

Merged
merged 24 commits into from
Feb 12, 2021
Merged

Added export to GameMaker Studio 2 #2979

merged 24 commits into from
Feb 12, 2021

Conversation

bjorn
Copy link
Member

@bjorn bjorn commented Jan 27, 2021

Closes #1642

Quite a bit of work done, but some tasks remain and no testing was done at all yet.

  • Export tile layers as GMRTileLayer (single tileset per layer)
  • Export tile objects as GMRSpriteGraphic or GMRGraphic on GMRAssetLayer
  • Export of image layers as GMRBackgroundLayer
  • Export group layers as GMRLayer
  • Export of instances (objects with type) to GMRInstanceLayer
  • Support tile layers using multiple tilesets (create a group layer with multiple child tile layers)
  • Export paths (polyline and polygon) as GMPath asset and a GMRPathLayer
  • Export tile layers to asset layers when they use image collection tilesets, or tiles where the size doesn't match the map grid size.
  • Export instance creation order
  • Handle overriding depth better

bjorn added 4 commits January 26, 2021 17:28
For exporting to GameMaker Studio 2.
* Added exporting of tile layers as GMRTileLayer
* Added exporting of tile objects as GMRSpriteGraphic or GMRGraphic
* Added exporting of image layers as GMRBackgroundLayer
* Added exporting of group layers as GMRLayer
* Numerous fixes and formatting tweaks
We can no longer assume bottom-left alignment for tiles.
@bjorn bjorn self-assigned this Jan 27, 2021
bjorn added 6 commits January 27, 2021 16:58
Broke compile against Qt 5.9, used for the snap package.
* Make sure doubles always include at least one decimal. It shouldn't
  matter for JSON, which has just one "number" type, but this is to
  match the behavior of GameMaker.

* Write out sequenceId as "null" instead of "0".

* Avoid allocation of QByteArray for writing keys. Relying on plain
  "const char *" for now, since we don't have QByteArrayView yet (needs
  Qt 6.0).
Split the export into two steps, where first all the layers are iterated
and converted to GameMaker structures. Serializing stuff to the file
happens as second step. This allows moving the data around as needed
more easily.

As a result of this change, it was now easy to handle a tile layer where
multiple tilesets are used, which will now create a group layer with
a child tile layer for each tileset.

Similarly, this way we can write out asset, instance and path layers for
a single group layer. However, writing of paths and instances is not
fully supported yet.

Also, all 8 views are now always written, as done by GameMaker.
Pretty much the same way as was done in the GMX plugin.
@bjorn bjorn mentioned this pull request Feb 2, 2021
bjorn added 2 commits February 3, 2021 15:02
* Layer names are now sanitized, so that they only contain 0-9, a-z, A-Z or _.
* Sprite and tileset names are now sanitized as well, so there's a higher chance they'll match the default naming they get when importing their images into GMS 2.
* IDs like spriteId, tilesetId and such now export as "null" instead of with empty paths, when they're not set.
* An empty tile layer exports as an empty GMRTileLayer instead of an empty GMRLayer (and an empty object layer as an empty GMRInstanceLayer).
* Fixed the order of color channels to be AABBGGRR.
* Reversed the layer order.
* Better names for child layers.
* Default "visible" property to layer's visible state.
* Support flipped tile objects exported as GMRGraphic.
@TrunXGIT
Copy link
Contributor

TrunXGIT commented Feb 3, 2021

More or less Critical:

  • x and y adjustment of sprites and objects in regard to origin, flipping, scale and rotation-

just sprites:
smth. is off with the vertical flipping (depending on the rotation it gets moved to a different wrong position)

sprites and objects:
scaling is not part of the x and y (origin) adjustment?

  • Support for the objName (objectId) property in view-objects.
  • Export the InstanceCreationOrder list (sort by layer/object order by default?)

Nice to have:

  • Support for custom properties of objects

(written to the "properties:[]" list of the instances)
-> always saved as strings

  • Support to overwrite the default sprite name of the image source with a custom property "sprite".
  • Use Map Property "Background Color" (if set) to create a background layer with the accourding color and no image as the backmost layer.
  • Support for custom layer property "depth" and automatic even distribution of the depth values of the layers in-between. (Mimicing GMS2 behaviour)
  • Supprt custom property "creationOrder" to influence the "InstanceCreationOrder list.

e.g negative values will always get placed before the instances without a defined creationOrder, while positive values will get placed after the undefined instances. (sorted by the creationOrder values)

EDIT: Added the two InstanceCreationOrder points

bjorn added 12 commits February 3, 2021 22:09
Any unrecognized custom properties are now assumed to override properties defined on the object. Overriding properties of parent objects is not supported for now.

For the views, a custom "objectId" property can now be used to set the object that the view should follow.
Supports custom int property "creationOrder" for controlling the creation order of instances.
There are a number of features that can't be supported on a GMRTileLayer:

* Image collection tilesets
* Tilesets with a tile size different from the grid size
* Non-orthogonal tile layers

This change falls back to exporting the tiles to an asset layer in such cases instead, adding support for all the above features.

A number of warnings have been added as well.

The "ignore" property for instances is now set to true for invisible objects by default.

Simplified a little the logic of assigning unique names.
Tile objects with custom origin would not export to the right location when scaled, both when exported as assets and as instances.

Assets created based on tiles from an image collection tileset were not taking the origin into account in determining their position.

There are still some remaining issues, but I'll have to revisit those later.
This applies wherever a sprite is referenced, which includes the tileset sprite, a tile sprite (in case of image collection tileset) and the image layer sprite.
Replicated the same behaviour as seen in GMS 2.

Also added custom layer property "noExport" for making the export skip the entire layer (and its children, in case of group layer).
* Avoid code duplication for writing GMResource properties and
  initializing a GMRGraphic
* Don't write out "tags" as GMOverriddenProperty
* Sort the used tilesets by name, to avoid random GMRTileLayer order
And a bit more cleanup regarding the depth property.
@bjorn bjorn marked this pull request as ready for review February 12, 2021 10:16
@bjorn bjorn merged commit 5ebf9aa into master Feb 12, 2021
@bjorn bjorn deleted the wip/yy-plugin branch February 12, 2021 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GameMaker Studio 2 support
2 participants