CGE Editor: Added TiledMapControl, unit has to be added manually?

Hi there,
playing around with the editor to examine what it can do and what it cannot do atm.

On adding a TiledMapControl via the CGE Editor (state_main.castle-user-interface), the corresponding source file (gamestatemain.pas) hasn’t been updated to add the corresponding unit (CastleTiledMap) to the uses clause. This lead to an execution error (JSON couldn’t find class decl. of component). After adding it manually, it runs fine.

I wondered, if this is intentionally? (I would expect the editor to add the corresponding units automatically, right? - Feature for the future?)

Have a nice day and keep the great work up!

Indeed, it is not implemented yet. Right now the editor doesn’t touch the Pascal code at all, so you have to do some things manually,

  • like adding units to uses clause, to make sure all relevant components are available at runtime
  • finding the components by name
  • assigning events like OnClick to buttons

This is all planned to be done (Lazarus does it, so we know we can :slight_smile: ), although after CGE 7.0 release.

In case of units, you will need to add them to uses clause anyway to declare e.g. a private field of type TCastleTiledMapControl. But indeed it can be surprising, if you just add the control and want to rerun the application to see it works, before adding code to deal with the map. Hm, I can easily improve the error message in this case, to point you toward the solution, I’ll do it later today :slight_smile:

This explains everything :slight_smile: , thanks!
And improving the error message may help some. :thinking: