tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Copy/paste a layer

Open EdenIndustries opened this issue 8 years ago • 3 comments

It would be very useful if a layer (or ideally, multiple layers) could be copied and then inserted at a specified point in the layer list. And in particular it would be especially useful if the destination level could be different than the source level that the copied layer is from.

EdenIndustries avatar Dec 04 '15 20:12 EdenIndustries

I have a script that accomplishes this: https://github.com/eishiya/tiled-scripts/blob/main/CopyPasteLayers.js

Of course, I still think this should be a built-in feature, perhaps also with the option to expand the destination map if it's finite and any of the pasted tile layers go outside its bounds (including in the negative direction).

eishiya avatar Mar 14 '22 00:03 eishiya

including in the negative direction

Hmm, that can only happen when pasting a layer from an infinite map to a finite map. Should this turn the map infinite, or should it just shift that layer into the positive coordinate space, possibly applying that same shift to all other pasted layers? Grr, corner cases...

bjorn avatar Mar 14 '22 11:03 bjorn

That was an issue I didn't want to tackle in my script, ngl 🤣 There are no fewer than five ways pasting content with negative tiles into a finite map can go:

  1. Don't expand the map, ignore ALL out of bounds content
  2. Expand the map to accommodate positive tiles, but lose the negative tiles
  3. Shift over only the pasted layers, expanding the map to accomodate them
  4. Shift over the pasted layers AND all existing layers, so alignment is retained. Object layers will need to be moved too.
  5. Make the destination map infinite

(2) is the only one that's likely to never be desirable, so that leaves 4 worthwhile options, which is probably too many to offer as a prompt :|

Edit: My script pastes all the content out of bounds and leaves it up to the user to handle this. Perhaps this but with a warning would be adequate? Maybe a general warning that appears at any time that a finite map contains tiles out of bounds, as may happen from scripts as well. Something like: "Warning: Map contains tiles out of bounds. This tile data will be not be written out when the map is saved. Consider resizing the map to fit the tiles, or making it infinite." Clicking the warning could pop up the Resize Map dialogue prepopulated with a new size and offset that would fit all the tiles, and show the Map Properties in the properties panel, in case the user would prefer to set it to infinite instead.

eishiya avatar Mar 14 '22 14:03 eishiya