You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modifying a TileMap with LayerEdit.apply() doesn't trigger Automap While Drawing. Changes made with TileMap.merge() do trigger it.
Here's my code that handles click+drag painting, this is part of Tool.tilePositionChanged. Since the mouse is held down and no preview is necessary, this code paints to the layer immediately instead of creating and merging a preview.
if(this.paintingDrag){letline=Geometry.pointsOnLine(this.lastPosition,newPosition);letlayer=this.map.selectedLayers[0];letlayerEdit=layer.edit();layerEdit.mergeable=true;//This doesn't affect the bug, it's the same with mergeable = false too.letfullTile=this.getSlopeTile(0,0,Qt.AlignBottom);//this just tells us which tile to paintfor(letpointofline){layerEdit.setTile(point.x,point.y,fullTile? fullTile.tile : null,fullTile? fullTile.flags : 0);}layerEdit.apply();}
Here's what the behaviour looks like, with an Automapping rule that replaces the green tile with a brown tile. In this case, one tile gets Automapped, the start of the stroke - this single tile is placed with TileMap.merge() in mousePressed, rather than LayerEdit.apply(). The tiles that remain green are the ones placed by apply() in the snippet above.
For comparison, here is the same green tile being drawn with Tiled's Stamp Brush tool rather than with a scripted tool. This is the behaviour I expected even with a scripted tool, all the tiles get Automapped:
Edit: On Discord, bjorn mentioned that he was reluctant to emit the regionEdited signal (which is used for Automap While Drawing) on apply() due to the potential for infinite loops as scripts can also listen to this signal. However, this issue exists with map.merge() as well, which does emit it. A potential solution is to provide a parameter for apply() and merge() that determines whether regionEdited is emitted. This way, scripts that don't listen for the signal (such as tools) can emit it if they want, while scripts that listen for regionEdited have a way to avoid emitting it.
The text was updated successfully, but these errors were encountered:
Modifying a TileMap with LayerEdit.apply() doesn't trigger Automap While Drawing. Changes made with TileMap.merge() do trigger it.
Here's my code that handles click+drag painting, this is part of Tool.tilePositionChanged. Since the mouse is held down and no preview is necessary, this code paints to the layer immediately instead of creating and merging a preview.
Here's what the behaviour looks like, with an Automapping rule that replaces the green tile with a brown tile. In this case, one tile gets Automapped, the start of the stroke - this single tile is placed with TileMap.merge() in mousePressed, rather than LayerEdit.apply(). The tiles that remain green are the ones placed by apply() in the snippet above.
For comparison, here is the same green tile being drawn with Tiled's Stamp Brush tool rather than with a scripted tool. This is the behaviour I expected even with a scripted tool, all the tiles get Automapped:
Edit: On Discord, bjorn mentioned that he was reluctant to emit the regionEdited signal (which is used for Automap While Drawing) on apply() due to the potential for infinite loops as scripts can also listen to this signal. However, this issue exists with map.merge() as well, which does emit it. A potential solution is to provide a parameter for apply() and merge() that determines whether regionEdited is emitted. This way, scripts that don't listen for the signal (such as tools) can emit it if they want, while scripts that listen for regionEdited have a way to avoid emitting it.
The text was updated successfully, but these errors were encountered: