1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-03-14 07:15:19 +00:00

Do not modify the tileset when resizing the canvas, if the tilemap cel content has not been offset

This commit is contained in:
Emmanouil Papadeas 2025-03-12 16:02:04 +02:00
parent 2f4567068a
commit 065c8d4821
2 changed files with 14 additions and 3 deletions

View file

@ -723,7 +723,14 @@ func resize_canvas(width: int, height: int, offset_x: int, offset_y: int) -> voi
)
resized.convert_rgb_to_indexed()
if cel is CelTileMap:
(cel as CelTileMap).serialize_undo_data_source_image(resized, redo_data, undo_data)
var tilemap_cel := cel as CelTileMap
var skip_tileset := (
offset_x % tilemap_cel.tileset.tile_size.x == 0
and offset_y % tilemap_cel.tileset.tile_size.y == 0
)
tilemap_cel.serialize_undo_data_source_image(
resized, redo_data, undo_data, skip_tileset
)
resized.add_data_to_dictionary(redo_data, cel_image)
cel_image.add_data_to_dictionary(undo_data)

View file

@ -305,13 +305,17 @@ func serialize_undo_data() -> Dictionary:
## ([param source_image]) we want to store to the undo/redo stack
## is not the same as [member image]. This method also handles the resizing logic for undo/redo.
func serialize_undo_data_source_image(
source_image: ImageExtended, redo_data: Dictionary, undo_data: Dictionary
source_image: ImageExtended,
redo_data: Dictionary,
undo_data: Dictionary,
skip_tileset_resize := false
) -> void:
undo_data[self] = serialize_undo_data()
if source_image.get_size() != image.get_size():
undo_data[self]["resize"] = true
_resize_cells(source_image.get_size())
tileset.handle_project_resize(self)
if not skip_tileset_resize:
tileset.handle_project_resize(self)
var tile_editing_mode := TileSetPanel.tile_editing_mode
if tile_editing_mode == TileSetPanel.TileEditingMode.MANUAL:
tile_editing_mode = TileSetPanel.TileEditingMode.AUTO