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 for AnimationLibrary & AnimationMixer's methods #86799

Merged
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
20 changes: 20 additions & 0 deletions scene/animation/animation_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,26 @@ void AnimationMixer::_notification(int p_what) {
}
}

void AnimationMixer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
String pf = p_function;
if (p_idx == 0) {
if (pf == "get_animation" || pf == "has_animation") {
List<StringName> al;
get_animation_list(&al);
for (const StringName &name : al) {
r_options->push_back(String(name).quote());
}
} else if (pf == "get_animation_library" || pf == "has_animation_library" || pf == "remove_animation_library" || pf == "rename_animation_library") {
List<StringName> al;
get_animation_library_list(&al);
for (const StringName &name : al) {
r_options->push_back(String(name).quote());
}
}
}
Node::get_argument_options(p_function, p_idx, r_options);
}

void AnimationMixer::_bind_methods() {
/* ---- Data lists ---- */
ClassDB::bind_method(D_METHOD("add_animation_library", "name", "library"), &AnimationMixer::add_animation_library);
Expand Down
1 change: 1 addition & 0 deletions scene/animation/animation_mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ class AnimationMixer : public Node {
void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
virtual void _validate_property(PropertyInfo &p_property) const;
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;

static void _bind_methods();
void _node_removed(Node *p_node);
Expand Down
12 changes: 12 additions & 0 deletions scene/resources/animation_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ Dictionary AnimationLibrary::_get_data() const {
return ret;
}

void AnimationLibrary::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
String pf = p_function;
if (p_idx == 0 && (pf == "get_animation" || pf == "has_animation" || pf == "rename_animation" || pf == "remove_animation")) {
List<StringName> names;
get_animation_list(&names);
for (const StringName &E : names) {
r_options->push_back(E.operator String().quote());
}
}
Resource::get_argument_options(p_function, p_idx, r_options);
}

void AnimationLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_animation", "name", "animation"), &AnimationLibrary::add_animation);
ClassDB::bind_method(D_METHOD("remove_animation", "name"), &AnimationLibrary::remove_animation);
Expand Down
2 changes: 2 additions & 0 deletions scene/resources/animation_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class AnimationLibrary : public Resource {
Ref<Animation> get_animation(const StringName &p_name) const;
void get_animation_list(List<StringName> *p_animations) const;

virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;

AnimationLibrary();
};

Expand Down
Loading