Skip to content

Conversation

@Maximilian-Seitz
Copy link

@Maximilian-Seitz Maximilian-Seitz commented Apr 20, 2025

Sometimes it may be of interest for a level to have a layer multiple times, or in a different order than in the project-wide layer definitions. Example for this include layers with complex auto-tile rules, which may want to be used multiple times in a single level. Duplicating these layers in the project itself means that any changes need to be replicated, and that it'll exist project-wide, which isn't very dynamic.

This pull-request allows for independent management of layers per level. Each level's layers (layer-instances) still refer to the project-wide layers (layer-definitions), but each layer-definition may be used as often, and in whatever order required.

In order to manage these layer-instances, a new panel is added, where they can be configured. Outside of that panel, the editor should work the same way, and the exported files should be backwards compatible. The only difference for normal usage is currently that a new level won't include every layer by default (feedback on this behavior would be welcome; maybe a project setting could be added to toggle this, if desired).

Export differences

The exported files should be equivalent, as long as no new features are used. Once new features are used, the __identifier field of exported layer-instances will no longer be identical to the layer-definition's identifier field. It instead holds the name of the layer-instance, which must be unique in the level. The layer-definition can be found using the layerDefUid field.

The order of layer-instances may, of course, also change now.

Functionality differences

The layer panels

The old "Layers" panel is renamed "Layer definitions" (the shortcut changed from L to D), and a new "Layers" panel is introduced (with shortcut L) for modifying layer-instances in the current level.

The new layers panel is currently only used for basic configurations of layers. This includes creating new ones, copy/pasting/duplicating them, sorting and configuring them. The configuration is mostly limited to an identifier for each layer-instance and the visibility. But this editor provides a framework for future additions, like individual overrides for rendering offsets, opacity, etc. This may also be useful for individual layer-instance annotation with meta-data (like requested in #731). Configurations like these are out of scope for this pull-request, however, since they result in more fundamental changes in the export outputs, and would require the JSON format to change.

It would also be useful to be able to designate specific layer-instances for auto-tile layers, and kill-tile layers. Both of these currently use all the layer-instances of the specified layer-definition. The auto-tile layer sources will all be rendered in their rendering order, not interfering with each other. The kill-tile sources will all be used to remove tiles. Filters by layer-instance tags, or selecting specific layer-instances for both of these options would both help these features become more useful fairly easily. This was also out of scope of this pull-request.

Existing features

The functionality to move entities from one layer-definition to another no longer makes sense, since a single layer-definition can have multiple layer-instances. The entities would therefore be moved to an arbitrary one. This feature is therefore moved to each layer-instance (see screenshots below), where entities may be moved to another layer-instance in the same level.

Screenshots

"Layer definitions" panel in menu-bar "Layers" panel in menu-bar
Opened "Layers" panel example

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.

1 participant