From 3c371b989f309527f01c311bf02bfb533286de76 Mon Sep 17 00:00:00 2001 From: Micky Date: Sat, 6 Jan 2024 17:23:25 +0100 Subject: [PATCH] Add autocompletion to AnimationNode --- scene/animation/animation_tree.cpp | 28 ++++++++++++++++++++++++++++ scene/animation/animation_tree.h | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 2c2d8387f313..4889cd82af2c 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -444,6 +444,34 @@ double AnimationNode::blend_input_ex(int p_input, double p_time, bool p_seek, bo return blend_input(p_input, info, p_filter, p_sync, p_test_only); } +#ifdef TOOLS_ENABLED +void AnimationNode::get_argument_options(const StringName &p_function, int p_idx, List *r_options) const { + const String pf = p_function; + if (p_idx == 0) { + if (pf == "find_input") { + for (const AnimationNode::Input &E : inputs) { + r_options->push_back(E.name.quote()); + } + } else if (pf == "get_parameter" || pf == "set_parameter") { + bool is_setter = pf == "set_parameter"; + List parameters; + get_parameter_list(¶meters); + for (const PropertyInfo &E : parameters) { + if (is_setter && is_parameter_read_only(E.name)) { + continue; + } + r_options->push_back(E.name.quote()); + } + } else if (pf == "set_filter_path" || pf == "is_path_filtered") { + for (const KeyValue &E : filter) { + r_options->push_back(String(E.key).quote()); + } + } + } + Resource::get_argument_options(p_function, p_idx, r_options); +} +#endif + void AnimationNode::_bind_methods() { ClassDB::bind_method(D_METHOD("add_input", "name"), &AnimationNode::add_input); ClassDB::bind_method(D_METHOD("remove_input", "index"), &AnimationNode::remove_input); diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index 87928e4d2075..8b2a117b0562 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -151,6 +151,10 @@ class AnimationNode : public Resource { virtual bool has_filter() const; +#ifdef TOOLS_ENABLED + virtual void get_argument_options(const StringName &p_function, int p_idx, List *r_options) const override; +#endif + virtual Ref get_child_by_name(const StringName &p_name) const; Ref find_node_by_path(const String &p_name) const;