From a389eb4608d87ea071916b52b40bd28aa542e9ae Mon Sep 17 00:00:00 2001 From: HolonProduction Date: Fri, 15 Nov 2024 13:06:59 +0100 Subject: [PATCH] Add back `AnimationPlayer.get_argument_options` --- .../argument_options/argument_options.tscn | 13 +++++++++++++ .../completion/argument_options/play_inferred.cfg | 6 ++++++ .../completion/argument_options/play_inferred.gd | 5 +++++ .../completion/argument_options/play_typed.cfg | 6 ++++++ .../completion/argument_options/play_typed.gd | 5 +++++ .../completion/argument_options/play_untyped.cfg | 6 ++++++ .../completion/argument_options/play_untyped.gd | 5 +++++ scene/animation/animation_player.cpp | 14 ++++++++++++++ scene/animation/animation_player.h | 4 ++++ 9 files changed, 64 insertions(+) create mode 100644 modules/gdscript/tests/scripts/completion/argument_options/play_inferred.cfg create mode 100644 modules/gdscript/tests/scripts/completion/argument_options/play_inferred.gd create mode 100644 modules/gdscript/tests/scripts/completion/argument_options/play_typed.cfg create mode 100644 modules/gdscript/tests/scripts/completion/argument_options/play_typed.gd create mode 100644 modules/gdscript/tests/scripts/completion/argument_options/play_untyped.cfg create mode 100644 modules/gdscript/tests/scripts/completion/argument_options/play_untyped.gd diff --git a/modules/gdscript/tests/scripts/completion/argument_options/argument_options.tscn b/modules/gdscript/tests/scripts/completion/argument_options/argument_options.tscn index d3dea6b12b4..082c87e708f 100644 --- a/modules/gdscript/tests/scripts/completion/argument_options/argument_options.tscn +++ b/modules/gdscript/tests/scripts/completion/argument_options/argument_options.tscn @@ -1,3 +1,16 @@ [gd_scene load_steps=1 format=3 uid="uid://dl28pdkxcjvym"] +[sub_resource type="Animation" id="Animation_d1pub"] +resource_name = "bounce" + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_gs7mj"] +_data = { +"bounce": SubResource("Animation_d1pub") +} + [node name="GetNode" type="Node"] + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_gs7mj") +} diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.cfg b/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.cfg new file mode 100644 index 00000000000..ca108a18c23 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.cfg @@ -0,0 +1,6 @@ +[input] +scene="res://completion/argument_options/argument_options.tscn" +[output] +include=[ + {"display": "\"bounce\""}, +] diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.gd b/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.gd new file mode 100644 index 00000000000..abeadbe5eed --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_inferred.gd @@ -0,0 +1,5 @@ +@onready var anim := $AnimationPlayer + +func test(): + anim.play(➡) + pass diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_typed.cfg b/modules/gdscript/tests/scripts/completion/argument_options/play_typed.cfg new file mode 100644 index 00000000000..ca108a18c23 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_typed.cfg @@ -0,0 +1,6 @@ +[input] +scene="res://completion/argument_options/argument_options.tscn" +[output] +include=[ + {"display": "\"bounce\""}, +] diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_typed.gd b/modules/gdscript/tests/scripts/completion/argument_options/play_typed.gd new file mode 100644 index 00000000000..d11f81e9853 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_typed.gd @@ -0,0 +1,5 @@ +@onready var anim: AnimationPlayer = $AnimationPlayer + +func test(): + anim.play(➡) + pass diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.cfg b/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.cfg new file mode 100644 index 00000000000..ca108a18c23 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.cfg @@ -0,0 +1,6 @@ +[input] +scene="res://completion/argument_options/argument_options.tscn" +[output] +include=[ + {"display": "\"bounce\""}, +] diff --git a/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.gd b/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.gd new file mode 100644 index 00000000000..4ddfd21ac60 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/argument_options/play_untyped.gd @@ -0,0 +1,5 @@ +@onready var anim = $AnimationPlayer + +func test(): + anim.play(➡) + pass diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index b3a75a75a04..7d28aead6ee 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -876,6 +876,20 @@ Tween::EaseType AnimationPlayer::get_auto_capture_ease_type() const { return auto_capture_ease_type; } +#ifdef TOOLS_ENABLED +void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List *r_options) const { + const String pf = p_function; + if (p_idx == 0 && (pf == "play" || pf == "play_backwards" || pf == "has_animation" || pf == "queue")) { + List al; + get_animation_list(&al); + for (const StringName &name : al) { + r_options->push_back(String(name).quote()); + } + } + AnimationMixer::get_argument_options(p_function, p_idx, r_options); +} +#endif + void AnimationPlayer::_animation_removed(const StringName &p_name, const StringName &p_library) { AnimationMixer::_animation_removed(p_name, p_library); diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 06b3eecb894..6d7e8aa9969 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -178,6 +178,10 @@ public: void set_auto_capture_ease_type(Tween::EaseType p_auto_capture_ease_type); Tween::EaseType get_auto_capture_ease_type() const; +#ifdef TOOLS_ENABLED + void get_argument_options(const StringName &p_function, int p_idx, List *r_options) const override; +#endif + void play(const StringName &p_name = StringName(), double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false); void play_section_with_markers(const StringName &p_name = StringName(), const StringName &p_start_marker = StringName(), const StringName &p_end_marker = StringName(), double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false); void play_section(const StringName &p_name = StringName(), double p_start_time = -1, double p_end_time = -1, double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false);