-Deprecate ImageTexture::load
-Add warning to Image::load when loading resources -Add script binding for get_configuration_warning
This commit is contained in:
parent
b4f579b5ba
commit
ef5095720b
4 changed files with 17 additions and 4 deletions
|
@ -36,8 +36,8 @@
|
|||
#include "math_funcs.h"
|
||||
#include "print_string.h"
|
||||
|
||||
#include "io/resource_loader.h"
|
||||
#include "thirdparty/misc/hq2x.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const char *Image::format_names[Image::FORMAT_MAX] = {
|
||||
|
@ -1582,7 +1582,11 @@ Image::AlphaMode Image::detect_alpha() const {
|
|||
}
|
||||
|
||||
Error Image::load(const String &p_path) {
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (p_path.begins_with("res://") && ResourceLoader::exists(p_path)) {
|
||||
WARN_PRINTS("Loaded resource as image file, this will not work on export: '" + p_path + "'. Instead, import the image file as an Image resource and load it normally as a resource.");
|
||||
}
|
||||
#endif
|
||||
return ImageLoader::load_image(p_path, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -2555,6 +2555,9 @@ void Node::clear_internal_tree_resource_paths() {
|
|||
|
||||
String Node::get_configuration_warning() const {
|
||||
|
||||
if (get_script_instance()) {
|
||||
return get_script_instance()->call("_get_configuration_warning");
|
||||
}
|
||||
return String();
|
||||
}
|
||||
|
||||
|
@ -2763,6 +2766,7 @@ void Node::_bind_methods() {
|
|||
BIND_VMETHOD(MethodInfo("_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
||||
BIND_VMETHOD(MethodInfo("_unhandled_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
||||
BIND_VMETHOD(MethodInfo("_unhandled_key_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEventKey")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_configuration_warning"));
|
||||
|
||||
//ClassDB::bind_method(D_METHOD("get_child",&Node::get_child,PH("index")));
|
||||
//ClassDB::bind_method(D_METHOD("get_node",&Node::get_node,PH("path")));
|
||||
|
|
|
@ -214,9 +214,10 @@ Image::Format ImageTexture::get_format() const {
|
|||
|
||||
return format;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
Error ImageTexture::load(const String &p_path) {
|
||||
|
||||
WARN_DEPRECATED
|
||||
Ref<Image> img;
|
||||
img.instance();
|
||||
Error err = img->load(p_path);
|
||||
|
@ -225,7 +226,7 @@ Error ImageTexture::load(const String &p_path) {
|
|||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif
|
||||
void ImageTexture::set_data(const Ref<Image> &p_image) {
|
||||
|
||||
ERR_FAIL_COND(p_image.is_null());
|
||||
|
@ -345,7 +346,9 @@ void ImageTexture::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("create", "width", "height", "format", "flags"), &ImageTexture::create, DEFVAL(FLAGS_DEFAULT));
|
||||
ClassDB::bind_method(D_METHOD("create_from_image", "image", "flags"), &ImageTexture::create_from_image, DEFVAL(FLAGS_DEFAULT));
|
||||
ClassDB::bind_method(D_METHOD("get_format"), &ImageTexture::get_format);
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
ClassDB::bind_method(D_METHOD("load", "path"), &ImageTexture::load);
|
||||
#endif
|
||||
ClassDB::bind_method(D_METHOD("set_data", "image"), &ImageTexture::set_data);
|
||||
ClassDB::bind_method(D_METHOD("set_storage", "mode"), &ImageTexture::set_storage);
|
||||
ClassDB::bind_method(D_METHOD("get_storage"), &ImageTexture::get_storage);
|
||||
|
|
|
@ -125,7 +125,9 @@ public:
|
|||
void set_flags(uint32_t p_flags);
|
||||
uint32_t get_flags() const;
|
||||
Image::Format get_format() const;
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
Error load(const String &p_path);
|
||||
#endif
|
||||
void set_data(const Ref<Image> &p_image);
|
||||
Ref<Image> get_data() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue