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

Fix undo/redo history not working when the tool changes

This commit is contained in:
Emmanouil Papadeas 2023-10-02 17:20:24 +03:00
parent e9e80e2a06
commit 331c46c8ee
2 changed files with 14 additions and 14 deletions

View file

@ -689,3 +689,15 @@ func path_join_array(basepaths: PackedStringArray, subpath: String) -> PackedStr
for _path in basepaths:
res.append(_path.path_join(subpath))
return res
func undo_redo_draw_op(
image: Image, compressed_image_data: PackedByteArray, buffer_size: int
) -> void:
image.set_data(
image.get_width(),
image.get_height(),
image.has_mipmaps(),
image.get_format(),
compressed_image_data.decompress(buffer_size)
)

View file

@ -217,14 +217,14 @@ func commit_undo() -> void:
var buffer_size: int = compressed_data["data"].size()
compressed_data["data"] = compressed_data["data"].compress()
project.undo_redo.add_do_method(
undo_redo_draw_op.bind(image, compressed_data["data"], buffer_size)
Global.undo_redo_draw_op.bind(image, compressed_data["data"], buffer_size)
)
for image in _undo_data:
var compressed_data: Dictionary = _undo_data[image]
var buffer_size: int = compressed_data["data"].size()
compressed_data["data"] = compressed_data["data"].compress()
project.undo_redo.add_undo_method(
undo_redo_draw_op.bind(image, compressed_data["data"], buffer_size)
Global.undo_redo_draw_op.bind(image, compressed_data["data"], buffer_size)
)
project.undo_redo.add_do_method(Global.undo_or_redo.bind(false, frame, layer))
project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true, frame, layer))
@ -233,18 +233,6 @@ func commit_undo() -> void:
_undo_data.clear()
func undo_redo_draw_op(
image: Image, compressed_image_data: PackedByteArray, buffer_size: int
) -> void:
image.set_data(
image.get_width(),
image.get_height(),
image.has_mipmaps(),
image.get_format(),
compressed_image_data.decompress(buffer_size)
)
func draw_tool(pos: Vector2i) -> void:
if Global.mirror_view:
# Even brushes are not perfectly centred and are offsetted by 1 px so we add it