From 90d02ad75be39b8eb5668e679efec77a3c983ffa Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 24 Jun 2020 04:02:19 +0300 Subject: [PATCH] Have the ResizeCanvas width & height values the same as the project's size the first time --- src/UI/Dialogs/ResizeCanvas.gd | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/UI/Dialogs/ResizeCanvas.gd b/src/UI/Dialogs/ResizeCanvas.gd index 49c3737..aec9c8d 100644 --- a/src/UI/Dialogs/ResizeCanvas.gd +++ b/src/UI/Dialogs/ResizeCanvas.gd @@ -6,13 +6,20 @@ var height := 64 var offset_x := 0 var offset_y := 0 var image : Image +var first_time := true +onready var width_spinbox : SpinBox = $VBoxContainer/OptionsContainer/WidthValue +onready var height_spinbox : SpinBox = $VBoxContainer/OptionsContainer/HeightValue onready var x_spinbox : SpinBox = $VBoxContainer/OptionsContainer/XSpinBox onready var y_spinbox : SpinBox = $VBoxContainer/OptionsContainer/YSpinBox onready var preview_rect : TextureRect = $VBoxContainer/Preview func _on_ResizeCanvas_about_to_show() -> void: + if first_time: + width_spinbox.value = Global.current_project.size.x + height_spinbox.value = Global.current_project.size.y + image = Image.new() image.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8) image.lock() @@ -38,6 +45,7 @@ func _on_ResizeCanvas_about_to_show() -> void: func _on_ResizeCanvas_confirmed() -> void: DrawingAlgos.resize_canvas(width, height, offset_x, offset_y) + first_time = false func _on_WidthValue_value_changed(value : int) -> void: