From 10ca31b9161b8e48e3a3b0b05b2f672ff0b114c1 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Mon, 18 Dec 2023 20:55:40 +0200 Subject: [PATCH] Add "include blended images" in SaveSpriteHTML5.tscn, and use `save_project()` for both desktop and web platforms --- src/Main.gd | 28 +++++++++++----------------- src/Main.tscn | 2 +- src/UI/Dialogs/SaveSpriteHTML5.tscn | 26 +++++++++++++++++++------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/Main.gd b/src/Main.gd index 59f6b13a3..befc69ddf 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -281,7 +281,7 @@ func _on_OpenSprite_files_selected(paths: PackedStringArray) -> void: func show_save_dialog(project := Global.current_project) -> void: Global.dialog_open(true) if OS.get_name() == "Web": - var save_filename := save_sprite_html5.get_node("FileNameContainer/FileNameLineEdit") + var save_filename := save_sprite_html5.get_node("%FileNameLineEdit") save_sprite_html5.popup_centered() save_filename.text = project.name else: @@ -294,12 +294,19 @@ func _on_SaveSprite_file_selected(path: String) -> void: func save_project(path: String) -> void: - var include_blended: bool = ( - Global.save_sprites_dialog.get_vbox().get_node("IncludeBlended").button_pressed - ) var project_to_save := Global.current_project if is_quitting_on_save: project_to_save = changed_projects_on_quit[0] + var include_blended := false + if OS.get_name() == "Web": + var file_name: String = save_sprite_html5.get_node("%FileNameLineEdit").text + file_name += ".pxo" + path = "user://".path_join(file_name) + include_blended = save_sprite_html5.get_node("%IncludeBlended").button_pressed + else: + include_blended = ( + Global.save_sprites_dialog.get_vbox().get_node("IncludeBlended").button_pressed + ) var success := OpenSave.save_pxo_file(path, false, include_blended, project_to_save) if success: Global.open_sprites_dialog.current_dir = path.get_base_dir() @@ -309,19 +316,6 @@ func save_project(path: String) -> void: _save_on_quit_confirmation() -func _on_SaveSpriteHTML5_confirmed() -> void: - var file_name: String = save_sprite_html5.get_node("FileNameContainer/FileNameLineEdit").text - file_name += ".pxo" - var path := "user://".path_join(file_name) - var project_to_save := Global.current_project - if is_quitting_on_save: - project_to_save = changed_projects_on_quit[0] - OpenSave.save_pxo_file(path, false, false, project_to_save) - if is_quitting_on_save: - changed_projects_on_quit.pop_front() - _save_on_quit_confirmation() - - func _on_open_sprite_visibility_changed() -> void: if !opensprite_file_selected: _can_draw_true() diff --git a/src/Main.tscn b/src/Main.tscn index 791ed8a88..848836790 100644 --- a/src/Main.tscn +++ b/src/Main.tscn @@ -120,7 +120,7 @@ visible = false [connection signal="visibility_changed" from="Dialogs/OpenSprite" to="." method="_on_open_sprite_visibility_changed"] [connection signal="file_selected" from="Dialogs/SaveSprite" to="." method="_on_SaveSprite_file_selected"] [connection signal="visibility_changed" from="Dialogs/SaveSprite" to="." method="_can_draw_true"] -[connection signal="confirmed" from="Dialogs/SaveSpriteHTML5" to="." method="_on_SaveSpriteHTML5_confirmed"] +[connection signal="confirmed" from="Dialogs/SaveSpriteHTML5" to="." method="save_project" binds= [""]] [connection signal="visibility_changed" from="Dialogs/SaveSpriteHTML5" to="." method="_can_draw_true"] [connection signal="visibility_changed" from="Dialogs/ExportDialog" to="." method="_can_draw_true"] [connection signal="visibility_changed" from="Dialogs/UnsavedCanvasDialog" to="." method="_can_draw_true"] diff --git a/src/UI/Dialogs/SaveSpriteHTML5.tscn b/src/UI/Dialogs/SaveSpriteHTML5.tscn index 1757158a4..8697e4fa2 100644 --- a/src/UI/Dialogs/SaveSpriteHTML5.tscn +++ b/src/UI/Dialogs/SaveSpriteHTML5.tscn @@ -1,22 +1,34 @@ [gd_scene format=3 uid="uid://cltlo2whtiejd"] [node name="SaveSpriteHTML5" type="ConfirmationDialog"] +size = Vector2i(205, 111) ok_button_text = "Save" -[node name="FileNameContainer" type="HBoxContainer" parent="."] -anchors_preset = 10 -anchor_right = 1.0 +[node name="VBoxContainer" type="VBoxContainer" parent="."] offset_left = 8.0 offset_top = 8.0 -offset_right = -8.0 -offset_bottom = 34.0 +offset_right = 197.0 +offset_bottom = 66.0 -[node name="FileNameLabel" type="Label" parent="FileNameContainer"] +[node name="FileNameContainer" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="FileNameLabel" type="Label" parent="VBoxContainer/FileNameContainer"] layout_mode = 2 text = "File Name:" -[node name="FileNameLineEdit" type="LineEdit" parent="FileNameContainer"] +[node name="FileNameLineEdit" type="LineEdit" parent="VBoxContainer/FileNameContainer"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 4 text = "untitled" + +[node name="IncludeBlended" type="CheckBox" parent="VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "If enabled, the final blended images are also being stored in the pxo, for each frame. +This makes the pxo file larger and is useful for importing by third-party software +or CLI exporting. Loading pxo files in Pixelorama does not need this option to be enabled." +mouse_default_cursor_shape = 2 +text = "Include blended images"