| 2810 | } |
| 2811 | |
| 2812 | void ScriptEditor::save_all_scripts() { |
| 2813 | HashSet<String> scenes_to_save; |
| 2814 | |
| 2815 | for (int i = 0; i < tab_container->get_tab_count(); i++) { |
| 2816 | ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); |
| 2817 | if (!se) { |
| 2818 | continue; |
| 2819 | } |
| 2820 | |
| 2821 | if (convert_indent_on_save) { |
| 2822 | se->convert_indent(); |
| 2823 | } |
| 2824 | |
| 2825 | if (trim_trailing_whitespace_on_save) { |
| 2826 | se->trim_trailing_whitespace(); |
| 2827 | } |
| 2828 | |
| 2829 | if (trim_final_newlines_on_save) { |
| 2830 | se->trim_final_newlines(); |
| 2831 | } |
| 2832 | |
| 2833 | if (!se->is_unsaved()) { |
| 2834 | continue; |
| 2835 | } |
| 2836 | |
| 2837 | Ref<Resource> edited_res = se->get_edited_resource(); |
| 2838 | if (edited_res.is_valid()) { |
| 2839 | se->apply_code(); |
| 2840 | } |
| 2841 | |
| 2842 | Ref<Script> scr = edited_res; |
| 2843 | |
| 2844 | if (scr.is_valid()) { |
| 2845 | clear_docs_from_script(scr); |
| 2846 | } |
| 2847 | |
| 2848 | if (!edited_res->is_built_in()) { |
| 2849 | Ref<TextFile> text_file = edited_res; |
| 2850 | if (text_file.is_valid()) { |
| 2851 | _save_text_file(text_file, text_file->get_path()); |
| 2852 | continue; |
| 2853 | } |
| 2854 | |
| 2855 | // External script, save it. |
| 2856 | EditorNode::get_singleton()->save_resource(edited_res); |
| 2857 | } else { |
| 2858 | // For built-in scripts, save their scenes instead. |
| 2859 | const String scene_path = edited_res->get_path().get_slice("::", 0); |
| 2860 | if (!scene_path.is_empty() && !scenes_to_save.has(scene_path)) { |
| 2861 | scenes_to_save.insert(scene_path); |
| 2862 | } |
| 2863 | } |
| 2864 | |
| 2865 | if (scr.is_valid()) { |
| 2866 | update_docs_from_script(scr); |
| 2867 | } |
| 2868 | } |
| 2869 |
no test coverage detected