diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index f18265ba8d94..4891823e3184 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -33,6 +33,10 @@ #include "core/os/os.h" #include "scene/scene_string_names.h" +#ifdef TOOLS_ENABLED +#include "editor/editor_settings.h" +#endif + #define NORMAL_SUFFIX "_normal" #ifdef TOOLS_ENABLED @@ -651,6 +655,23 @@ String AnimatedSprite::get_configuration_warning() const { return warning; } +void AnimatedSprite::get_argument_options(const StringName &p_function, int p_idx, List *r_options) const { +#ifdef TOOLS_ENABLED + const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\""; +#else + const String quote_style = "\""; +#endif + + if (p_idx == 0 && p_function == "play" && frames.is_valid()) { + List al; + frames->get_animation_list(&al); + for (List::Element *E = al.front(); E; E = E->next()) { + r_options->push_back(quote_style + String(E->get()) + quote_style); + } + } + Node::get_argument_options(p_function, p_idx, r_options); +} + void AnimatedSprite::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite::set_sprite_frames); ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite::get_sprite_frames); diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index 6b838f31106f..81f0a3eccbc3 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -196,6 +196,8 @@ class AnimatedSprite : public Node2D { bool is_flipped_v() const; virtual String get_configuration_warning() const; + virtual void get_argument_options(const StringName &p_function, int p_idx, List *r_options) const; + AnimatedSprite(); }; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 5633f9c4cd6f..9adef13574be 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -32,6 +32,10 @@ #include "core/core_string_names.h" #include "scene/scene_string_names.h" +#ifdef TOOLS_ENABLED +#include "editor/editor_settings.h" +#endif + Color SpriteBase3D::_get_color_accum() { if (!color_dirty) { return color_accum; @@ -1176,6 +1180,23 @@ String AnimatedSprite3D::get_configuration_warning() const { return warning; } +void AnimatedSprite3D::get_argument_options(const StringName &p_function, int p_idx, List *r_options) const { +#ifdef TOOLS_ENABLED + const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\""; +#else + const String quote_style = "\""; +#endif + + if (p_idx == 0 && p_function == "play" && frames.is_valid()) { + List al; + frames->get_animation_list(&al); + for (List::Element *E = al.front(); E; E = E->next()) { + r_options->push_back(quote_style + String(E->get()) + quote_style); + } + } + Node::get_argument_options(p_function, p_idx, r_options); +} + void AnimatedSprite3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite3D::set_sprite_frames); ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite3D::get_sprite_frames); diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 98b5fdb51cbb..9e7230d706e7 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -237,6 +237,8 @@ class AnimatedSprite3D : public SpriteBase3D { virtual Rect2 get_item_rect() const; virtual String get_configuration_warning() const; + virtual void get_argument_options(const StringName &p_function, int p_idx, List *r_options) const; + AnimatedSprite3D(); };