1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Compare commits

..

3 commits

Author SHA1 Message Date
Emmanouil Papadeas 30eed8ad19
Merge 63f3fa8e0c into c60c62f476 2024-12-27 07:28:59 +00:00
Emmanouil Papadeas 63f3fa8e0c New translations translations.pot (Chinese Simplified) 2024-12-27 09:28:56 +02:00
Emmanouil Papadeas c60c62f476 Fix tileset being completely cleared when resizing a project
Now only remove the tiles that are used so they can be remade as resized tiles. Unused tiles remain in the tileset as is.
2024-12-27 03:30:56 +02:00
4 changed files with 54 additions and 42 deletions

View file

@ -10,7 +10,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Language-Team: Chinese Simplified\n"
"Language: zh_CN\n"
"PO-Revision-Date: 2024-12-16 23:11\n"
"PO-Revision-Date: 2024-12-27 07:28\n"
msgid "OK"
msgstr "确定"
@ -226,7 +226,7 @@ msgstr "初始角度:"
#. Found under the Select menu, It's a checkbox that, if enabled, wraps around brush strokes if some part of them goes out of selection bounds.
msgid "Wrap Strokes"
msgstr ""
msgstr "环绕描边"
msgid "Clear"
msgstr "取消选中"
@ -1181,24 +1181,24 @@ msgstr "色调影响因素:"
#. An image effect that adjusts the colors of the image by using curves.
msgid "Color Curves"
msgstr ""
msgstr "颜色曲线"
#. Refers to a color channel, such as the red, green, blue or alpha channels.
msgid "Channel:"
msgstr ""
msgstr "通道:"
msgid "Red"
msgstr ""
msgstr "红色"
msgid "Green"
msgstr ""
msgstr "绿色"
#. Refers to the value (as in HSV) of the colors of an image.
msgid "Value"
msgstr ""
msgstr ""
msgid "Presets"
msgstr ""
msgstr "预设"
msgid "Apply"
msgstr "应用"
@ -1268,7 +1268,7 @@ msgid "Developed by Orama Interactive"
msgstr "由 Orama Interactive 开发 - 简体中文翻译 By 大眼仔~旭Anan"
msgid "©2019-present by Orama Interactive and contributors"
msgstr "© 版权所有 2019~2024 - Orama Interactive 和贡献者"
msgstr "© 版权所有 2019~2025 - Orama Interactive 和贡献者"
msgid "Website"
msgstr "网站"
@ -1874,7 +1874,7 @@ msgstr "如果启用,应用程序窗口可以变得透明。 这会影响性
#. An option found in the preferences, under the Performance section. A dummy driver is basically a driver that doesn't do anything. When this option is enabled, audio does not play, but it can help save some performance.
msgid "Use dummy audio driver"
msgstr ""
msgstr "使用虚拟音频驱动程序"
#. Found in the Preferences, under Drivers. Specifies the renderer/video driver being used.
msgid "Renderer:"
@ -2311,7 +2311,7 @@ msgstr "取消链接单元格"
#. An option found in the right click menu of an audio cel. If selected, the audio of the audio layer will start playing from this frame.
msgid "Play audio here"
msgstr ""
msgstr "在此处播放音频"
msgid "Properties"
msgstr "属性"
@ -2351,10 +2351,10 @@ 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 ""
msgstr "图块"
msgid "Audio"
msgstr ""
msgstr "音频"
msgid "Layers"
msgstr "图层"
@ -2386,12 +2386,12 @@ msgstr "添加 3D 图层"
#. One of the options of the create new layer button.
#: src/UI/Timeline/AnimationTimeline.tscn
msgid "Add Tilemap Layer"
msgstr ""
msgstr "添加图块图层"
#. One of the options of the create new layer button.
#: src/UI/Timeline/AnimationTimeline.tscn
msgid "Add Audio Layer"
msgstr ""
msgstr "添加音频图层"
#: src/UI/Timeline/AnimationTimeline.tscn
msgid "Remove current layer"
@ -2526,14 +2526,14 @@ msgstr "展开/折叠组"
#. Refers to the audio file of an audio layer.
msgid "Audio file:"
msgstr ""
msgstr "音频文件:"
msgid "Load file"
msgstr ""
msgstr "加载文件"
#. An option in the audio layer properties, allows users to play the audio starting from a specific frame.
msgid "Play at frame:"
msgstr ""
msgstr "在帧中播放:"
msgid "Palette"
msgstr "调色板"
@ -3111,7 +3111,7 @@ msgstr "录制器"
#. Tiles are images of a specific shape, usually rectangular, that are laid out in a grid. They are used in tile-based video games. https://en.wikipedia.org/wiki/Tile-based_video_game
msgid "Tiles"
msgstr ""
msgstr "平铺"
msgid "Crop"
msgstr "裁剪"
@ -3522,47 +3522,47 @@ msgstr "您想从 %s 下载图像吗?"
#: src/Classes/TileSetCustom.gd
#: src/UI/Dialogs/ImportPreviewDialog.gd
msgid "Tileset"
msgstr ""
msgstr "图块集"
#. A tileset is a collection of tiles.
#: src/UI/Timeline/NewTileMapLayerDialog.tscn
msgid "Tileset:"
msgstr ""
msgstr "图块集:"
#. A tileset is a collection of tiles.
#: src/UI/Dialogs/ProjectProperties.tscn
msgid "Tilesets"
msgstr ""
msgstr "图块集"
#: src/UI/Timeline/NewTileMapLayerDialog.tscn
msgid "New tileset"
msgstr ""
msgstr "新建图块集"
#: src/UI/Timeline/NewTileMapLayerDialog.tscn
msgid "Tileset name:"
msgstr ""
msgstr "图块集名称:"
#: src/UI/Timeline/NewTileMapLayerDialog.tscn
msgid "Tile size:"
msgstr ""
msgstr "图块大小:"
#: src/UI/TilesPanel.tscn
msgid "Draw tiles"
msgstr ""
msgstr "绘制图块"
#: src/UI/TilesPanel.tscn
msgid "Rotate tile left (counterclockwise)"
msgstr ""
msgstr "向左旋转图块(逆时针)"
#: src/UI/TilesPanel.tscn
msgid "Rotate tile right (clockwise)"
msgstr ""
msgstr "向右旋转图块(顺时针)"
#: src/UI/TilesPanel.tscn
msgid "Flip tile horizontally"
msgstr ""
msgstr "水平翻转图块"
#: src/UI/TilesPanel.tscn
msgid "Flip tile vertically"
msgstr ""
msgstr "垂直翻转图块"

View file

@ -287,7 +287,10 @@ func open_pxo_file(path: String, is_backup := false, replace_empty := true) -> v
var image := Image.create_from_data(
tile_size.x, tile_size.y, false, new_project.get_image_format(), image_data
)
tileset.add_tile(image, null)
tileset.add_tile(image, null, 0)
for cel in new_project.get_all_pixel_cels():
if cel is CelTileMap:
cel.find_times_used_of_tiles()
zip_reader.close()
new_project.export_directory_path = path.get_base_dir()
@ -878,7 +881,7 @@ func open_image_as_tileset(
Rect2i(frame_width * xx, frame_height * yy, frame_width, frame_height)
)
@warning_ignore("int_as_enum_without_cast")
tileset.add_tile(cropped_image, null)
tileset.add_tile(cropped_image, null, 0)
project.tilesets.append(tileset)
@ -901,7 +904,7 @@ func open_image_as_tileset_smart(
)
cropped_image.blit_rect(image, rect, offset)
@warning_ignore("int_as_enum_without_cast")
tileset.add_tile(cropped_image, null)
tileset.add_tile(cropped_image, null, 0)
project.tilesets.append(tileset)

View file

@ -330,7 +330,7 @@ func serialize_undo_data_source_image(
if source_image.get_size() != image.get_size():
undo_data[self]["resize"] = true
_resize_cells(source_image.get_size())
tileset.clear_tileset(self)
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
@ -352,6 +352,13 @@ func deserialize_undo_data(dict: Dictionary, undo_redo: UndoRedo, undo: bool) ->
undo_redo.add_do_method(tileset.deserialize_undo_data.bind(dict.tileset, self))
## Called when loading a new project. Loops through all [member cells]
## and finds the amount of times each tile from the [member tileset] is being used.
func find_times_used_of_tiles() -> void:
for cell in cells:
tileset.tiles[cell.index].times_used += 1
## Gets called every time a change is being applied to the [param image],
## such as when finishing drawing with a draw tool, or when applying an image effect.
## This method responsible for updating the indices of the [member cells], as well as

View file

@ -16,9 +16,9 @@ var name := ""
var tile_size: Vector2i
## The collection of tiles in the form of an [Array] of type [TileSetCustom.Tile].
var tiles: Array[Tile] = []
## If [code]true[/code], the code in [method clear_tileset] does not execute.
## If [code]true[/code], the code in [method handle_project_resize] does not execute.
## This variable is used to prevent multiple cels from clearing the tileset at the same time.
## In [method clear_tileset], the variable is set to [code]true[/code], and then
## In [method handle_project_resize], the variable is set to [code]true[/code], and then
## immediately set to [code]false[/code] in the next frame using [method Object.set_deferred].
var _tileset_has_been_cleared := false
@ -50,8 +50,9 @@ func _init(_tile_size: Vector2i, _name := "", add_empty_tile := true) -> void:
## Adds a new [param image] as a tile to the tileset.
## The [param cel] parameter references the [CelTileMap] that this change is coming from,
## and the [param edit_mode] parameter contains the tile editing mode at the time of this change.
func add_tile(image: Image, cel: CelTileMap) -> void:
func add_tile(image: Image, cel: CelTileMap, times_used := 1) -> void:
var tile := Tile.new(image)
tile.times_used = times_used
tiles.append(tile)
updated.emit(cel, -1)
@ -115,14 +116,15 @@ func remove_unused_tiles(cel: CelTileMap) -> bool:
return tile_removed
## Clears the tileset. Usually called when the project gets resized,
## Clears the used tiles of tileset. Called when the project gets resized,
## and tilemap cels are updating their size and clearing the tileset to re-create it.
func clear_tileset(cel: CelTileMap) -> void:
func handle_project_resize(cel: CelTileMap) -> void:
if _tileset_has_been_cleared:
return
tiles.clear()
var empty_image := Image.create_empty(tile_size.x, tile_size.y, false, Image.FORMAT_RGBA8)
tiles.append(Tile.new(empty_image))
for i in range(tiles.size() - 1, 0, -1):
var tile := tiles[i]
if tile.times_used > 0:
tiles.erase(tile)
updated.emit(cel, -1)
_tileset_has_been_cleared = true
set_deferred("_tileset_has_been_cleared", false)