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

Method save_resource_in_path

editor/editor_node.cpp:1580–1620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1578}
1579
1580void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path) {
1581 editor_data.apply_changes_in_editors();
1582
1583 if (saving_resources_in_path.has(p_resource)) {
1584 return;
1585 }
1586 saving_resources_in_path.insert(p_resource);
1587
1588 int flg = 0;
1589 if (EDITOR_GET("filesystem/on_save/compress_binary_resources")) {
1590 flg |= ResourceSaver::FLAG_COMPRESS;
1591 }
1592
1593 String path = ProjectSettings::get_singleton()->localize_path(p_path);
1594 Error err = ResourceSaver::save(p_resource, path, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
1595
1596 if (err != OK) {
1597 if (ResourceLoader::is_imported(p_resource->get_path())) {
1598 show_accept(TTR("Imported resources can't be saved."), TTR("OK"));
1599 } else {
1600 show_accept(TTR("Error saving resource!"), TTR("OK"));
1601 }
1602
1603 saving_resources_in_path.erase(p_resource);
1604 return;
1605 }
1606
1607 Ref<Resource> prev_resource = ResourceCache::get_ref(p_path);
1608 if (prev_resource.is_null() || prev_resource != p_resource) {
1609 p_resource->set_path(path, true);
1610 }
1611 if (prev_resource.is_valid() && prev_resource != p_resource) {
1612 replace_resources_in_scenes({ prev_resource }, { p_resource });
1613 }
1614 saving_resources_in_path.erase(p_resource);
1615
1616 _resource_saved(p_resource, path);
1617
1618 emit_signal(SNAME("resource_saved"), p_resource);
1619 editor_data.notify_resource_saved(p_resource);
1620}
1621
1622void EditorNode::save_resource(const Ref<Resource> &p_resource) {
1623 // If built-in resource, save the scene instead.

Callers 1

_load_fileMethod · 0.80

Calls 11

TTRFunction · 0.85
localize_pathMethod · 0.80
hasMethod · 0.45
insertMethod · 0.45
get_pathMethod · 0.45
eraseMethod · 0.45
is_nullMethod · 0.45
set_pathMethod · 0.45
is_validMethod · 0.45
notify_resource_savedMethod · 0.45

Tested by

no test coverage detected