1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Fix issue where Pixelorama was quitting on save, if the user attempted to save on exit before and cancelled the save file dialog

And replace instances of `Global.save_sprites_dialog` with a local `save_sprite_dialog` variable
This commit is contained in:
Emmanouil Papadeas 2024-06-01 17:56:50 +03:00
parent b7a77a2ceb
commit 770e04c550
2 changed files with 13 additions and 9 deletions

View file

@ -18,6 +18,7 @@ var splash_dialog: AcceptDialog:
@onready var main_ui := $MenuAndUI/UI/DockableContainer as DockableContainer @onready var main_ui := $MenuAndUI/UI/DockableContainer as DockableContainer
@onready var backup_confirmation: ConfirmationDialog = $Dialogs/BackupConfirmation @onready var backup_confirmation: ConfirmationDialog = $Dialogs/BackupConfirmation
@onready var save_sprite_dialog := $Dialogs/SaveSprite as FileDialog
@onready var save_sprite_html5: ConfirmationDialog = $Dialogs/SaveSpriteHTML5 @onready var save_sprite_html5: ConfirmationDialog = $Dialogs/SaveSpriteHTML5
@onready var quit_dialog: ConfirmationDialog = $Dialogs/QuitDialog @onready var quit_dialog: ConfirmationDialog = $Dialogs/QuitDialog
@onready var quit_and_save_dialog: ConfirmationDialog = $Dialogs/QuitAndSaveDialog @onready var quit_and_save_dialog: ConfirmationDialog = $Dialogs/QuitAndSaveDialog
@ -178,7 +179,7 @@ func _ready() -> void:
Global.open_sprites_dialog.current_dir = Global.config_cache.get_value( Global.open_sprites_dialog.current_dir = Global.config_cache.get_value(
"data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP) "data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
) )
Global.save_sprites_dialog.current_dir = Global.config_cache.get_value( save_sprite_dialog.current_dir = Global.config_cache.get_value(
"data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP) "data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP)
) )
var include_blended := CheckBox.new() var include_blended := CheckBox.new()
@ -190,7 +191,7 @@ This makes the pxo file larger and is useful for importing by third-party softwa
or CLI exporting. Loading pxo files in Pixelorama does not need this option to be enabled. or CLI exporting. Loading pxo files in Pixelorama does not need this option to be enabled.
""" """
include_blended.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND include_blended.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
Global.save_sprites_dialog.get_vbox().add_child(include_blended) save_sprite_dialog.get_vbox().add_child(include_blended)
_handle_cmdline_arguments() _handle_cmdline_arguments()
get_tree().root.files_dropped.connect(_on_files_dropped) get_tree().root.files_dropped.connect(_on_files_dropped)
if OS.get_name() == "Android": if OS.get_name() == "Android":
@ -426,7 +427,7 @@ func load_recent_project_file(path: String) -> void:
func _on_OpenSprite_files_selected(paths: PackedStringArray) -> void: func _on_OpenSprite_files_selected(paths: PackedStringArray) -> void:
for path in paths: for path in paths:
OpenSave.handle_loading_file(path) OpenSave.handle_loading_file(path)
Global.save_sprites_dialog.current_dir = paths[0].get_base_dir() save_sprite_dialog.current_dir = paths[0].get_base_dir()
func show_save_dialog(project := Global.current_project) -> void: func show_save_dialog(project := Global.current_project) -> void:
@ -436,14 +437,19 @@ func show_save_dialog(project := Global.current_project) -> void:
save_sprite_html5.popup_centered() save_sprite_html5.popup_centered()
save_filename.text = project.name save_filename.text = project.name
else: else:
Global.save_sprites_dialog.popup_centered() save_sprite_dialog.popup_centered()
Global.save_sprites_dialog.get_line_edit().text = project.name save_sprite_dialog.get_line_edit().text = project.name
func _on_SaveSprite_file_selected(path: String) -> void: func _on_SaveSprite_file_selected(path: String) -> void:
save_project(path) save_project(path)
func _on_save_sprite_visibility_changed() -> void:
if not save_sprite_dialog.visible:
is_quitting_on_save = false
func save_project(path: String) -> void: func save_project(path: String) -> void:
var project_to_save := Global.current_project var project_to_save := Global.current_project
if is_quitting_on_save: if is_quitting_on_save:
@ -455,16 +461,13 @@ func save_project(path: String) -> void:
path = "user://".path_join(file_name) path = "user://".path_join(file_name)
include_blended = save_sprite_html5.get_node("%IncludeBlended").button_pressed include_blended = save_sprite_html5.get_node("%IncludeBlended").button_pressed
else: else:
include_blended = ( include_blended = save_sprite_dialog.get_vbox().get_node("IncludeBlended").button_pressed
Global.save_sprites_dialog.get_vbox().get_node("IncludeBlended").button_pressed
)
var success := OpenSave.save_pxo_file(path, false, include_blended, project_to_save) var success := OpenSave.save_pxo_file(path, false, include_blended, project_to_save)
if success: if success:
Global.open_sprites_dialog.current_dir = path.get_base_dir() Global.open_sprites_dialog.current_dir = path.get_base_dir()
if is_quitting_on_save: if is_quitting_on_save:
changed_projects_on_quit.pop_front() changed_projects_on_quit.pop_front()
_save_on_quit_confirmation() _save_on_quit_confirmation()
is_quitting_on_save = false
func _on_open_sprite_visibility_changed() -> void: func _on_open_sprite_visibility_changed() -> void:

View file

@ -113,6 +113,7 @@ visible = false
[connection signal="visibility_changed" from="Dialogs/OpenSprite" to="." method="_on_open_sprite_visibility_changed"] [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="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="visibility_changed" from="Dialogs/SaveSprite" to="." method="_can_draw_true"]
[connection signal="visibility_changed" from="Dialogs/SaveSprite" to="." method="_on_save_sprite_visibility_changed"]
[connection signal="confirmed" from="Dialogs/SaveSpriteHTML5" to="." method="save_project" binds= [""]] [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/SaveSpriteHTML5" to="." method="_can_draw_true"]
[connection signal="visibility_changed" from="Dialogs/ExportDialog" to="." method="_can_draw_true"] [connection signal="visibility_changed" from="Dialogs/ExportDialog" to="." method="_can_draw_true"]