tiled
tiled copied to clipboard
Automap input on layers with the same name
If I have a map with multiple layers with the same name, let's say Surface. In rule file I have layer input_Surface. Then automapping feature is working with only first of Surface layers in the map. It would be nice if it was checking all layers with expected name.
That should indeed be the case. I'll debug into it tonight. Do you have an example at hands?
I've just edited sewers map from examples: https://dl.dropboxusercontent.com/u/17056327/sewers2.tmx
The problem is in AutoMapper::applyRule as it has
foreach (const QString &name, ii.names) {
const int i = mMapWork->indexOfLayer(name, Layer::TileLayerType);
...
const TileLayer *setLayer = mMapWork->layerAt(i)->asTileLayer();
Instead of indexOfLayer we would need to loop through all indexes where the name matches.
What would be the expected behavior in case there are multiple layers named "Surface"? I can think of at least two options:
- The rule matches if any of the layers named "Surface" match
input_Surface
and none of them match theinputnot_Surface
. - For each of the layers named "Surface" that match
input_Surface
and that don't matchinputnot_Surface
, the rule matches.
It seems to me that which of these two makes sense really depends on where the output will go. In case of output_Surface
, one may expect the second behavior, with "Surface" referring to the same layer that matched the input. Whereas in case we have output_SomeOtherLayer
, only a single match makes sense.
Another consideration is how should this behave in case of additional input or output layers, which may in turn also occur multiple times in the target map? I think in this case only the first option could be reasonably supported.