From 312ec612c78a9d3b5af046332c0bbc54dbca7040 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 4 May 2022 20:56:20 +0800 Subject: Add autocompletion for AnimatedSprite.play() --- scene/2d/animated_sprite_2d.cpp | 11 +++++++++++ scene/2d/animated_sprite_2d.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'scene/2d') diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index d3783aadd1..4734f97e23 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -443,6 +443,17 @@ TypedArray AnimatedSprite2D::get_configuration_warnings() const { return warnings; } +void AnimatedSprite2D::get_argument_options(const StringName &p_function, int p_idx, List *r_options) const { + if (p_idx == 0 && p_function == "play" && frames.is_valid()) { + List al; + frames->get_animation_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 AnimatedSprite2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite2D::set_sprite_frames); ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite2D::get_sprite_frames); diff --git a/scene/2d/animated_sprite_2d.h b/scene/2d/animated_sprite_2d.h index b3af931ea2..3a41f810dc 100644 --- a/scene/2d/animated_sprite_2d.h +++ b/scene/2d/animated_sprite_2d.h @@ -109,6 +109,8 @@ public: bool is_flipped_v() const; TypedArray get_configuration_warnings() const override; + virtual void get_argument_options(const StringName &p_function, int p_idx, List *r_options) const override; + AnimatedSprite2D(); }; -- cgit v1.2.3