1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-19 09:39:48 +00:00

Add get_text_info() in TileSetCustom

This commit is contained in:
Emmanouil Papadeas 2024-11-30 12:48:54 +02:00
parent 8346b465b6
commit a9946099ef
3 changed files with 15 additions and 4 deletions

View file

@ -2239,6 +2239,10 @@ msgstr ""
msgid "Group" msgid "Group"
msgstr "" 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" msgid "Layers"
msgstr "" msgstr ""
@ -3381,6 +3385,7 @@ msgid "Do you want to download the image from %s?"
msgstr "" msgstr ""
#. A tileset is a collection of tiles. #. A tileset is a collection of tiles.
#: src/Classes/TileSetCustom.gd
#: src/UI/Dialogs/ImportPreviewDialog.gd #: src/UI/Dialogs/ImportPreviewDialog.gd
msgid "Tileset" msgid "Tileset"
msgstr "" msgstr ""

View file

@ -127,6 +127,15 @@ func clear_tileset(cel: CelTileMap) -> void:
set_deferred("_tileset_has_been_cleared", false) 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], ## Serializes the data of this class into the form of a [Dictionary],
## which is used so the data can be stored in pxo files. ## which is used so the data can be stored in pxo files.
func serialize() -> Dictionary: func serialize() -> Dictionary:

View file

@ -33,10 +33,7 @@ func _on_about_to_popup() -> void:
tileset_option_button.add_item("New tileset") tileset_option_button.add_item("New tileset")
for i in project.tilesets.size(): for i in project.tilesets.size():
var tileset := project.tilesets[i] var tileset := project.tilesets[i]
var item_string := " %s (%s×%s)" % [i, tileset.tile_size.x, tileset.tile_size.y] tileset_option_button.add_item(tileset.get_text_info(i))
if not tileset.name.is_empty():
item_string += ": " + tileset.name
tileset_option_button.add_item(tr("Tileset" + item_string))
_on_tileset_option_button_item_selected(tileset_option_button.selected) _on_tileset_option_button_item_selected(tileset_option_button.selected)