2019-12-29 22:24:37 +00:00
|
|
|
extends ConfirmationDialog
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2019-12-29 22:24:37 +00:00
|
|
|
func _on_ScaleImage_confirmed() -> void:
|
|
|
|
var width : int = $VBoxContainer/OptionsContainer/WidthValue.value
|
|
|
|
var height : int = $VBoxContainer/OptionsContainer/HeightValue.value
|
|
|
|
var interpolation : int = $VBoxContainer/OptionsContainer/InterpolationType.selected
|
|
|
|
Global.undos += 1
|
|
|
|
Global.undo_redo.create_action("Scale")
|
|
|
|
|
2020-05-11 14:43:58 +00:00
|
|
|
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()
|
2020-06-01 15:50:31 +00:00
|
|
|
sprite.copy_from(c.layers[i].image)
|
2020-05-11 14:43:58 +00:00
|
|
|
sprite.resize(width, height, interpolation)
|
2020-06-01 15:50:31 +00:00
|
|
|
Global.undo_redo.add_do_property(c.layers[i].image, "data", sprite.data)
|
|
|
|
Global.undo_redo.add_undo_property(c.layers[i].image, "data", c.layers[i].image.data)
|
2020-05-11 14:43:58 +00:00
|
|
|
Global.undo_redo.add_undo_property(c, "size", c.size)
|
2019-12-29 22:24:37 +00:00
|
|
|
|
2020-05-11 14:43:58 +00:00
|
|
|
Global.undo_redo.add_undo_method(Global, "undo", Global.canvases)
|
|
|
|
Global.undo_redo.add_do_method(Global, "redo", Global.canvases)
|
2019-12-29 22:24:37 +00:00
|
|
|
Global.undo_redo.commit_action()
|