diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index e9e6cc9ea0..112d94dc3b 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -559,7 +559,7 @@ void EditorNode::_menu_confirm_current() { _menu_option_confirm(current_option, true); } -void EditorNode::_dialog_display_file_error(String p_file, Error p_error) { +void EditorNode::_dialog_display_save_error(String p_file, Error p_error) { if (p_error) { @@ -586,6 +586,41 @@ void EditorNode::_dialog_display_file_error(String p_file, Error p_error) { } } +void EditorNode::_dialog_display_load_error(String p_file, Error p_error) { + + if (p_error) { + + current_option = -1; + accept->get_ok()->set_text(TTR("I see..")); + + switch (p_error) { + + case ERR_CANT_OPEN: { + + accept->set_text(vformat(TTR("Can't open '%s'."), p_file.get_file())); + } break; + case ERR_PARSE_ERROR: { + + accept->set_text(vformat(TTR("Error while parsing '%s'."), p_file.get_file())); + } break; + case ERR_FILE_CORRUPT: { + + accept->set_text(vformat(TTR("Unexpected end of file '%s'."), p_file.get_file())); + } break; + case ERR_FILE_NOT_FOUND: { + + accept->set_text(vformat(TTR("Missing '%s' or its dependencies."), p_file.get_file())); + } break; + default: { + + accept->set_text(vformat(TTR("Error while loading '%s'."), p_file.get_file())); + } break; + } + + accept->popup_centered_minsize(); + } +} + void EditorNode::_get_scene_metadata(const String &p_file) { Node *scene = editor_data.get_edited_scene_root(); @@ -899,7 +934,7 @@ void EditorNode::_save_scene(String p_file, int idx) { _update_scene_tabs(); } else { - _dialog_display_file_error(p_file, err); + _dialog_display_save_error(p_file, err); } } @@ -908,8 +943,10 @@ 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() != "") { - // save in background if in the script editor - _save_scene_with_preview(scene->get_filename()); + 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 } @@ -983,7 +1020,10 @@ void EditorNode::_dialog_action(String p_file) { if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { _save_default_environment(); - _save_scene_with_preview(p_file); + if (scene_idx != editor_data.get_edited_scene()) + _save_scene(p_file, scene_idx); + else + _save_scene_with_preview(p_file); if (scene_idx != -1) _discard_changes(); @@ -1660,8 +1700,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { Node *scene = editor_data.get_edited_scene_root(scene_idx); if (scene && scene->get_filename() != "") { - // save in background if in the script editor - _save_scene_with_preview(scene->get_filename()); + if (scene_idx != editor_data.get_edited_scene()) + _save_scene(scene->get_filename(), scene_idx); + else + _save_scene_with_preview(scene->get_filename()); if (scene_idx != -1) _discard_changes(); @@ -2783,13 +2825,11 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b dependency_errors.clear(); - Ref<PackedScene> sdata = ResourceLoader::load(lpath, "", true); + Error err; + Ref<PackedScene> sdata = ResourceLoader::load(lpath, "", true, &err); if (!sdata.is_valid()) { - current_option = -1; - accept->get_ok()->set_text(TTR("Ugh")); - accept->set_text(TTR("Error loading scene.")); - accept->popup_centered_minsize(); + _dialog_display_load_error(lpath, err); opening_prev = false; if (prev != -1) { @@ -2846,10 +2886,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b if (!new_scene) { sdata.unref(); - current_option = -1; - accept->get_ok()->set_text(TTR("Ugh")); - accept->set_text(TTR("Error loading scene.")); - accept->popup_centered_minsize(); + _dialog_display_load_error(lpath, ERR_FILE_NOT_FOUND); opening_prev = false; if (prev != -1) { set_current_scene(prev); |