| 2900 | } |
| 2901 | |
| 2902 | void ScriptEditor::_reload_scripts(bool p_refresh_only) { |
| 2903 | for (int i = 0; i < tab_container->get_tab_count(); i++) { |
| 2904 | ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); |
| 2905 | if (!se) { |
| 2906 | continue; |
| 2907 | } |
| 2908 | |
| 2909 | Ref<Resource> edited_res = se->get_edited_resource(); |
| 2910 | |
| 2911 | if (edited_res->is_built_in()) { |
| 2912 | continue; // Internal script, who cares. |
| 2913 | } |
| 2914 | |
| 2915 | if (p_refresh_only) { |
| 2916 | // Make sure the modified time is correct. |
| 2917 | se->edited_file_data.last_modified_time = FileAccess::get_modified_time(edited_res->get_path()); |
| 2918 | } else { |
| 2919 | uint64_t last_date = se->edited_file_data.last_modified_time; |
| 2920 | uint64_t date = FileAccess::get_modified_time(edited_res->get_path()); |
| 2921 | |
| 2922 | if (last_date == date) { |
| 2923 | continue; |
| 2924 | } |
| 2925 | se->edited_file_data.last_modified_time = date; |
| 2926 | |
| 2927 | Ref<Script> scr = edited_res; |
| 2928 | if (scr.is_valid()) { |
| 2929 | Ref<Script> rel_scr = ResourceLoader::load(scr->get_path(), scr->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); |
| 2930 | ERR_CONTINUE(rel_scr.is_null()); |
| 2931 | scr->set_source_code(rel_scr->get_source_code()); |
| 2932 | scr->reload(true); |
| 2933 | |
| 2934 | update_docs_from_script(scr); |
| 2935 | } |
| 2936 | |
| 2937 | Ref<JSON> json = edited_res; |
| 2938 | if (json.is_valid()) { |
| 2939 | Ref<JSON> rel_json = ResourceLoader::load(json->get_path(), json->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); |
| 2940 | ERR_CONTINUE(rel_json.is_null()); |
| 2941 | json->parse(rel_json->get_parsed_text(), true); |
| 2942 | } |
| 2943 | |
| 2944 | Ref<TextFile> text_file = edited_res; |
| 2945 | if (text_file.is_valid()) { |
| 2946 | text_file->reload_from_file(); |
| 2947 | } |
| 2948 | } |
| 2949 | |
| 2950 | se->reload_text(); |
| 2951 | } |
| 2952 | |
| 2953 | disk_changed->hide(); |
| 2954 | _update_script_names(); |
| 2955 | } |
| 2956 | |
| 2957 | void ScriptEditor::open_find_in_files_dialog(const String &text) { |
| 2958 | find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::SEARCH_MODE); |
nothing calls this directly
no test coverage detected