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

Confirmation dialog for "open last project" menu option when there are unsaved changes

Changed text in UnsavedCanvasDialog and renamed Global.saved to Global.project_has_changed (the boolean values are now opposite)
This commit is contained in:
OverloadedOrama 2020-05-01 19:40:36 +03:00
parent df2bf59871
commit 62bbad7374
6 changed files with 25 additions and 15 deletions

View file

@ -1624,7 +1624,7 @@ visible = false
margin_right = 200.0
margin_bottom = 70.0
window_title = "Unsaved Image"
dialog_text = "Changes has not been saved. Are you sure you want to create a new image?"
dialog_text = "You have unsaved changes. If you proceed, the progress you have made will be lost."
[node name="QuitDialog" type="ConfirmationDialog" parent="."]
margin_right = 200.0

View file

@ -83,7 +83,7 @@ func _on_CreateNewImage_confirmed() -> void:
Global.canvases = Global.canvases # To trigger Global.canvases_changed()
Global.current_frame = 0
Global.layers = Global.layers # To trigger Global.layers_changed()
Global.saved = true
Global.project_has_changed = false
if fill_color.a > 0:
Global.canvas.layers[0][0].fill(fill_color)
Global.canvas.layers[0][0].lock()

View file

@ -30,7 +30,7 @@ var key_move_press_time := [0.0, 0.0, 0.0, 0.0]
var loaded_locales : Array
var undo_redo : UndoRedo
var undos := 0 # The number of times we added undo properties
var saved := true # Checks if the user has saved
var project_has_changed := false # Checks if the user has made changes to the project
# Canvas related stuff
var canvases := [] setget canvases_changed
@ -462,8 +462,8 @@ func undo(_canvases : Array, layer_index : int = -1) -> void:
canvas_parent.move_child(_canvases[0], _canvases[0].frame)
canvas.update()
if saved:
saved = false
if !project_has_changed:
project_has_changed = true
self.window_title = window_title + "(*)"
@ -493,8 +493,8 @@ func redo(_canvases : Array, layer_index : int = -1) -> void:
canvas_parent.move_child(_canvases[0], _canvases[0].frame)
canvas.update()
if saved:
saved = false
if !project_has_changed:
project_has_changed = true
self.window_title = window_title + "(*)"

View file

@ -5,6 +5,7 @@ var file_menu : PopupMenu
var view_menu : PopupMenu
var tools := []
var redone := false
var unsaved_canvas_state := 0
var is_quitting_on_save := false
var previous_left_color := Color.black
var previous_right_color := Color.white
@ -251,7 +252,8 @@ func _notification(what : int) -> void:
func file_menu_id_pressed(id : int) -> void:
match id:
0: # New
if(!Global.saved):
if Global.project_has_changed:
unsaved_canvas_state = id
$UnsavedCanvasDialog.popup_centered()
else:
$CreateNewImage.popup_centered()
@ -263,6 +265,10 @@ func file_menu_id_pressed(id : int) -> void:
2: # Open last project
# Check if last project path is set and if yes then open
if Global.config_cache.has_section_key("preferences", "last_project_path"):
if Global.project_has_changed:
unsaved_canvas_state = id
$UnsavedCanvasDialog.popup_centered()
else:
load_last_project()
else: # if not then warn user that he didn't edit any project yet
$NoProjectEditedOrCreatedAlertDialog.popup_centered()
@ -455,7 +461,10 @@ func load_last_project() -> void:
func _on_UnsavedCanvasDialog_confirmed() -> void:
if unsaved_canvas_state == 0: # New image
$CreateNewImage.popup_centered()
elif unsaved_canvas_state == 2: # Open last project
load_last_project()
func _on_OpenSprite_file_selected(path : String) -> void:
@ -790,7 +799,7 @@ func _on_RightVerticalMirroring_toggled(button_pressed) -> void:
func show_quit_dialog() -> void:
if !$QuitDialog.visible:
if Global.saved:
if !Global.project_has_changed:
$QuitDialog.call_deferred("popup_centered")
else:
$QuitAndSaveDialog.call_deferred("popup_centered")

View file

@ -152,6 +152,7 @@ func open_pxo_file(path : String, untitled_backup : bool = false) -> void:
# Untitled backup should not change window title and save path
current_save_path = path
Global.window_title = path.get_file() + " - Pixelorama"
Global.project_has_changed = false
func save_pxo_file(path : String, autosave : bool) -> void:
@ -226,8 +227,8 @@ func save_pxo_file(path : String, autosave : bool) -> void:
file.close()
if !Global.saved and not autosave:
Global.saved = true
if Global.project_has_changed and not autosave:
Global.project_has_changed = false
if autosave:
Global.notification_label("File autosaved")
@ -306,7 +307,7 @@ func reload_backup_file(project_path : String, backup_path : String) -> void:
if project_path != backup_path:
current_save_path = project_path
Global.window_title = project_path.get_file() + " - Pixelorama(*)"
Global.saved = false
Global.project_has_changed = true
Global.notification_label("Backup reloaded")

View file

@ -428,7 +428,7 @@ msgstr ""
msgid "Unsaved Image"
msgstr ""
msgid "Changes has not been saved. Are you sure you want to create a new image?"
msgid "You have unsaved changes. If you proceed, the progress you have made will be lost."
msgstr ""
msgid "Save before exiting?"