From 2f072593896b3ca39391a413d033061a6fbd10c4 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 6 Mar 2020 23:11:21 +0200 Subject: [PATCH] Importing PNGs should now work --- Scripts/Dialogs/ImportSprites.gd | 14 ++++++++++++++ Scripts/Main.gd | 5 ----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Scripts/Dialogs/ImportSprites.gd b/Scripts/Dialogs/ImportSprites.gd index c0f2e4822..99802090a 100644 --- a/Scripts/Dialogs/ImportSprites.gd +++ b/Scripts/Dialogs/ImportSprites.gd @@ -57,6 +57,19 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void: tex.create_from_image(image, 0) # Store [Image, ImageTexture, Opacity] canvas.layers.append([image, tex, 1]) + + for _i in range(1, Global.layers.size()): + var empty_sprite := Image.new() + empty_sprite.create(canvas.size.x, canvas.size.y, false, Image.FORMAT_RGBA8) + empty_sprite.fill(Color(0, 0, 0, 0)) + empty_sprite.lock() + + var empty_tex := ImageTexture.new() + empty_tex.create_from_image(empty_sprite, 0) + + # Store [Image, ImageTexture, Opacity] + canvas.layers.append([empty_sprite, empty_tex, 1]) + canvas.frame = i Global.canvases.append(canvas) Global.canvas_parent.add_child(canvas) @@ -107,6 +120,7 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void: Global.canvases[Global.canvases.size() - 1].camera_zoom() + Global.canvases = Global.canvases # Just to call Global.canvases_changed Global.current_frame = i - 1 Global.canvas = Global.canvases[Global.canvases.size() - 1] Global.canvas.visible = true diff --git a/Scripts/Main.gd b/Scripts/Main.gd index 2e860bd7a..f65a292a8 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -553,11 +553,6 @@ func _on_SaveSprite_file_selected(path : String) -> void: _on_QuitDialog_confirmed() func clear_canvases() -> void: - for child in Global.vbox_layer_container.get_children(): - if child is PanelContainer: - child.queue_free() - for child in Global.frame_containers.get_children(): - child.queue_free() for child in Global.canvas_parent.get_children(): if child is Canvas: child.queue_free()