From 74f3644e176498f6835da5c83f20ded3d13a7130 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Mon, 11 May 2020 17:43:58 +0300 Subject: [PATCH] Made "Scale Image" affect all frames --- src/UI/Dialogs/ScaleImage.gd | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/UI/Dialogs/ScaleImage.gd b/src/UI/Dialogs/ScaleImage.gd index b49f4ec91..de4cbfd62 100644 --- a/src/UI/Dialogs/ScaleImage.gd +++ b/src/UI/Dialogs/ScaleImage.gd @@ -7,15 +7,17 @@ func _on_ScaleImage_confirmed() -> void: var interpolation : int = $VBoxContainer/OptionsContainer/InterpolationType.selected Global.undos += 1 Global.undo_redo.create_action("Scale") - Global.undo_redo.add_do_property(Global.canvas, "size", Vector2(width, height).floor()) - for i in range(Global.canvas.layers.size() - 1, -1, -1): - var sprite : Image = Global.canvas.layers[i][1].get_data() - sprite.resize(width, height, interpolation) - Global.undo_redo.add_do_property(Global.canvas.layers[i][0], "data", sprite.data) - Global.undo_redo.add_undo_property(Global.canvas.layers[i][0], "data", Global.canvas.layers[i][0].data) + for c in Global.canvases: + Global.undo_redo.add_do_property(c, "size", Vector2(width, height).floor()) + for i in range(c.layers.size() - 1, -1, -1): + var sprite := Image.new() + sprite.copy_from(c.layers[i][0]) + sprite.resize(width, height, interpolation) + Global.undo_redo.add_do_property(c.layers[i][0], "data", sprite.data) + Global.undo_redo.add_undo_property(c.layers[i][0], "data", c.layers[i][0].data) + Global.undo_redo.add_undo_property(c, "size", c.size) - Global.undo_redo.add_undo_property(Global.canvas, "size", Global.canvas.size) - Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas]) - Global.undo_redo.add_do_method(Global, "redo", [Global.canvas]) + Global.undo_redo.add_undo_method(Global, "undo", Global.canvases) + Global.undo_redo.add_do_method(Global, "redo", Global.canvases) Global.undo_redo.commit_action()