From 7893ae2531853e2884b2acfd3a28456e86114fb7 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 21 Nov 2024 17:19:06 +0200 Subject: [PATCH] Make manual mode work when the tileset is empty --- src/Classes/Cels/CelTileMap.gd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Classes/Cels/CelTileMap.gd b/src/Classes/Cels/CelTileMap.gd index f4a645c24..0812b77d9 100644 --- a/src/Classes/Cels/CelTileMap.gd +++ b/src/Classes/Cels/CelTileMap.gd @@ -47,6 +47,9 @@ func update_tileset() -> void: var index := indices[i] if tile_editing_mode == TileEditingMode.MANUAL: if index == 0 or tileset.tiles.size() <= index: + if tileset.tiles.size() <= 1: + tileset.add_tile(image_portion) + indices[i] = tileset.tiles.size() - 1 continue if image_portion.get_data() != tileset.tiles[index].get_data(): tileset.replace_tile_at(image_portion, index) @@ -62,7 +65,7 @@ func update_tileset() -> void: if not found_tile: if removed_tile_indices.is_empty(): tileset.add_tile(image_portion) - indices[i] = tileset.tiles.size() + indices[i] = tileset.tiles.size() - 1 else: var index_position := removed_tile_indices.pop_back() as int tileset.insert_tile(image_portion, index_position)