Fixed bindings, and now the importers work. The Merger can use this Texture type by default.

This commit is contained in:
Relintai 2019-10-22 15:09:47 +02:00
parent b0b34add3f
commit b39313b237
3 changed files with 19 additions and 4 deletions

View File

@ -50,8 +50,8 @@ Ref<Image> PackerImageResource::get_data() const {
}
void PackerImageResource::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_data", "image"), &PackerImageResource::set_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "Image"), "set_data", "get_data");
}
PackerImageResource::PackerImageResource() {

View File

@ -33,6 +33,8 @@ String PackerImageResourceImporter::get_preset_name(int p_idx) const {
}
void PackerImageResourceImporter::get_import_options(List<ImportOption> *r_options, int p_preset) const {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "hdr_as_srgb"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "scale"), 1.0));
}
bool PackerImageResourceImporter::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
@ -40,17 +42,24 @@ bool PackerImageResourceImporter::get_option_visibility(const String &p_option,
}
Error PackerImageResourceImporter::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
bool hdr_as_srgb = p_options["hdr_as_srgb"];
float scale = p_options["scale"];
/*
Ref<Image> image;
image.instance();
Error err = ImageLoader::load_image(p_source_file, image, NULL, hdr_as_srgb, scale);
if (err != OK)
return err;
*/
return Error::FAILED;
Ref<PackerImageResource> res;
res.instance();
res->set_data(image);
return ResourceSaver::save(p_save_path + "." + get_save_extension(), res);
return Error::ERR_PARSE_ERROR;
}
PackerImageResourceImporter::PackerImageResourceImporter() {

View File

@ -4,10 +4,13 @@
#include "editor/import/editor_import_plugin.h"
#include "core/ustring.h"
#include "core/io/resource_saver.h"
#include "core/image.h"
#include "core/io/image_loader.h"
#include "packer_image_resource.h"
class PackerImageResourceImporter : public EditorImportPlugin {
GDCLASS(PackerImageResourceImporter, EditorImportPlugin);
@ -30,6 +33,9 @@ public:
PackerImageResourceImporter();
~PackerImageResourceImporter();
private:
};
#endif