Skip to content

Commit

Permalink
Merge pull request #90660 from adamscott/rename-file-updated-dialog
Browse files Browse the repository at this point in the history
Improve UX when saving newer files on disk
  • Loading branch information
akien-mga committed May 29, 2024
2 parents bda8e30 + 38d8abe commit 4d906f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 4 additions & 2 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7228,6 +7228,8 @@ EditorNode::EditorNode() {

disk_changed = memnew(ConfirmationDialog);
{
disk_changed->set_title(TTR("Files have been modified on disk"));

VBoxContainer *vbc = memnew(VBoxContainer);
disk_changed->add_child(vbc);

Expand All @@ -7241,9 +7243,9 @@ EditorNode::EditorNode() {

disk_changed->connect("confirmed", callable_mp(this, &EditorNode::_reload_modified_scenes));
disk_changed->connect("confirmed", callable_mp(this, &EditorNode::_reload_project_settings));
disk_changed->set_ok_button_text(TTR("Reload"));
disk_changed->set_ok_button_text(TTR("Discard local changes and reload"));

disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave");
disk_changed->add_button(TTR("Keep local changes and overwrite"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave");
disk_changed->connect("custom_action", callable_mp(this, &EditorNode::_resave_scenes));
}

Expand Down
16 changes: 11 additions & 5 deletions editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4249,22 +4249,28 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {

disk_changed = memnew(ConfirmationDialog);
{
disk_changed->set_title(TTR("Files have been modified on disk"));

VBoxContainer *vbc = memnew(VBoxContainer);
disk_changed->add_child(vbc);

Label *dl = memnew(Label);
dl->set_text(TTR("The following files are newer on disk.\nWhat action should be taken?:"));
vbc->add_child(dl);
Label *files_are_newer_label = memnew(Label);
files_are_newer_label->set_text(TTR("The following files are newer on disk."));
vbc->add_child(files_are_newer_label);

Label *what_action_label = memnew(Label);
what_action_label->set_text(TTR("What action should be taken?:"));
vbc->add_child(what_action_label);

disk_changed_list = memnew(Tree);
vbc->add_child(disk_changed_list);
disk_changed_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL);

disk_changed->connect("confirmed", callable_mp(this, &ScriptEditor::reload_scripts).bind(false));
disk_changed->set_ok_button_text(TTR("Reload"));
disk_changed->set_ok_button_text(TTR("Discard local changes and reload"));

disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave");
disk_changed->add_button(TTR("Keep local changes and overwrite"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave");
disk_changed->connect("custom_action", callable_mp(this, &ScriptEditor::_resave_scripts));
}

Expand Down

0 comments on commit 4d906f4

Please sign in to comment.