mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Compare commits
3 commits
b7c34f4233
...
d41037d2df
Author | SHA1 | Date | |
---|---|---|---|
d41037d2df | |||
65e907e1d2 | |||
e5c7d46997 |
|
@ -656,6 +656,21 @@ func update_texture(undo := false) -> void:
|
||||||
var tile_size := current_tile.image.get_size()
|
var tile_size := current_tile.image.get_size()
|
||||||
image.blit_rect(current_tile.image, Rect2i(Vector2i.ZERO, tile_size), coords)
|
image.blit_rect(current_tile.image, Rect2i(Vector2i.ZERO, tile_size), coords)
|
||||||
continue
|
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):
|
if editing_images.has(index):
|
||||||
var editing_portion := editing_images[index][0] as int
|
var editing_portion := editing_images[index][0] as int
|
||||||
if i == editing_portion:
|
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():
|
if not image_portion.get_data() == transformed_editing_image.get_data():
|
||||||
var tile_size := image_portion.get_size()
|
var tile_size := image_portion.get_size()
|
||||||
image.blit_rect(transformed_editing_image, Rect2i(Vector2i.ZERO, tile_size), coords)
|
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)
|
super.update_texture(undo)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ var tileset: TileSetCustom
|
||||||
func _init(_project: Project, _tileset: TileSetCustom, _name := "") -> void:
|
func _init(_project: Project, _tileset: TileSetCustom, _name := "") -> void:
|
||||||
super._init(_project, _name)
|
super._init(_project, _name)
|
||||||
tileset = _tileset
|
tileset = _tileset
|
||||||
if not project.tilesets.has(tileset):
|
if not project.tilesets.has(tileset) and is_instance_valid(tileset):
|
||||||
project.add_tileset(tileset)
|
project.add_tileset(tileset)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,7 @@ func deserialize(dict: Dictionary, zip_reader: ZIPReader = null, file: FileAcces
|
||||||
if dict.has("tilesets"):
|
if dict.has("tilesets"):
|
||||||
for saved_tileset in dict["tilesets"]:
|
for saved_tileset in dict["tilesets"]:
|
||||||
var tile_size = str_to_var("Vector2i" + saved_tileset.get("tile_size"))
|
var tile_size = str_to_var("Vector2i" + saved_tileset.get("tile_size"))
|
||||||
var tileset := TileSetCustom.new(tile_size)
|
var tileset := TileSetCustom.new(tile_size, "", false)
|
||||||
tileset.deserialize(saved_tileset)
|
tileset.deserialize(saved_tileset)
|
||||||
tilesets.append(tileset)
|
tilesets.append(tileset)
|
||||||
if dict.has("frames") and dict.has("layers"):
|
if dict.has("frames") and dict.has("layers"):
|
||||||
|
|
|
@ -39,11 +39,12 @@ class Tile:
|
||||||
return times_used <= 0
|
return times_used <= 0
|
||||||
|
|
||||||
|
|
||||||
func _init(_tile_size: Vector2i, _name := "") -> void:
|
func _init(_tile_size: Vector2i, _name := "", add_empty_tile := true) -> void:
|
||||||
tile_size = _tile_size
|
tile_size = _tile_size
|
||||||
name = _name
|
name = _name
|
||||||
var empty_image := Image.create_empty(tile_size.x, tile_size.y, false, Image.FORMAT_RGBA8)
|
if add_empty_tile:
|
||||||
tiles.append(Tile.new(empty_image))
|
var empty_image := Image.create_empty(tile_size.x, tile_size.y, false, Image.FORMAT_RGBA8)
|
||||||
|
tiles.append(Tile.new(empty_image))
|
||||||
|
|
||||||
|
|
||||||
## Adds a new [param image] as a tile to the tileset.
|
## Adds a new [param image] as a tile to the tileset.
|
||||||
|
|
|
@ -276,6 +276,7 @@ func prepare_undo(action: String) -> void:
|
||||||
|
|
||||||
func commit_undo() -> void:
|
func commit_undo() -> void:
|
||||||
var project := Global.current_project
|
var project := Global.current_project
|
||||||
|
Global.canvas.update_selected_cels_textures(project)
|
||||||
project.update_tilemaps(_undo_data)
|
project.update_tilemaps(_undo_data)
|
||||||
var redo_data := _get_undo_data()
|
var redo_data := _get_undo_data()
|
||||||
var frame := -1
|
var frame := -1
|
||||||
|
|
|
@ -163,6 +163,7 @@ func text_to_pixels() -> void:
|
||||||
|
|
||||||
func commit_undo(action: String, undo_data: Dictionary) -> void:
|
func commit_undo(action: String, undo_data: Dictionary) -> void:
|
||||||
var project := Global.current_project
|
var project := Global.current_project
|
||||||
|
Global.canvas.update_selected_cels_textures(project)
|
||||||
project.update_tilemaps(undo_data)
|
project.update_tilemaps(undo_data)
|
||||||
var redo_data := _get_undo_data()
|
var redo_data := _get_undo_data()
|
||||||
var frame := -1
|
var frame := -1
|
||||||
|
|
Loading…
Reference in a new issue