summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/editor_node.cpp39
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/scene_tree_dock.cpp12
3 files changed, 36 insertions, 17 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index e719797e03..9a79e1f942 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1757,13 +1757,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();
@@ -2484,20 +2486,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);
- } else {
- _save_scene_with_preview(scene->get_filename());
- }
+ 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();
+ if (scene_idx != -1) {
+ _discard_changes();
+ }
+ save_layout();
+ } else {
+ show_save_accept(vformat(TTR("%s no longer exists! Please specify a new save location."), scene->get_filename().get_base_dir()), TTR("OK"));
}
- save_layout();
-
break;
}
[[fallthrough]];
@@ -4150,6 +4154,13 @@ void EditorNode::show_accept(const String &p_text, const String &p_title) {
accept->popup_centered();
}
+void EditorNode::show_save_accept(const String &p_text, const String &p_title) {
+ current_option = -1;
+ save_accept->get_ok_button()->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);
@@ -6263,6 +6274,10 @@ EditorNode::EditorNode() {
gui_base->add_child(accept);
accept->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current));
+ save_accept = memnew(AcceptDialog);
+ gui_base->add_child(save_accept);
+ save_accept->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), make_binds((int)MenuOptions::FILE_SAVE_AS_SCENE));
+
project_export = memnew(ProjectExportDialog);
gui_base->add_child(project_export);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 2e8b850c7b..d1f4cf8452 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -308,6 +308,7 @@ private:
ConfirmationDialog *pick_main_scene;
Button *select_current_scene_button;
AcceptDialog *accept;
+ AcceptDialog *save_accept;
EditorAbout *about;
AcceptDialog *warning;
@@ -814,6 +815,7 @@ public:
Ref<Texture2D> 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);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 4bc0905163..5ce88949ef 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -848,7 +848,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
}
Ref<MultiNodeEdit> mne = memnew(MultiNodeEdit);
- for (const Map<Node *, Object *>::Element *E = EditorNode::get_singleton()->get_editor_selection()->get_selection().front(); E; E = E->next()) {
+ for (const Map<Node *, Object *>::Element *E = editor_selection->get_selection().front(); E; E = E->next()) {
mne->add_node(root->get_path_to(E->key()));
}
@@ -2101,11 +2101,11 @@ void SceneTreeDock::_update_script_button() {
if (!profile_allow_script_editing) {
button_create_script->hide();
button_detach_script->hide();
- } else if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 0) {
+ } else if (editor_selection->get_selection().size() == 0) {
button_create_script->hide();
button_detach_script->hide();
- } else if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) {
- Node *n = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()[0];
+ } else if (editor_selection->get_selection().size() == 1) {
+ Node *n = editor_selection->get_selected_node_list()[0];
if (n->get_script().is_null()) {
button_create_script->show();
button_detach_script->hide();
@@ -2128,10 +2128,12 @@ void SceneTreeDock::_update_script_button() {
}
void SceneTreeDock::_selection_changed() {
- int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size();
+ int selection_size = editor_selection->get_selection().size();
if (selection_size > 1) {
//automatically turn on multi-edit
_tool_selected(TOOL_MULTI_EDIT);
+ } else if (selection_size == 1) {
+ editor->push_item(editor_selection->get_selection().front()->key());
} else if (selection_size == 0) {
editor->push_item(nullptr);
}