Merge pull request #271 from Windfisch/fix-register-property
Fix registering properties of reference-types by applying bruvzg's patchpull/286/head
commit
7defa6f77e
|
@ -326,8 +326,13 @@ void register_property(const char *name, P(T::*var), P default_value, godot_meth
|
||||||
godot_string *_hint_string = (godot_string *)&hint_string;
|
godot_string *_hint_string = (godot_string *)&hint_string;
|
||||||
|
|
||||||
godot_property_attributes attr = {};
|
godot_property_attributes attr = {};
|
||||||
|
if (def_val.get_type() == Variant::NIL) {
|
||||||
|
attr.type = Variant::OBJECT;
|
||||||
|
} else {
|
||||||
attr.type = def_val.get_type();
|
attr.type = def_val.get_type();
|
||||||
attr.default_value = *(godot_variant *)&def_val;
|
attr.default_value = *(godot_variant *)&def_val;
|
||||||
|
}
|
||||||
|
|
||||||
attr.hint = hint;
|
attr.hint = hint;
|
||||||
attr.rset_type = rpc_mode;
|
attr.rset_type = rpc_mode;
|
||||||
attr.usage = usage;
|
attr.usage = usage;
|
||||||
|
@ -356,12 +361,19 @@ template <class T, class P>
|
||||||
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(), P default_value, godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED, godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT, godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(), P default_value, godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED, godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT, godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
||||||
Variant def_val = default_value;
|
Variant def_val = default_value;
|
||||||
|
|
||||||
|
godot_string *_hint_string = (godot_string *)&hint_string;
|
||||||
|
|
||||||
godot_property_attributes attr = {};
|
godot_property_attributes attr = {};
|
||||||
|
if (def_val.get_type() == Variant::NIL) {
|
||||||
|
attr.type = Variant::OBJECT;
|
||||||
|
} else {
|
||||||
attr.type = def_val.get_type();
|
attr.type = def_val.get_type();
|
||||||
attr.default_value = *(godot_variant *)&def_val;
|
attr.default_value = *(godot_variant *)&def_val;
|
||||||
|
}
|
||||||
attr.hint = hint;
|
attr.hint = hint;
|
||||||
attr.rset_type = rpc_mode;
|
attr.rset_type = rpc_mode;
|
||||||
attr.usage = usage;
|
attr.usage = usage;
|
||||||
|
attr.hint_string = *_hint_string;
|
||||||
|
|
||||||
_PropertySetFunc<T, P> *wrapped_set = (_PropertySetFunc<T, P> *)godot::api->godot_alloc(sizeof(_PropertySetFunc<T, P>));
|
_PropertySetFunc<T, P> *wrapped_set = (_PropertySetFunc<T, P> *)godot::api->godot_alloc(sizeof(_PropertySetFunc<T, P>));
|
||||||
wrapped_set->f = setter;
|
wrapped_set->f = setter;
|
||||||
|
|
Loading…
Reference in New Issue