MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _save_external_resources

Method _save_external_resources

editor/editor_node.cpp:2034–2101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2032}
2033
2034int EditorNode::_save_external_resources(bool p_also_save_external_data) {
2035 int flg = 0;
2036 if (EDITOR_GET("filesystem/on_save/compress_binary_resources")) {
2037 flg |= ResourceSaver::FLAG_COMPRESS;
2038 }
2039 flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
2040
2041 HashSet<String> edited_resources;
2042 int saved = 0;
2043 List<Ref<Resource>> cached;
2044 ResourceCache::get_cached_resources(&cached);
2045
2046 for (Ref<Resource> res : cached) {
2047 if (!res->is_edited()) {
2048 continue;
2049 }
2050
2051 String path = res->get_path();
2052 if (path.begins_with("res://")) {
2053 int subres_pos = path.find("::");
2054 if (subres_pos == -1) {
2055 // Actual resource.
2056 edited_resources.insert(path);
2057 } else {
2058 edited_resources.insert(path.substr(0, subres_pos));
2059 }
2060 }
2061
2062 res->set_edited(false);
2063 }
2064
2065 bool script_was_saved = false;
2066 for (const String &E : edited_resources) {
2067 Ref<Resource> res = ResourceCache::get_ref(E);
2068 if (res.is_null()) {
2069 continue; // Maybe it was erased in a thread, who knows.
2070 }
2071 Ref<PackedScene> ps = res;
2072 if (ps.is_valid()) {
2073 continue; // Do not save PackedScenes, this will mess up the editor.
2074 }
2075 if (!script_was_saved) {
2076 Ref<Script> scr = res;
2077 script_was_saved = scr.is_valid();
2078 }
2079 ResourceSaver::save(res, res->get_path(), flg);
2080 saved++;
2081 }
2082
2083 if (script_was_saved) {
2084 ScriptEditor::get_singleton()->update_script_times();
2085 }
2086
2087 if (p_also_save_external_data) {
2088 for (int i = 0; i < editor_data.get_editor_plugin_count(); i++) {
2089 EditorPlugin *plugin = editor_data.get_editor_plugin(i);
2090 if (!plugin->get_unsaved_status().is_empty()) {
2091 plugin->save_external_data();

Callers

nothing calls this directly

Calls 15

is_editedMethod · 0.80
begins_withMethod · 0.80
substrMethod · 0.80
update_script_timesMethod · 0.80
get_editor_pluginMethod · 0.80
set_history_as_savedMethod · 0.80
get_pathMethod · 0.45
findMethod · 0.45
insertMethod · 0.45
set_editedMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected