From d41037d2df3cdb264e4223232da3f6a8afc71588 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:06:23 +0200 Subject: [PATCH] Fix tilemap manual editing mode not working with shape & text tools, and fixed issues with the pencil tool Not the most performance-friendly solution, but it works. If users encounter performance issues in the future, we should rewrite this, as it does the same for loop two times. --- src/Classes/Cels/CelTileMap.gd | 21 +++++++++++++++------ src/Tools/BaseDraw.gd | 1 + src/Tools/UtilityTools/Text.gd | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Classes/Cels/CelTileMap.gd b/src/Classes/Cels/CelTileMap.gd index 4cf9e75f8..0c6da9451 100644 --- a/src/Classes/Cels/CelTileMap.gd +++ b/src/Classes/Cels/CelTileMap.gd @@ -656,6 +656,21 @@ func update_texture(undo := false) -> void: var tile_size := current_tile.image.get_size() image.blit_rect(current_tile.image, Rect2i(Vector2i.ZERO, tile_size), coords) continue + if not editing_images.has(index): + if not _tiles_equal(i, image_portion, current_tile.image): + var transformed_image := transform_tile( + image_portion, cell_data.flip_h, cell_data.flip_v, cell_data.transpose, true + ) + editing_images[index] = [i, transformed_image] + + for i in cells.size(): + var cell_data := cells[i] + var index := cell_data.index + if index >= tileset.tiles.size(): + index = 0 + var coords := get_cell_coords_in_image(i) + var rect := Rect2i(coords, tileset.tile_size) + var image_portion := image.get_region(rect) if editing_images.has(index): var editing_portion := editing_images[index][0] as int if i == editing_portion: @@ -670,12 +685,6 @@ func update_texture(undo := false) -> void: if not image_portion.get_data() == transformed_editing_image.get_data(): var tile_size := image_portion.get_size() image.blit_rect(transformed_editing_image, Rect2i(Vector2i.ZERO, tile_size), coords) - else: - if not _tiles_equal(i, image_portion, current_tile.image): - var transformed_image := transform_tile( - image_portion, cell_data.flip_h, cell_data.flip_v, cell_data.transpose, true - ) - editing_images[index] = [i, transformed_image] super.update_texture(undo) diff --git a/src/Tools/BaseDraw.gd b/src/Tools/BaseDraw.gd index 14e65badb..aa2d2d8a3 100644 --- a/src/Tools/BaseDraw.gd +++ b/src/Tools/BaseDraw.gd @@ -276,6 +276,7 @@ func prepare_undo(action: String) -> void: func commit_undo() -> void: var project := Global.current_project + Global.canvas.update_selected_cels_textures(project) project.update_tilemaps(_undo_data) var redo_data := _get_undo_data() var frame := -1 diff --git a/src/Tools/UtilityTools/Text.gd b/src/Tools/UtilityTools/Text.gd index 20fa26783..fe7b583b2 100644 --- a/src/Tools/UtilityTools/Text.gd +++ b/src/Tools/UtilityTools/Text.gd @@ -163,6 +163,7 @@ func text_to_pixels() -> void: func commit_undo(action: String, undo_data: Dictionary) -> void: var project := Global.current_project + Global.canvas.update_selected_cels_textures(project) project.update_tilemaps(undo_data) var redo_data := _get_undo_data() var frame := -1