Corrected Save Scene and Save All Scenes not working when the scene's dir no longer exists
(cherry picked from commit ed2280528f
)
This commit is contained in:
parent
a4fecbb0da
commit
8f66e6148d
2 changed files with 29 additions and 12 deletions
|
@ -1613,13 +1613,15 @@ void EditorNode::restart_editor() {
|
|||
void EditorNode::_save_all_scenes() {
|
||||
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
|
||||
Node *scene = editor_data.get_edited_scene_root(i);
|
||||
if (scene && scene->get_filename() != "") {
|
||||
if (scene && scene->get_filename() != "" && DirAccess::exists(scene->get_filename().get_base_dir())) {
|
||||
if (i != editor_data.get_edited_scene()) {
|
||||
_save_scene(scene->get_filename(), i);
|
||||
} else {
|
||||
_save_scene_with_preview(scene->get_filename());
|
||||
}
|
||||
} // else: ignore new scenes
|
||||
} else {
|
||||
show_warning(TTR("Could not save one or more scenes!"), TTR("Save All Scenes"));
|
||||
}
|
||||
}
|
||||
|
||||
_save_default_environment();
|
||||
|
@ -2345,20 +2347,22 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||
case SCENE_TAB_CLOSE:
|
||||
case FILE_SAVE_SCENE: {
|
||||
int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing;
|
||||
|
||||
Node *scene = editor_data.get_edited_scene_root(scene_idx);
|
||||
if (scene && scene->get_filename() != "") {
|
||||
if (scene_idx != editor_data.get_edited_scene()) {
|
||||
_save_scene_with_preview(scene->get_filename(), scene_idx);
|
||||
if (DirAccess::exists(scene->get_filename().get_base_dir())) {
|
||||
if (scene_idx != editor_data.get_edited_scene()) {
|
||||
_save_scene_with_preview(scene->get_filename(), scene_idx);
|
||||
} else {
|
||||
_save_scene_with_preview(scene->get_filename());
|
||||
}
|
||||
|
||||
if (scene_idx != -1) {
|
||||
_discard_changes();
|
||||
}
|
||||
save_layout();
|
||||
} else {
|
||||
_save_scene_with_preview(scene->get_filename());
|
||||
show_save_accept(vformat(TTR("%s no longer exists! Please specify a new save location."), scene->get_filename().get_base_dir()), TTR("OK"));
|
||||
}
|
||||
|
||||
if (scene_idx != -1) {
|
||||
_discard_changes();
|
||||
}
|
||||
save_layout();
|
||||
|
||||
break;
|
||||
}
|
||||
FALLTHROUGH;
|
||||
|
@ -4131,6 +4135,13 @@ void EditorNode::show_accept(const String &p_text, const String &p_title) {
|
|||
accept->popup_centered_minsize();
|
||||
}
|
||||
|
||||
void EditorNode::show_save_accept(const String &p_text, const String &p_title) {
|
||||
current_option = -1;
|
||||
save_accept->get_ok()->set_text(p_title);
|
||||
save_accept->set_text(p_text);
|
||||
save_accept->popup_centered();
|
||||
}
|
||||
|
||||
void EditorNode::show_warning(const String &p_text, const String &p_title) {
|
||||
if (warning->is_inside_tree()) {
|
||||
warning->set_text(p_text);
|
||||
|
@ -6178,6 +6189,10 @@ EditorNode::EditorNode() {
|
|||
gui_base->add_child(accept);
|
||||
accept->connect("confirmed", this, "_menu_confirm_current");
|
||||
|
||||
save_accept = memnew(AcceptDialog);
|
||||
gui_base->add_child(save_accept);
|
||||
save_accept->connect("confirmed", this, "_menu_option", make_binds((int)MenuOptions::FILE_SAVE_AS_SCENE));
|
||||
|
||||
project_export = memnew(ProjectExportDialog);
|
||||
gui_base->add_child(project_export);
|
||||
|
||||
|
|
|
@ -311,6 +311,7 @@ private:
|
|||
ConfirmationDialog *pick_main_scene;
|
||||
Button *select_current_scene_button;
|
||||
AcceptDialog *accept;
|
||||
AcceptDialog *save_accept;
|
||||
EditorAbout *about;
|
||||
AcceptDialog *warning;
|
||||
|
||||
|
@ -802,6 +803,7 @@ public:
|
|||
Ref<Texture> get_class_icon(const String &p_class, const String &p_fallback = "Object") const;
|
||||
|
||||
void show_accept(const String &p_text, const String &p_title);
|
||||
void show_save_accept(const String &p_text, const String &p_title);
|
||||
void show_warning(const String &p_text, const String &p_title = TTR("Warning!"));
|
||||
|
||||
void _copy_warning(const String &p_str);
|
||||
|
|
Loading…
Reference in a new issue