Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocompletion to AnimationNode #86888

Merged
1 commit merged into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scene/animation/animation_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> *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") {
Mickeon marked this conversation as resolved.
Show resolved Hide resolved
bool is_setter = pf == "set_parameter";
List<PropertyInfo> parameters;
get_parameter_list(&parameters);
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<NodePath, bool> &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);
Expand Down
4 changes: 4 additions & 0 deletions scene/animation/animation_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> *r_options) const override;
#endif

virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) const;
Ref<AnimationNode> find_node_by_path(const String &p_name) const;

Expand Down
Loading