Do you want to work on this issue?
You can request for a bounty in order to promote it!
Automapping: Allow addressing selected layer and layers relative to it #3238
eishiya posted onGitHub
Automapping currently requires that input and output layers target specific layers by name. This means that if a rule should be applied to multiple layers in a map, those layers need to all have unique names, and need to have copies of every rule targeting them, or the user has to temporarily rename each layer one by one to make it the target of the rule(s) and apply Automapping repeatedly. Neither is great.
In addition to name-based matching, I think Automapping should support some way to address the current layers and layers relative to it, e.g.
input_CURRENT+1 (layer above the current layer) input_CURRENT input_CURRENT-2 (the layer two below the current layer) output_CURRENT+1
This approach should be usable in tandem with named layers:
input_Colour Guide input_CURRENT output_CURRENT
What counts as the "current" layer depends on what was selected when the user applied the Automap. If only one layer is selected, that layer will be CURRENT. This would be the most common scenario, especially for Automap While Drawing. If multiple layers are selected, each selected layer gets to be CURRENT in turn, allowing the same rules to be applied to multiple layers at once. If no layers are selected, then rules containing any references to CURRENT do not run. Edit: Or perhaps every layer in the map should get a chance to be CURRENT, regardless of selection, if performance allows. Maybe there could be some way to select this as a global Tiled setting? Would love to hear input on which behaviour is more useful to other users.
Although I used input|output_CURRENT
in the examples above, I'm not attached to that naming. Anything that makes it clear that it's not referring to a named layer would work (maybe *
to avoid being tied to English so much?). However, in the unlikely scenario that the map contains a layer that exactly matches the text used to match the current layer, I think name-based matching should take priority. I don't know what should be done with CURRENT+/-X in that case. Perhaps +/-X could be implemented for the general case, working even with named layers, e.g. input_Guide+1 would look at the layer above "Guide". Of course, name-based matching should again take priority, so if a map contains a layer named "Guide+1", that should be used.
This suggestion is possibly related to #429. However, where they're looking for matches on any layer regardless of order, this approach allows keeping layer structure in mind without having to get specific with names. These two approaches could work in tandem, allowing a rule like "if the current layer contains tile A and any layer contains tile B in this spot", which can be useful when using symbolic tiles where their meaning doesn't depend on the layer.