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

Properly update the tileset when using any tool

This commit is contained in:
Emmanouil Papadeas 2024-11-24 19:25:58 +02:00
parent b87bfdf7e8
commit 12eda32176
8 changed files with 26 additions and 9 deletions

View file

@ -77,6 +77,10 @@ func update_texture() -> void:
cel.texture_changed.emit()
func tool_finished_drawing() -> void:
pass
## Returns a curated [Dictionary] containing the cel data.
func serialize() -> Dictionary:
var dict := {"opacity": opacity, "z_index": z_index}

View file

@ -29,6 +29,10 @@ func update_texture() -> void:
super.update_texture()
func tool_finished_drawing() -> void:
update_tileset()
func update_tileset() -> void:
for i in indices.size():
var coords := get_tile_coords(i)

View file

@ -128,8 +128,8 @@ func draw_move(pos: Vector2i) -> void:
func draw_end(pos: Vector2i) -> void:
pos = snap_position(pos)
super.draw_end(pos)
if _picking_color:
super.draw_end(pos)
return
if _drawing:
@ -150,6 +150,7 @@ func draw_end(pos: Vector2i) -> void:
_drawing = false
_displace_origin = false
cursor_text = ""
super.draw_end(pos)
func draw_preview() -> void:

View file

@ -76,13 +76,16 @@ func draw_end(_pos: Vector2i) -> void:
is_moving = false
_draw_cache = []
var project := Global.current_project
for cel_index in project.selected_cels:
var cel := project.frames[cel_index[0]].cels[cel_index[1]]
if cel is CelTileMap:
cel.update_tileset()
update_cels(project)
project.can_undo = true
func update_cels(project := Global.current_project) -> void:
for cel_index in project.selected_cels:
var cel := project.frames[cel_index[0]].cels[cel_index[1]] as BaseCel
cel.tool_finished_drawing()
func cursor_move(pos: Vector2i) -> void:
_cursor = pos
if _spacing_mode and is_moving:

View file

@ -120,8 +120,8 @@ func draw_move(pos: Vector2i) -> void:
func draw_end(pos: Vector2i) -> void:
pos = snap_position(pos)
super.draw_end(pos)
if _picking_color:
super.draw_end(pos)
return
if _drawing:
@ -144,6 +144,7 @@ func draw_end(pos: Vector2i) -> void:
_drawing = false
_displace_origin = false
cursor_text = ""
super.draw_end(pos)
func draw_preview() -> void:

View file

@ -70,8 +70,8 @@ func draw_move(pos: Vector2i) -> void:
func draw_end(pos: Vector2i) -> void:
super.draw_end(pos)
if !Global.current_project.layers[Global.current_project.current_layer].can_layer_get_drawn():
super.draw_end(pos)
return
if (
_start_pos != Vector2i(Vector2.INF)
@ -93,6 +93,7 @@ func draw_end(pos: Vector2i) -> void:
_snap_to_grid = false
Global.canvas.sprite_changed_this_frame = true
Global.canvas.measurements.update_measurement(Global.MeasurementMode.NONE)
super.draw_end(pos)
func _move_image(image: Image, pixel_diff: Vector2i) -> void:

View file

@ -104,8 +104,8 @@ func draw_move(pos: Vector2i) -> void:
_offset = pos
func draw_end(_position: Vector2i) -> void:
pass
func draw_end(pos: Vector2i) -> void:
super.draw_end(pos)
func text_to_pixels() -> void:
@ -159,6 +159,7 @@ func text_to_pixels() -> void:
if image is ImageExtended:
image.convert_rgb_to_indexed()
commit_undo("Draw", undo_data)
update_cels(project)
func commit_undo(action: String, undo_data: Dictionary) -> void:

View file

@ -517,6 +517,7 @@ func transform_content_confirm() -> void:
big_bounding_rectangle.position
)
cel_image.convert_rgb_to_indexed()
cel.tool_finished_drawing()
project.selection_map.move_bitmap_values(project)
commit_undo("Move Selection", undo_data)
@ -552,6 +553,7 @@ func transform_content_cancel() -> void:
big_bounding_rectangle.position
)
cel.transformed_content = null
cel.tool_finished_drawing()
for cel_index in project.selected_cels:
canvas.update_texture(cel_index[1])
original_preview_image = Image.new()