Esempio n. 1
0
RES ResourceFormatLoader::load(const String &p_path, const String& p_original_path, Error *r_error) {


	String path=p_path;

	//or this must be implemented
	Ref<ResourceInteractiveLoader> ril = load_interactive(p_path,r_error);
	if (!ril.is_valid())
		return RES();
	ril->set_local_path(p_original_path);

	while(true) {

		Error err = ril->poll();

		if (err==ERR_FILE_EOF) {
			if (r_error)
				*r_error=OK;
			return ril->get_resource();
		}

		if (r_error)
			*r_error=err;

		ERR_FAIL_COND_V(err!=OK,RES());
	}

	return RES();

}
Esempio n. 2
0
RES ResourceFormatLoader::load(const String &p_path, const String &p_original_path, Error *r_error) {

	if (get_script_instance() && get_script_instance()->has_method("load")) {
		Variant res = get_script_instance()->call("load", p_path, p_original_path);

		if (res.get_type() == Variant::INT) {

			if (r_error)
				*r_error = (Error)res.operator int64_t();

		} else {

			if (r_error)
				*r_error = OK;
			return res;
		}
	}

	//or this must be implemented
	Ref<ResourceInteractiveLoader> ril = load_interactive(p_path, p_original_path, r_error);
	if (!ril.is_valid())
		return RES();
	ril->set_local_path(p_original_path);

	while (true) {

		Error err = ril->poll();

		if (err == ERR_FILE_EOF) {
			if (r_error)
				*r_error = OK;
			return ril->get_resource();
		}

		if (r_error)
			*r_error = err;

		ERR_FAIL_COND_V(err != OK, RES());
	}

	return RES();
}