mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Ask for Confirmation when Pixelorama is about to quit and the Sprite is unsaved (#165)
This commit is contained in:
parent
48981e16b2
commit
3ea3bd7b40
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ export_presets.cfg
|
||||||
|
|
||||||
Translations/Update Translations.bat
|
Translations/Update Translations.bat
|
||||||
Scripts/Old/
|
Scripts/Old/
|
||||||
|
|
||||||
|
|
|
@ -1546,7 +1546,9 @@ visible = false
|
||||||
[connection signal="popup_hide" from="OutlineDialog" to="." method="_can_draw_true"]
|
[connection signal="popup_hide" from="OutlineDialog" to="." method="_can_draw_true"]
|
||||||
[connection signal="popup_hide" from="AboutDialog" to="." method="_can_draw_true"]
|
[connection signal="popup_hide" from="AboutDialog" to="." method="_can_draw_true"]
|
||||||
[connection signal="confirmed" from="QuitDialog" to="." method="_on_QuitDialog_confirmed"]
|
[connection signal="confirmed" from="QuitDialog" to="." method="_on_QuitDialog_confirmed"]
|
||||||
|
[connection signal="custom_action" from="QuitDialog" to="." method="_on_QuitDialog_custom_action"]
|
||||||
[connection signal="popup_hide" from="QuitDialog" to="." method="_can_draw_true"]
|
[connection signal="popup_hide" from="QuitDialog" to="." method="_can_draw_true"]
|
||||||
|
[connection signal="popup_hide" from="QuitDialog" to="." method="_on_QuitDialog_popup_hide"]
|
||||||
[connection signal="confirmed" from="NewPaletteDialog" to="MenuAndUI/UI/LayerPanel/LayersAndMisc/VSplitContainer/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="on_new_palette_confirmed"]
|
[connection signal="confirmed" from="NewPaletteDialog" to="MenuAndUI/UI/LayerPanel/LayersAndMisc/VSplitContainer/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="on_new_palette_confirmed"]
|
||||||
[connection signal="file_selected" from="PaletteImportFileDialog" to="MenuAndUI/UI/LayerPanel/LayersAndMisc/VSplitContainer/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="on_palette_import_file_selected"]
|
[connection signal="file_selected" from="PaletteImportFileDialog" to="MenuAndUI/UI/LayerPanel/LayersAndMisc/VSplitContainer/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="on_palette_import_file_selected"]
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ var config_cache := ConfigFile.new()
|
||||||
var loaded_locales : Array
|
var loaded_locales : Array
|
||||||
var undo_redo : UndoRedo
|
var undo_redo : UndoRedo
|
||||||
var undos := 0 #The number of times we added undo properties
|
var undos := 0 #The number of times we added undo properties
|
||||||
|
var saved := false #Checks if the user has saved
|
||||||
|
|
||||||
# Canvas related stuff
|
# Canvas related stuff
|
||||||
var current_frame := 0 setget frame_changed
|
var current_frame := 0 setget frame_changed
|
||||||
|
|
|
@ -8,6 +8,7 @@ var tools := []
|
||||||
var redone := false
|
var redone := false
|
||||||
var previous_left_color := Color.black
|
var previous_left_color := Color.black
|
||||||
var previous_right_color := Color.white
|
var previous_right_color := Color.white
|
||||||
|
var SaveButton : Button
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -201,6 +202,8 @@ func _input(event : InputEvent) -> void:
|
||||||
|
|
||||||
func _notification(what : int) -> void:
|
func _notification(what : int) -> void:
|
||||||
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit
|
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit
|
||||||
|
if !Global.saved && !$QuitDialog.visible:
|
||||||
|
SaveButton = $QuitDialog.add_button("Save", false, "Save")
|
||||||
$QuitDialog.call_deferred("popup_centered")
|
$QuitDialog.call_deferred("popup_centered")
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
|
|
||||||
|
@ -236,6 +239,8 @@ func file_menu_id_pressed(id : int) -> void:
|
||||||
$ExportSprites.popup_centered()
|
$ExportSprites.popup_centered()
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
7: # Quit
|
7: # Quit
|
||||||
|
if !Global.saved && !$QuitDialog.visible:
|
||||||
|
SaveButton = $QuitDialog.add_button("Save", false, "Save")
|
||||||
$QuitDialog.popup_centered()
|
$QuitDialog.popup_centered()
|
||||||
Global.can_draw = false
|
Global.can_draw = false
|
||||||
|
|
||||||
|
@ -538,6 +543,7 @@ func _on_SaveSprite_file_selected(path : String) -> void:
|
||||||
file.store_buffer(brush.get_data())
|
file.store_buffer(brush.get_data())
|
||||||
file.store_line("END_BRUSHES")
|
file.store_line("END_BRUSHES")
|
||||||
file.close()
|
file.close()
|
||||||
|
Global.saved = true
|
||||||
Global.notification_label("File saved")
|
Global.notification_label("File saved")
|
||||||
|
|
||||||
func clear_canvases() -> void:
|
func clear_canvases() -> void:
|
||||||
|
@ -855,3 +861,11 @@ func _on_QuitDialog_confirmed() -> void:
|
||||||
|
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
func _on_QuitDialog_custom_action(action):
|
||||||
|
if action == "Save":
|
||||||
|
$SaveSprite.popup_centered()
|
||||||
|
Global.can_draw = false
|
||||||
|
|
||||||
|
func _on_QuitDialog_popup_hide():
|
||||||
|
if !Global.saved:
|
||||||
|
SaveButton.queue_free()
|
||||||
|
|
Loading…
Reference in a new issue