Allow layers to be handled differently in different levels (including duplicates and different orders) #1166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
__identifierfield of exported layer-instances will no longer be identical to the layer-definition'sidentifierfield. It instead holds the name of the layer-instance, which must be unique in the level. The layer-definition can be found using thelayerDefUidfield.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
LtoD), and a new "Layers" panel is introduced (with shortcutL) 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