Swap arguments of ResourceSaver.save()

This commit is contained in:
kobewi 2022-06-03 01:33:42 +02:00
parent ba3734e69a
commit c3606cb5f3
57 changed files with 97 additions and 99 deletions

View file

@ -103,7 +103,7 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String &
}
}
return ResourceSaver::save(p_save_path + ".res", bitmap);
return ResourceSaver::save(bitmap, p_save_path + ".res");
}
ResourceImporterBitMap::ResourceImporterBitMap() {

View file

@ -84,7 +84,7 @@ Error ResourceImporterBMFont::import(const String &p_source_file, const String &
}
print_verbose("Saving to: " + p_save_path + ".fontdata");
err = ResourceSaver::save(p_save_path + ".fontdata", font, flg);
err = ResourceSaver::save(font, p_save_path + ".fontdata", flg);
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save font to file \"" + p_save_path + ".res\".");
print_verbose("Done saving to: " + p_save_path + ".fontdata");
return OK;

View file

@ -131,7 +131,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
String save_path = p_source_file.get_basename() + "." + translations[i]->get_locale() + ".translation";
ResourceSaver::save(save_path, xlt);
ResourceSaver::save(xlt, save_path);
if (r_gen_files) {
r_gen_files->push_back(save_path);
}

View file

@ -219,7 +219,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str
}
print_verbose("Saving to: " + p_save_path + ".fontdata");
Error err = ResourceSaver::save(p_save_path + ".fontdata", font, flg);
Error err = ResourceSaver::save(font, p_save_path + ".fontdata", flg);
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save font to file \"" + p_save_path + ".res\".");
print_verbose("Done saving to: " + p_save_path + ".fontdata");
return OK;

View file

@ -159,7 +159,7 @@ Error ResourceImporterImageFont::import(const String &p_source_file, const Strin
}
print_verbose("Saving to: " + p_save_path + ".fontdata");
err = ResourceSaver::save(p_save_path + ".fontdata", font, flg);
err = ResourceSaver::save(font, p_save_path + ".fontdata", flg);
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save font to file \"" + p_save_path + ".res\".");
print_verbose("Done saving to: " + p_save_path + ".fontdata");
return OK;

View file

@ -519,7 +519,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
String save_path = p_save_path + ".mesh";
err = ResourceSaver::save(save_path, meshes.front()->get());
err = ResourceSaver::save(meshes.front()->get(), save_path);
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save Mesh to file '" + save_path + "'.");

View file

@ -1224,7 +1224,7 @@ Ref<Animation> ResourceImporterScene::_save_animation_to_file(Ref<Animation> ani
}
}
anim->set_path(p_save_to_path, true); // Set path to save externally.
Error err = ResourceSaver::save(p_save_to_path, anim, ResourceSaver::FLAG_CHANGE_PATH);
Error err = ResourceSaver::save(anim, p_save_to_path, ResourceSaver::FLAG_CHANGE_PATH);
ERR_FAIL_COND_V_MSG(err != OK, anim, "Saving of animation failed: " + p_save_to_path);
return anim;
}
@ -1842,7 +1842,7 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
}
mesh = src_mesh_node->get_mesh()->get_mesh(existing);
ResourceSaver::save(save_to_file, mesh); //override
ResourceSaver::save(mesh, save_to_file); //override
mesh->set_path(save_to_file, true); //takeover existing, if needed
@ -2310,14 +2310,14 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
}
print_verbose("Saving animation to: " + p_save_path + ".scn");
err = ResourceSaver::save(p_save_path + ".res", library); //do not take over, let the changed files reload themselves
err = ResourceSaver::save(library, p_save_path + ".res"); //do not take over, let the changed files reload themselves
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save animation to file '" + p_save_path + ".res'.");
} else {
Ref<PackedScene> packer = memnew(PackedScene);
packer->pack(scene);
print_verbose("Saving scene to: " + p_save_path + ".scn");
err = ResourceSaver::save(p_save_path + ".scn", packer); //do not take over, let the changed files reload themselves
err = ResourceSaver::save(packer, p_save_path + ".scn"); //do not take over, let the changed files reload themselves
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save scene to file '" + p_save_path + ".scn'.");
}

View file

@ -109,7 +109,7 @@ Error ResourceImporterShaderFile::import(const String &p_source_file, const Stri
}
}
ResourceSaver::save(p_save_path + ".res", shader_file);
ResourceSaver::save(shader_file, p_save_path + ".res");
return OK;
}

View file

@ -88,7 +88,7 @@ Error ResourceImporterTextureAtlas::import(const String &p_source_file, const St
//use an xpm because it's size independent, the editor images are vector and size dependent
//it's a simple hack
Ref<Image> broken = memnew(Image((const char **)atlas_import_failed_xpm));
ResourceSaver::save(p_save_path + ".tex", ImageTexture::create_from_image(broken));
ResourceSaver::save(ImageTexture::create_from_image(broken), p_save_path + ".tex");
return OK;
}
@ -386,7 +386,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
}
String save_path = p_base_paths[E.key] + ".res";
ResourceSaver::save(save_path, texture);
ResourceSaver::save(texture, save_path);
idx++;
}

View file

@ -531,7 +531,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
sample->set_loop_end(loop_end);
sample->set_stereo(format_channels == 2);
ResourceSaver::save(p_save_path + ".sample", sample);
ResourceSaver::save(sample, p_save_path + ".sample");
return OK;
}

View file

@ -1184,7 +1184,7 @@ void SceneImportSettings::_save_dir_confirm() {
ERR_CONTINUE(!material_map.has(id));
MaterialData &md = material_map[id];
Error err = ResourceSaver::save(path, md.material);
Error err = ResourceSaver::save(md.material, path);
if (err != OK) {
EditorNode::get_singleton()->add_io_error(TTR("Can't make material external to file, write error:") + "\n\t" + path);
continue;