summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-11-25 16:56:49 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-11-25 16:57:23 -0300
commit81c86e8047d86d03e690948c68eb54c5b115f2ab (patch)
treea498149a61f47f56a1ca0a8c864b66b2a5610913 /scene
parent95d604b9cdde554a4e3ede796791827eb33e3196 (diff)
Improved bindings and added documentation for AnimationNode, closes #20720
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/animation_tree.cpp34
1 files changed, 34 insertions, 0 deletions
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<PropertyInfo> *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<ChildNode> *r_child_nodes) {
+
+ if (get_script_instance()) {
+ Dictionary cn = get_script_instance()->call("get_child_nodes");
+ List<Variant> keys;
+ cn.get_key_list(&keys);
+ for (List<Variant>::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> AnimationNode::get_child_by_name(const StringName &p_name) {
+ if (get_script_instance()) {
+ return get_script_instance()->call("get_child_by_nane");
+ }
return Ref<AnimationNode>();
}
@@ -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"));