tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Automap input on layers with the same name

Open Deadarius opened this issue 10 years ago • 4 comments

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.

Deadarius avatar May 13 '14 11:05 Deadarius

That should indeed be the case. I'll debug into it tonight. Do you have an example at hands?

stefanbeller avatar May 13 '14 14:05 stefanbeller

I've just edited sewers map from examples: https://dl.dropboxusercontent.com/u/17056327/sewers2.tmx

Deadarius avatar May 13 '14 19:05 Deadarius

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.

stefanbeller avatar May 14 '16 06:05 stefanbeller

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 the inputnot_Surface.
  • For each of the layers named "Surface" that match input_Surface and that don't match inputnot_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.

bjorn avatar Apr 05 '22 09:04 bjorn