diff --git a/.gitignore b/.gitignore index 04a6a11c2..96b12e1ae 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ export_presets.cfg Translations/Update Translations.bat Scripts/Old/ + diff --git a/Main.tscn b/Main.tscn index 469661bb0..a4cf9fd57 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1546,7 +1546,9 @@ visible = false [connection signal="popup_hide" from="OutlineDialog" 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="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="_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="file_selected" from="PaletteImportFileDialog" to="MenuAndUI/UI/LayerPanel/LayersAndMisc/VSplitContainer/PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer" method="on_palette_import_file_selected"] diff --git a/Scripts/Global.gd b/Scripts/Global.gd index 1b871f129..3c1ab70e5 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -9,6 +9,7 @@ var config_cache := ConfigFile.new() var loaded_locales : Array var undo_redo : UndoRedo var undos := 0 #The number of times we added undo properties +var saved := false #Checks if the user has saved # Canvas related stuff var current_frame := 0 setget frame_changed diff --git a/Scripts/Main.gd b/Scripts/Main.gd index 9d7b2d0ec..a6cb289f8 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -8,6 +8,7 @@ var tools := [] var redone := false var previous_left_color := Color.black var previous_right_color := Color.white +var SaveButton : Button # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -166,10 +167,10 @@ func _ready() -> void: Global.canvas.generate_layer_panels() 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/RightColorPickerButton.get_picker().presets_visible = false - + if not Global.config_cache.has_section_key("preferences", "startup"): Global.config_cache.set_value("preferences", "startup", true) if Global.config_cache.get_value("preferences", "startup"): @@ -201,6 +202,8 @@ func _input(event : InputEvent) -> void: func _notification(what : int) -> void: 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") Global.can_draw = false @@ -236,6 +239,8 @@ func file_menu_id_pressed(id : int) -> void: $ExportSprites.popup_centered() Global.can_draw = false 7: # Quit + if !Global.saved && !$QuitDialog.visible: + SaveButton = $QuitDialog.add_button("Save", false, "Save") $QuitDialog.popup_centered() Global.can_draw = false @@ -471,14 +476,14 @@ func _on_OpenSprite_file_selected(path : String) -> void: brush_line = file.get_line() file.close() - + current_save_path = path $SaveSprite.current_path = path $ExportSprites.current_export_path = path.trim_suffix(".pxo") + ".png" $ExportSprites.current_path = $ExportSprites.current_export_path 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()) - + 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_line("END_BRUSHES") file.close() + Global.saved = true Global.notification_label("File saved") func clear_canvases() -> void: @@ -855,3 +861,11 @@ func _on_QuitDialog_confirmed() -> void: 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()