From 324e21776de853e6ea24703d5724a491547371ab Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Thu, 7 Mar 2024 16:38:19 +0200 Subject: [PATCH] Fix exporting selected layers not including the non-selected frames Backport from 55df23e40076ab2bafb80f115a4ece5d701d6185. --- CHANGELOG.md | 1 + project.godot | 2 +- src/Autoload/Export.gd | 23 ++++++++++++++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4f47e054..0925fa96d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Built using Godot 3.5.2 - Optimize canvas drawing by only updating it when the image(s) have changed. [ac6a4db43d9296ebc03e639d8199dd3878a25d86](https://github.com/Orama-Interactive/Pixelorama/commit/ac6a4db43d9296ebc03e639d8199dd3878a25d86) - Fix bug where using shortcuts to switch between frames also moved the selection, causing deletions. - Pxo files can now be loaded from the Open menu option in the Web version. [3dcc51705a999145e53a8e6d4de217dc03b0f147](https://github.com/Orama-Interactive/Pixelorama/commit/3dcc51705a999145e53a8e6d4de217dc03b0f147) +- Fixed exporting selected layers not including the non-selected frames. - The ellipse tool no longer produces gaps with large sizes. [4f3a7a305a264e0d2fe86c201af76eca4b2fea0a](https://github.com/Orama-Interactive/Pixelorama/commit/4f3a7a305a264e0d2fe86c201af76eca4b2fea0a) - Fix "visible layers" option on the export dialog producing wrong results. [346d1f071a8c6b1defb1072d39aea9c642f1ef59](https://github.com/Orama-Interactive/Pixelorama/commit/346d1f071a8c6b1defb1072d39aea9c642f1ef59) - Random brushes now work again. [1317e40ffa5e9f01a9d214221bb5133db20a1de9](https://github.com/Orama-Interactive/Pixelorama/commit/1317e40ffa5e9f01a9d214221bb5133db20a1de9) diff --git a/project.godot b/project.godot index 38b74c312..d0172fb7b 100644 --- a/project.godot +++ b/project.godot @@ -343,7 +343,7 @@ config/icon="res://assets/graphics/icons/icon.png" config/macos_native_icon="res://assets/graphics/icons/icon.icns" config/windows_native_icon="res://assets/graphics/icons/icon.ico" config/custom_user_dir_name.X11="pixelorama" -config/Version="v0.11.4-rc2" +config/Version="v0.11.4-rc3" config/ExtensionsAPI_Version=3 config/Pxo_Version=2 diff --git a/src/Autoload/Export.gd b/src/Autoload/Export.gd index 645989757..2e88c2c2c 100644 --- a/src/Autoload/Export.gd +++ b/src/Autoload/Export.gd @@ -441,7 +441,7 @@ func blend_layers( if export_layers == 0: blend_all_layers(image, frame, origin, project) elif export_layers == 1: - blend_selected_cels(image, frame, origin, project) + blend_selected_cels(image, frame, origin, project, true) else: var layer: BaseLayer = project.layers[export_layers - 2] var layer_image := Image.new() @@ -482,12 +482,25 @@ func blend_all_layers( # Blends selected cels of the given frame into passed image starting from the origin position func blend_selected_cels( - image: Image, frame: Frame, origin := Vector2(0, 0), project := Global.current_project + image: Image, + frame: Frame, + origin := Vector2.ZERO, + project := Global.current_project, + include_layers := false ) -> void: for cel_ind in frame.cels.size(): - var test_array := [project.frames.find(frame), cel_ind] - if not test_array in project.selected_cels: - continue + if include_layers: + var layer_is_selected := false + for selected_cel in project.selected_cels: + if cel_ind == selected_cel[1]: + layer_is_selected = true + break + if not layer_is_selected: + continue + else: + var test_array := [project.frames.find(frame), cel_ind] + if not test_array in project.selected_cels: + continue if frame.cels[cel_ind] is GroupCel: continue if not project.layers[cel_ind].is_visible_in_hierarchy():