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

GameMaker Studio 2 Export Broken With Recent GM Update #4132

Closed
DustinVG opened this issue Jan 1, 2025 · 8 comments · Fixed by #4143
Closed

GameMaker Studio 2 Export Broken With Recent GM Update #4132

DustinVG opened this issue Jan 1, 2025 · 8 comments · Fixed by #4143
Assignees
Labels
bug Broken behavior.

Comments

@DustinVG
Copy link

DustinVG commented Jan 1, 2025

Reposting here for maximum visibility

A recent GM update seems to have rendered maps exported from Tiled incompatible. Attempting to load the project in GM will result in an error reading

The JSON file reader encountered parsing errors
C:\Git\Ancient Keys DX\rooms\rm_area_a\rm_area_a.yy(2,3): Error: A type tag field is required at the start of the JSON record, eg: “$MyTypeName”: …

Adding this field manually will turn the error into

C:\Git\Ancient Keys DX\rooms\rm_area_a\rm_area_a.yy(3,3): Error: Field “%Name”: expected.

Adding that field turns it into

C:\Git\Ancient Keys DX\rooms\rm_area_a\rm_area_a.yy(4,3): Error: Field “creationCodeFile”: expected.

And so on and so forth.

I’m sure this is known and is being worked on, but I wanted to make absolutely sure. Thank you for your time.

@DustinVG DustinVG added the bug Broken behavior. label Jan 1, 2025
@bjorn
Copy link
Member

bjorn commented Jan 13, 2025

I’m sure this is known and is being worked on, but I wanted to make absolutely sure. Thank you for your time.

These issues were not known until you reported them, so thank you for opening an issue about it! Unfortunately, I forgot to look into this before publishing the Tiled 1.11.1 release. I'll look into making the necessary updates.

@bjorn bjorn self-assigned this Jan 13, 2025
@bjorn
Copy link
Member

bjorn commented Jan 13, 2025

Alright, when opening my old test project in recent GameMaker it told me that it needed to be converted and it actually made a copy of the entire project to a new location of my choice. And at the new location, the files look different in subtle ways:

  • Addition of a "type tag field" at the start of most JSON objects. It appears to duplicate the value of the existing resourceType property (which is still there, just at a different location). The value is "v1" for rooms, but is more commonly just an empty string, for example "$GMRTileLayer":"", "$GMRGraphic":"", etc.
  • Addition of %Name property, with the same value as name (which is also still there, just at a different location).
  • Removal of spaces separating property name and value.
  • JSON objects now have their properties saved in alphabetical order

So far I fail to understand why these changes would require duplication and conversion of the entire project. Since the new fields appear to duplicate information, my guess is that it's some kind of optimization that wouldn't work if it wasn't applied everywhere.

I hope I can adjust the format while staying compatible with older GameMaker versions. Since the old fields are still there I guess it might be compatible.

bjorn added a commit to bjorn/tiled-dev that referenced this issue Jan 13, 2025
It seems an update to GameMaker in late 2024 has broken compatibility
in several ways:

* It now requires a "type tag field" at the start of applicable JSON
  records.

* The name is expected to follow the "type tag field" as a "%Name"
  field, in addition to the regular "name" field.

* Except for these special properties, the JSON fields are now required
  to be ordered alphabetically.

Other minor differences include:

* The "tags" field is left out when there are no tags.
* There is no longer a space included after JSON field names.
* Some new fields were added.

This patch does not address all alphabetical ordering issues. Propably
the preferred way will be to collect the fields in a QJsonObject first
and rely on automatic sorting of the fields while serializing.

Closes mapeditor#4132
@bjorn
Copy link
Member

bjorn commented Jan 13, 2025

I've started to address the incompatibilities in #4142. It's not finished yet. Especially due to the required alphabetical sorting of the JSON fields, GameMaker is being incredibly picky now.

@bjorn
Copy link
Member

bjorn commented Jan 14, 2025

Oh boy... I thought I had a clean solution to this by stuffing things in a map (or QJsonObject) before serialization, but to make matters worse, GameMaker appears to require the keys to be sorted case-insensitively. This means a custom sort on the keys will be necessary... :S

bjorn added a commit to bjorn/tiled-dev that referenced this issue Jan 15, 2025
An update to GameMaker has broken compatibility in several ways:

* It now requires a "type tag field" at the start of applicable JSON
  records.

* The name is expected to follow the "type tag field" as a "%Name"
  field, in addition to the regular "name" field.

* The JSON fields are now required to be ordered alphabetically
  (case-insentively).

Other minor differences include:

* The "tags" field is left out when there are no tags.
* There is no longer a space included after JSON field names.
* Some new fields were added.

Also, the plugin now uses SaveFile again rather than QFile, because it
seems that recent GameMaker versions will reload fine when using safe
writing of files.

Closes mapeditor#4132
@bjorn
Copy link
Member

bjorn commented Jan 15, 2025

@DustinVG I think I've got it fully working again now. Please see if you can take the builds available from #4143 to test whether it works also in your case. The files will be available at https://github.com/mapeditor/tiled/actions/runs/12787726250.

@DustinVG
Copy link
Author

@DustinVG I think I've got it fully working again now. Please see if you can take the builds available from #4143 to test whether it works also in your case. The files will be available at https://github.com/mapeditor/tiled/actions/runs/12787726250.

Besides the fact I had to delete a ton of old unused variables (which I probably should've done already anyway), yes, it appears to work fine. The only issue I'm running into is that Tiled doesn't seem to be setting the color variables in one of my objects properly where it previously did:

image
image

@bjorn
Copy link
Member

bjorn commented Jan 16, 2025

Besides the fact I had to delete a ton of old unused variables (which I probably should've done already anyway)

Is GM now complaining about these unused variables where it wasn't before? Do you think the exporter could be changed such that it won't complain about unused variables, or is the required cleanup a good thing?

The only issue I'm running into is that Tiled doesn't seem to be setting the color variables in one of my objects properly where it previously did

Hmm, maybe something changed about the color values as well. I don't personally know GameMaker very well, so could you maybe help me by describing how you got these properties set up on the GameMaker side?

@bjorn
Copy link
Member

bjorn commented Jan 16, 2025

@DustinVG I found the problem and fixed it in d7497ae. I think the colors you were seeing must have just been the defaults, because the properties set on the object were getting ignored due to that regression introduced along with the new Properties view. New build will be available at https://github.com/mapeditor/tiled/actions/runs/12816565529?pr=4143

bjorn added a commit to bjorn/tiled-dev that referenced this issue Jan 17, 2025
An update to GameMaker has broken compatibility in several ways:

* It now requires a "type tag field" at the start of applicable JSON
  records.

* The name is expected to follow the "type tag field" as a "%Name"
  field, in addition to the regular "name" field.

* The JSON fields are now required to be ordered alphabetically
  (case-insentively).

Other minor differences include:

* The "tags" field is left out when there are no tags.
* There is no longer a space included after JSON field names.
* Some new fields were added.

Also, the plugin now uses SaveFile again rather than QFile, because it
seems that recent GameMaker versions will reload fine when using safe
writing of files.

Closes mapeditor#4132
bjorn added a commit that referenced this issue Jan 17, 2025
An update to GameMaker has broken compatibility in several ways:

* It now requires a "type tag field" at the start of applicable JSON
  records.

* The name is expected to follow the "type tag field" as a "%Name"
  field, in addition to the regular "name" field.

* The JSON fields are now required to be ordered alphabetically
  (case-insentively).

Other minor differences include:

* The "tags" field is left out when there are no tags.
* There is no longer a space included after JSON field names.
* Some new fields were added.

Also, the plugin now uses SaveFile again rather than QFile, because it
seems that recent GameMaker versions will reload fine when using safe
writing of files.

Updated the manual to no longer say "GameMaker Studio 2.3".

Closes #4132
bjorn added a commit that referenced this issue Jan 28, 2025
An update to GameMaker has broken compatibility in several ways:

* It now requires a "type tag field" at the start of applicable JSON
  records.

* The name is expected to follow the "type tag field" as a "%Name"
  field, in addition to the regular "name" field.

* The JSON fields are now required to be ordered alphabetically
  (case-insentively).

Other minor differences include:

* The "tags" field is left out when there are no tags.
* There is no longer a space included after JSON field names.
* Some new fields were added.

Also, the plugin now uses SaveFile again rather than QFile, because it
seems that recent GameMaker versions will reload fine when using safe
writing of files.

Updated the manual to no longer say "GameMaker Studio 2.3".

Closes #4132

(cherry picked from commit cc77ce6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior.
Projects
None yet
2 participants