From 81c86e8047d86d03e690948c68eb54c5b115f2ab Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 25 Nov 2018 16:56:49 -0300 Subject: Improved bindings and added documentation for AnimationNode, closes #20720 --- scene/animation/animation_tree.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'scene') diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index eb00f91bb3..03c3c78768 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -37,9 +37,20 @@ #include "servers/audio/audio_stream.h" void AnimationNode::get_parameter_list(List *r_list) const { + if (get_script_instance()) { + Array parameters = get_script_instance()->call("get_parameter_list"); + for (int i = 0; i < parameters.size(); i++) { + Dictionary d = parameters[i]; + ERR_CONTINUE(d.empty()); + r_list->push_back(PropertyInfo::from_dict(d)); + } + } } Variant AnimationNode::get_parameter_default_value(const StringName &p_parameter) const { + if (get_script_instance()) { + return get_script_instance()->call("get_parameter_default_value"); + } return Variant(); } @@ -62,6 +73,18 @@ Variant AnimationNode::get_parameter(const StringName &p_name) const { } void AnimationNode::get_child_nodes(List *r_child_nodes) { + + if (get_script_instance()) { + Dictionary cn = get_script_instance()->call("get_child_nodes"); + List keys; + cn.get_key_list(&keys); + for (List::Element *E = keys.front(); E; E = E->next()) { + ChildNode child; + child.name = E->get(); + child.node = cn[E->get()]; + r_child_nodes->push_back(child); + } + } } void AnimationNode::blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend) { @@ -373,6 +396,9 @@ void AnimationNode::_validate_property(PropertyInfo &property) const { } Ref AnimationNode::get_child_by_name(const StringName &p_name) { + if (get_script_instance()) { + return get_script_instance()->call("get_child_by_nane"); + } return Ref(); } @@ -403,6 +429,14 @@ void AnimationNode::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter_enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_filter_enabled", "is_filter_enabled"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "filters", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_filters", "_get_filters"); + BIND_VMETHOD(MethodInfo(Variant::DICTIONARY, "get_child_nodes")); + BIND_VMETHOD(MethodInfo(Variant::ARRAY, "get_parameter_list")); + BIND_VMETHOD(MethodInfo(Variant::OBJECT, "get_child_by_name", PropertyInfo(Variant::STRING, "name"))); + { + MethodInfo mi = MethodInfo(Variant::NIL, "get_parameter_default_value", PropertyInfo(Variant::STRING, "name")); + mi.return_val.usage = PROPERTY_USAGE_NIL_IS_VARIANT; + BIND_VMETHOD(mi); + } BIND_VMETHOD(MethodInfo("process", PropertyInfo(Variant::REAL, "time"), PropertyInfo(Variant::BOOL, "seek"))); BIND_VMETHOD(MethodInfo(Variant::STRING, "get_caption")); BIND_VMETHOD(MethodInfo(Variant::STRING, "has_filter")); -- cgit v1.2.3