mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +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:
|
||||||
|
@ -166,10 +167,10 @@ func _ready() -> void:
|
||||||
Global.canvas.generate_layer_panels()
|
Global.canvas.generate_layer_panels()
|
||||||
|
|
||||||
Import.import_brushes("Brushes")
|
Import.import_brushes("Brushes")
|
||||||
|
|
||||||
$MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton.get_picker().presets_visible = false
|
$MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/LeftColorPickerButton.get_picker().presets_visible = false
|
||||||
$MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/RightColorPickerButton.get_picker().presets_visible = false
|
$MenuAndUI/UI/ToolPanel/Tools/ColorAndToolOptions/ColorButtonsVertical/ColorPickersCenter/ColorPickersHorizontal/RightColorPickerButton.get_picker().presets_visible = false
|
||||||
|
|
||||||
if not Global.config_cache.has_section_key("preferences", "startup"):
|
if not Global.config_cache.has_section_key("preferences", "startup"):
|
||||||
Global.config_cache.set_value("preferences", "startup", true)
|
Global.config_cache.set_value("preferences", "startup", true)
|
||||||
if Global.config_cache.get_value("preferences", "startup"):
|
if Global.config_cache.get_value("preferences", "startup"):
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -471,14 +476,14 @@ func _on_OpenSprite_file_selected(path : String) -> void:
|
||||||
brush_line = file.get_line()
|
brush_line = file.get_line()
|
||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
current_save_path = path
|
current_save_path = path
|
||||||
$SaveSprite.current_path = path
|
$SaveSprite.current_path = path
|
||||||
$ExportSprites.current_export_path = path.trim_suffix(".pxo") + ".png"
|
$ExportSprites.current_export_path = path.trim_suffix(".pxo") + ".png"
|
||||||
$ExportSprites.current_path = $ExportSprites.current_export_path
|
$ExportSprites.current_path = $ExportSprites.current_export_path
|
||||||
file_menu.set_item_text(2, tr("Save") + " %s" % path.get_file())
|
file_menu.set_item_text(2, tr("Save") + " %s" % path.get_file())
|
||||||
file_menu.set_item_text(5, tr("Export") + " %s" % $ExportSprites.current_path.get_file())
|
file_menu.set_item_text(5, tr("Export") + " %s" % $ExportSprites.current_path.get_file())
|
||||||
|
|
||||||
OS.set_window_title(path.get_file() + " - Pixelorama")
|
OS.set_window_title(path.get_file() + " - Pixelorama")
|
||||||
|
|
||||||
|
|
||||||
|
@ -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