MMNodeUniversalProperty bindings cleanup.

This commit is contained in:
Relintai 2022-06-07 10:55:42 +02:00
parent 7f0b7d121e
commit 523ed95055
2 changed files with 29 additions and 10 deletions

View File

@ -164,12 +164,6 @@ void MMNodeUniversalProperty::set_owner(const Ref<MMNode> &val) {
owner = val;
}
void MMNodeUniversalProperty::_init() {
if (input_property.is_valid()) {
input_property->connect("changed", this, "on_input_property_changed");
}
}
Variant MMNodeUniversalProperty::get_value(const Vector2 &uv, const bool skip_owner_val) {
if (get_value_from_owner && !skip_owner_val) {
return get_owner_value(uv);
@ -500,6 +494,14 @@ MMNodeUniversalProperty::MMNodeUniversalProperty() {
MMNodeUniversalProperty::~MMNodeUniversalProperty() {
}
void MMNodeUniversalProperty::_notification(int p_what) {
if (p_what == NOTIFICATION_POSTINITIALIZE) {
if (input_property.is_valid()) {
input_property->connect("changed", this, "on_input_property_changed");
}
}
}
void MMNodeUniversalProperty::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_default_type"), &MMNodeUniversalProperty::get_default_type);
ClassDB::bind_method(D_METHOD("set_default_type", "value"), &MMNodeUniversalProperty::set_default_type);
@ -571,8 +573,6 @@ void MMNodeUniversalProperty::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_owner", "value"), &MMNodeUniversalProperty::set_owner);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "MMNode", 0), "set_owner", "get_owner");
ClassDB::bind_method(D_METHOD("_init"), &MMNodeUniversalProperty::_init);
ClassDB::bind_method(D_METHOD("get_value", "uv", "skip_owner_val"), &MMNodeUniversalProperty::get_value, false);
ClassDB::bind_method(D_METHOD("get_owner_value", "uv"), &MMNodeUniversalProperty::get_owner_value);
ClassDB::bind_method(D_METHOD("get_value_or_zero", "uv", "skip_owner_val"), &MMNodeUniversalProperty::get_value_or_zero, false);
@ -588,4 +588,20 @@ void MMNodeUniversalProperty::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_default_value", "uv"), &MMNodeUniversalProperty::get_default_value, Vector2());
ClassDB::bind_method(D_METHOD("set_default_value", "val"), &MMNodeUniversalProperty::set_default_value);
ClassDB::bind_method(D_METHOD("get_active_image"), &MMNodeUniversalProperty::get_active_image);
BIND_ENUM_CONSTANT(SLOT_TYPE_NONE);
BIND_ENUM_CONSTANT(SLOT_TYPE_IMAGE);
BIND_ENUM_CONSTANT(SLOT_TYPE_INT);
BIND_ENUM_CONSTANT(SLOT_TYPE_FLOAT);
BIND_ENUM_CONSTANT(SLOT_TYPE_VECTOR2);
BIND_ENUM_CONSTANT(SLOT_TYPE_VECTOR3);
BIND_ENUM_CONSTANT(SLOT_TYPE_COLOR);
BIND_ENUM_CONSTANT(SLOT_TYPE_UNIVERSAL);
BIND_ENUM_CONSTANT(DEFAULT_TYPE_INT);
BIND_ENUM_CONSTANT(DEFAULT_TYPE_FLOAT);
BIND_ENUM_CONSTANT(DEFAULT_TYPE_VECTOR2);
BIND_ENUM_CONSTANT(DEFAULT_TYPE_VECTOR3);
BIND_ENUM_CONSTANT(DEFAULT_TYPE_COLOR);
BIND_ENUM_CONSTANT(DEFAULT_TYPE_IMAGE);
}

View File

@ -4,6 +4,7 @@
#include "core/image.h"
#include "core/math/vector2.h"
#include "core/math/vector3.h"
#include "core/method_bind.h"
#include "core/variant.h"
#include "core/resource.h"
@ -87,8 +88,6 @@ public:
Ref<MMNode> get_owner();
void set_owner(const Ref<MMNode> &val);
void _init();
Variant get_value(const Vector2 &uv, const bool skip_owner_val = false);
Variant get_owner_value(const Vector2 &uv);
Variant get_value_or_zero(const Vector2 &uv, const bool skip_owner_val = false);
@ -109,6 +108,7 @@ public:
~MMNodeUniversalProperty();
protected:
void _notification(int p_what);
static void _bind_methods();
//export(int, "Int,Float,Vector2,Vector3,Color,Image")
@ -142,4 +142,7 @@ protected:
Ref<MMNode> owner;
};
VARIANT_ENUM_CAST(MMNodeUniversalProperty::SlotTypes);
VARIANT_ENUM_CAST(MMNodeUniversalProperty::MMNodeUniversalPropertyDefaultType);
#endif