summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicky <micheledevita2@gmail.com>2024-01-03 19:06:54 +0100
committerMicky <micheledevita2@gmail.com>2024-01-03 19:25:28 +0100
commitc2f9a227f7cfd8892c7f37f575a4288e9fce8a29 (patch)
tree0ec6f27b021c33cc466dd551442e74f4d36320c2
parentfbaab3cf537a892295aabdfd02c8052e370e6669 (diff)
downloadredot-engine-c2f9a227f7cfd8892c7f37f575a4288e9fce8a29.tar.gz
Add autocompletion for SpriteFrames' methods
-rw-r--r--scene/resources/sprite_frames.cpp17
-rw-r--r--scene/resources/sprite_frames.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/scene/resources/sprite_frames.cpp b/scene/resources/sprite_frames.cpp
index 17aaf579dd..fc8bff1f25 100644
--- a/scene/resources/sprite_frames.cpp
+++ b/scene/resources/sprite_frames.cpp
@@ -224,6 +224,23 @@ void SpriteFrames::_set_animations(const Array &p_animations) {
}
}
+void SpriteFrames::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 == "has_animation" || pf == "remove_animation" || pf == "rename_animation" ||
+ pf == "set_animation_speed" || pf == "get_animation_speed" ||
+ pf == "set_animation_loop" || pf == "get_animation_loop" ||
+ pf == "add_frame" || pf == "set_frame" || pf == "remove_frame" ||
+ pf == "get_frame_count" || pf == "get_frame_texture" || pf == "get_frame_duration" ||
+ pf == "clear") {
+ for (const String &E : get_animation_names()) {
+ r_options->push_back(E.quote());
+ }
+ }
+ }
+ Resource::get_argument_options(p_function, p_idx, r_options);
+}
+
void SpriteFrames::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_animation", "anim"), &SpriteFrames::add_animation);
ClassDB::bind_method(D_METHOD("has_animation", "anim"), &SpriteFrames::has_animation);
diff --git a/scene/resources/sprite_frames.h b/scene/resources/sprite_frames.h
index 6de2b4a37b..dc980f8321 100644
--- a/scene/resources/sprite_frames.h
+++ b/scene/resources/sprite_frames.h
@@ -103,6 +103,8 @@ public:
void clear(const StringName &p_anim);
void clear_all();
+ virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
+
SpriteFrames();
};