You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-21 14:57:09 +00:00
@@ -743,100 +743,6 @@ void EditorNode::_set_scene_metadata(const String& p_file) {
|
||||
|
||||
}
|
||||
|
||||
static Error _fix_object_paths(Object* obj, Node* root, String save_path) {
|
||||
|
||||
Globals* g = Globals::get_singleton();
|
||||
|
||||
String import_dir = root->get_meta("__editor_import_file__");
|
||||
import_dir = import_dir.get_base_dir();
|
||||
import_dir = DirAccess::normalize_path(import_dir);
|
||||
if (import_dir[import_dir.length()-1] != '/') {
|
||||
import_dir = import_dir + "/";
|
||||
};
|
||||
|
||||
String resource_dir = DirAccess::normalize_path(g->get_resource_path());
|
||||
if (resource_dir[resource_dir.length()-1] != '/') {
|
||||
resource_dir = resource_dir + "/";
|
||||
};
|
||||
|
||||
|
||||
List<PropertyInfo> list;
|
||||
obj->get_property_list(&list, false);
|
||||
|
||||
List<PropertyInfo>::Element *E = list.front();
|
||||
|
||||
while (E) {
|
||||
|
||||
Variant v = obj->get(E->get().name);
|
||||
if (v.get_type() == Variant::OBJECT) {
|
||||
|
||||
Ref<Resource> res = (RefPtr)v;
|
||||
if (res.is_null()) {
|
||||
E = E->next();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (res->get_path() != "") {
|
||||
|
||||
String res_path = res->get_path();
|
||||
res_path = Globals::get_singleton()->globalize_path(res_path);
|
||||
res_path = DirAccess::normalize_path(res_path);
|
||||
|
||||
if (res_path.find(resource_dir) != 0) {
|
||||
|
||||
// path of resource is not inside engine's resource path
|
||||
|
||||
String new_path;
|
||||
|
||||
if (res_path.find(import_dir) == 0) {
|
||||
|
||||
// path of resource is relative to path of import file
|
||||
new_path = save_path + "/" + res_path.substr(import_dir.length(), res_path.length() - import_dir.length());
|
||||
|
||||
} else {
|
||||
|
||||
// path of resource is not relative to import file
|
||||
new_path = save_path + "/" + res_path.get_file();
|
||||
};
|
||||
|
||||
res->set_path(g->localize_path(new_path));
|
||||
DirAccess* d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||
d->make_dir_recursive(new_path.get_base_dir());
|
||||
printf("copying from %ls to %ls\n", res_path.c_str(), new_path.c_str());
|
||||
Error err = d->copy(res_path, new_path);
|
||||
memdelete(d);
|
||||
ERR_FAIL_COND_V(err != OK, err);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
_fix_object_paths(res.operator->(), root, save_path);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
E = E->next();
|
||||
};
|
||||
|
||||
return OK;
|
||||
};
|
||||
|
||||
static Error _fix_imported_scene_paths(Node* node, Node* root, String save_path) {
|
||||
|
||||
if (node == root || node->get_owner() == root) {
|
||||
Error e = _fix_object_paths(node, root, save_path);
|
||||
ERR_FAIL_COND_V(e != OK, e);
|
||||
};
|
||||
|
||||
for (int i=0; i<node->get_child_count(); i++) {
|
||||
|
||||
Error e = _fix_imported_scene_paths(node->get_child(i), root, save_path);
|
||||
ERR_FAIL_COND_V(e != OK, e);
|
||||
};
|
||||
|
||||
return OK;
|
||||
};
|
||||
|
||||
|
||||
bool EditorNode::_find_and_save_resource(RES res,Map<RES,bool>& processed,int32_t flags) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user