Google Summer of Code 2022 - The ENIGMA Team

Week 10-12: EGM Importer, Testing and Wrap Up

Contributor: Kartik Shrivastava
Project: Add Tiled compatibility to/from Enigma
Guided by: fundies, bjorn and Josh

Highlights:
  1. Adding proto fields corresponding to Tiled object layer, tile layer and internal/external tileset #1769b4e #a2866a1 #068660c #661784d
  2. Creating a new plugin in Tiled to import .egm files #2428c4f #1612224 #d118793 #d4fa9d0
  3. Adding merge tmx project into egm functionality in enigma and RadialGM #894aae3 #b7b8cf2 #1f329d7
  4. Adding a gtest #d7f0d50



Details

Adding proto fields corresponding to Tiled object layer

This is the first part of the roadblock resolution mentioned in the last log. In above linked PRs, firstly I renamed Room.proto to GMRoom.proto and created an additional EGMRoom.proto. While EGMRoom.proto contains the additional fields to store Tiled object layer, tile layer and tilesets, the GMRoom.proto is kept for backward compatibility (edit from the future: later I realized that I was supposed to use it for GameMaker to EGM format translation routines, and because of some misunderstanding I had regarding usage of newly created EGMRoom.proto I used it to serve both GameMaker as well as Tiled formats).

Secondly, I updated tmx.cpp to parse Tiled tmx and tsx files data into newly added Tileset, ObjectGroup and TileLayer messages instead of previous type of parsing, which one of my mentor rightly called "shoe horn" approach, in which I some how managed to fit in the Tiled data into existing GameMaker based Room.proto.

At last I updated RoomView class to display the data from newly added EGMRoom.proto fields. The implementation was mostly based on the existing ProtoRepeatableMessage implementation which isn't optimized for optimal rendering.


Creating a new plugin in Tiled - "Enigma" plugin

Tiled supports importer and exporter functionality through its plugin interface. This plugin implementation can be mostly divided into two parts. First is to import and link libEGM libraries and second is to parse protocol buffer data into Tiled map.

I used Qt .qbs module to import the existing libEGM libraries into this plugin, which proved to be quite helpful in parsing EGM files into known proto buffers.

To parse proto data into Tiled map I referred mapreader class. Mainly I sort of wrote a version of mapreader.cpp which is an xml based reader into a protocol buffer based reader.


Adding merge TMX project into EGM project functionality

To me this seems like the most important feature of this whole GSoC project, because it actually gives user ability to simultaneously work in the same project between enigma's RadialGM and Tiled editors. This feature is added as a "Merge" button in "File" menu.

Here is short sequence of steps a user might follow to use this feature. Let's suppose user is working in a Tiled project saved as TMX file and now wants to create a game out of it in RadialGM(RGM), so user can go ahead and import that TMX file into RGM. Now after a while, user decides to update something in the room so at first this project is saved as EGM file and then can be imported back in Tiled editor using enigma plugin. Now after making the update user saves the project as TMX file, after that "merge" button can be used to copy the updates into existing EGM project in RGM.

So this wraps up my GSoC project and this series of logs. If anyone was following it by any chance, huge thank you to you. Have a nice year ahead!