From a9946099ef1e50e84b357bac909229f853bd5ce3 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 30 Nov 2024 12:48:54 +0200 Subject: [PATCH] Add get_text_info() in TileSetCustom --- Translations/Translations.pot | 5 +++++ src/Classes/TileSetCustom.gd | 9 +++++++++ src/UI/Timeline/NewTileMapLayerDialog.gd | 5 +---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Translations/Translations.pot b/Translations/Translations.pot index c59b716d3..e0a6358ff 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -2239,6 +2239,10 @@ msgstr "" msgid "Group" msgstr "" +#. A tilemap is a type of layer, which is divided by grid cells, the size of which is determined by the tileset it uses. Each grid cell is mapped to a tile in the tileset. Tilemaps can be used to create game levels and layouts. +msgid "Tilemap" +msgstr "" + msgid "Layers" msgstr "" @@ -3381,6 +3385,7 @@ msgid "Do you want to download the image from %s?" msgstr "" #. A tileset is a collection of tiles. +#: src/Classes/TileSetCustom.gd #: src/UI/Dialogs/ImportPreviewDialog.gd msgid "Tileset" msgstr "" diff --git a/src/Classes/TileSetCustom.gd b/src/Classes/TileSetCustom.gd index 96f25ef2a..362ef67ea 100644 --- a/src/Classes/TileSetCustom.gd +++ b/src/Classes/TileSetCustom.gd @@ -127,6 +127,15 @@ func clear_tileset(cel: CelTileMap) -> void: set_deferred("_tileset_has_been_cleared", false) +## Returns the tilemap's info, such as its name and tile size and with a given +## [param tile_index], in the form of text. +func get_text_info(tile_index: int) -> String: + var item_string := " %s (%s×%s)" % [tile_index, tile_size.x, tile_size.y] + if not name.is_empty(): + item_string += ": " + name + return tr("Tileset") + item_string + + ## Serializes the data of this class into the form of a [Dictionary], ## which is used so the data can be stored in pxo files. func serialize() -> Dictionary: diff --git a/src/UI/Timeline/NewTileMapLayerDialog.gd b/src/UI/Timeline/NewTileMapLayerDialog.gd index 0c4020d03..6fe79e281 100644 --- a/src/UI/Timeline/NewTileMapLayerDialog.gd +++ b/src/UI/Timeline/NewTileMapLayerDialog.gd @@ -33,10 +33,7 @@ func _on_about_to_popup() -> void: tileset_option_button.add_item("New tileset") for i in project.tilesets.size(): var tileset := project.tilesets[i] - var item_string := " %s (%s×%s)" % [i, tileset.tile_size.x, tileset.tile_size.y] - if not tileset.name.is_empty(): - item_string += ": " + tileset.name - tileset_option_button.add_item(tr("Tileset" + item_string)) + tileset_option_button.add_item(tileset.get_text_info(i)) _on_tileset_option_button_item_selected(tileset_option_button.selected)