mirror of
https://github.com/godotengine/godot.git
synced 2025-10-15 02:49:24 +00:00
Merge pull request #110767 from Ryan-000/Fix-AnimationPlayer-to-use-StringName
Fix AnimationPlayer to use StringName instead of String in the exposed API.
This commit is contained in:
@@ -58,6 +58,38 @@ void AnimationPlayer::_seek_bind_compat_80813(double p_time, bool p_update) {
|
||||
seek(p_time, p_update, false);
|
||||
}
|
||||
|
||||
Vector<String> AnimationPlayer::_get_queue_compat_110767() {
|
||||
Vector<String> queue;
|
||||
for (const Variant &E : get_queue()) {
|
||||
queue.push_back(E);
|
||||
}
|
||||
return queue;
|
||||
}
|
||||
|
||||
String AnimationPlayer::_get_current_animation_compat_110767() const {
|
||||
return get_current_animation();
|
||||
}
|
||||
|
||||
void AnimationPlayer::_set_current_animation_compat_110767(const String &p_animation) {
|
||||
set_current_animation(p_animation);
|
||||
}
|
||||
|
||||
String AnimationPlayer::_get_assigned_animation_compat_110767() const {
|
||||
return get_assigned_animation();
|
||||
}
|
||||
|
||||
void AnimationPlayer::_set_assigned_animation_compat_110767(const String &p_animation) {
|
||||
set_assigned_animation(p_animation);
|
||||
}
|
||||
|
||||
String AnimationPlayer::_get_autoplay_compat_110767() const {
|
||||
return get_autoplay();
|
||||
}
|
||||
|
||||
void AnimationPlayer::_set_autoplay_compat_110767(const String &p_name) {
|
||||
set_autoplay(p_name);
|
||||
}
|
||||
|
||||
void AnimationPlayer::_bind_compatibility_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_process_callback", "mode"), &AnimationPlayer::_set_process_callback_bind_compat_80813);
|
||||
ClassDB::bind_method(D_METHOD("get_process_callback"), &AnimationPlayer::_get_process_callback_bind_compat_80813);
|
||||
@@ -65,6 +97,15 @@ void AnimationPlayer::_bind_compatibility_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_method_call_mode"), &AnimationPlayer::_get_method_call_mode_bind_compat_80813);
|
||||
ClassDB::bind_method(D_METHOD("set_root", "path"), &AnimationPlayer::_set_root_bind_compat_80813);
|
||||
ClassDB::bind_method(D_METHOD("get_root"), &AnimationPlayer::_get_root_bind_compat_80813);
|
||||
|
||||
ClassDB::bind_compatibility_method(D_METHOD("get_queue"), &AnimationPlayer::_get_queue_compat_110767);
|
||||
ClassDB::bind_compatibility_method(D_METHOD("get_current_animation"), &AnimationPlayer::_get_current_animation_compat_110767);
|
||||
ClassDB::bind_compatibility_method(D_METHOD("set_current_animation", "animation"), &AnimationPlayer::_set_current_animation_compat_110767);
|
||||
ClassDB::bind_compatibility_method(D_METHOD("get_assigned_animation"), &AnimationPlayer::_get_assigned_animation_compat_110767);
|
||||
ClassDB::bind_compatibility_method(D_METHOD("set_assigned_animation", "animation"), &AnimationPlayer::_set_assigned_animation_compat_110767);
|
||||
ClassDB::bind_compatibility_method(D_METHOD("get_autoplay"), &AnimationPlayer::_get_autoplay_compat_110767);
|
||||
ClassDB::bind_compatibility_method(D_METHOD("set_autoplay", "name"), &AnimationPlayer::_set_autoplay_compat_110767);
|
||||
|
||||
ClassDB::bind_compatibility_method(D_METHOD("seek", "seconds", "update"), &AnimationPlayer::_seek_bind_compat_80813, DEFVAL(false));
|
||||
BIND_ENUM_CONSTANT(ANIMATION_PROCESS_PHYSICS);
|
||||
BIND_ENUM_CONSTANT(ANIMATION_PROCESS_IDLE);
|
||||
|
@@ -365,8 +365,8 @@ void AnimationPlayer::queue(const StringName &p_name) {
|
||||
}
|
||||
}
|
||||
|
||||
Vector<String> AnimationPlayer::get_queue() {
|
||||
Vector<String> ret;
|
||||
TypedArray<StringName> AnimationPlayer::get_queue() {
|
||||
TypedArray<StringName> ret;
|
||||
for (const StringName &E : playback_queue) {
|
||||
ret.push_back(E);
|
||||
}
|
||||
@@ -579,8 +579,8 @@ bool AnimationPlayer::is_playing() const {
|
||||
return playing;
|
||||
}
|
||||
|
||||
void AnimationPlayer::set_current_animation(const String &p_animation) {
|
||||
if (p_animation == "[stop]" || p_animation.is_empty()) {
|
||||
void AnimationPlayer::set_current_animation(const StringName &p_animation) {
|
||||
if (p_animation == SNAME("[stop]") || p_animation.is_empty()) {
|
||||
stop();
|
||||
} else if (!is_playing()) {
|
||||
play(p_animation);
|
||||
@@ -592,16 +592,16 @@ void AnimationPlayer::set_current_animation(const String &p_animation) {
|
||||
}
|
||||
}
|
||||
|
||||
String AnimationPlayer::get_current_animation() const {
|
||||
return (is_playing() ? playback.assigned : "");
|
||||
StringName AnimationPlayer::get_current_animation() const {
|
||||
return (is_playing() ? playback.assigned : StringName());
|
||||
}
|
||||
|
||||
void AnimationPlayer::set_assigned_animation(const String &p_animation) {
|
||||
void AnimationPlayer::set_assigned_animation(const StringName &p_animation) {
|
||||
if (is_playing()) {
|
||||
float speed = playback.current.speed_scale;
|
||||
play(p_animation, -1.0, speed, std::signbit(speed));
|
||||
} else {
|
||||
ERR_FAIL_COND_MSG(!animation_set.has(p_animation), vformat("Animation not found: %s.", p_animation));
|
||||
ERR_FAIL_COND_MSG(!animation_set.has(p_animation), vformat("Animation not found: %s.", p_animation.operator String()));
|
||||
playback.current.pos = 0;
|
||||
playback.current.from = &animation_set[p_animation];
|
||||
playback.current.start_time = -1;
|
||||
@@ -611,7 +611,7 @@ void AnimationPlayer::set_assigned_animation(const String &p_animation) {
|
||||
}
|
||||
}
|
||||
|
||||
String AnimationPlayer::get_assigned_animation() const {
|
||||
StringName AnimationPlayer::get_assigned_animation() const {
|
||||
return playback.assigned;
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ bool AnimationPlayer::has_section() const {
|
||||
return Animation::is_greater_or_equal_approx(playback.current.start_time, 0) || Animation::is_greater_or_equal_approx(playback.current.end_time, 0);
|
||||
}
|
||||
|
||||
void AnimationPlayer::set_autoplay(const String &p_name) {
|
||||
void AnimationPlayer::set_autoplay(const StringName &p_name) {
|
||||
if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
|
||||
WARN_PRINT("Setting autoplay after the node has been added to the scene has no effect.");
|
||||
}
|
||||
@@ -753,7 +753,7 @@ void AnimationPlayer::set_autoplay(const String &p_name) {
|
||||
autoplay = p_name;
|
||||
}
|
||||
|
||||
String AnimationPlayer::get_autoplay() const {
|
||||
StringName AnimationPlayer::get_autoplay() const {
|
||||
return autoplay;
|
||||
}
|
||||
|
||||
@@ -1029,7 +1029,7 @@ void AnimationPlayer::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "speed_scale", PROPERTY_HINT_RANGE, "-4,4,0.001,or_less,or_greater"), "set_speed_scale", "get_speed_scale");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "movie_quit_on_finish"), "set_movie_quit_on_finish_enabled", "is_movie_quit_on_finish_enabled");
|
||||
|
||||
ADD_SIGNAL(MethodInfo(SNAME("current_animation_changed"), PropertyInfo(Variant::STRING, "name")));
|
||||
ADD_SIGNAL(MethodInfo(SNAME("current_animation_changed"), PropertyInfo(Variant::STRING_NAME, "name")));
|
||||
ADD_SIGNAL(MethodInfo(SNAME("animation_changed"), PropertyInfo(Variant::STRING_NAME, "old_name"), PropertyInfo(Variant::STRING_NAME, "new_name")));
|
||||
}
|
||||
|
||||
|
@@ -166,6 +166,14 @@ protected:
|
||||
void _play_compat_84906(const StringName &p_name = StringName(), double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false);
|
||||
void _play_backwards_compat_84906(const StringName &p_name = StringName(), double p_custom_blend = -1);
|
||||
|
||||
Vector<String> _get_queue_compat_110767();
|
||||
String _get_current_animation_compat_110767() const;
|
||||
void _set_current_animation_compat_110767(const String &p_animation);
|
||||
String _get_assigned_animation_compat_110767() const;
|
||||
void _set_assigned_animation_compat_110767(const String &p_animation);
|
||||
String _get_autoplay_compat_110767() const;
|
||||
void _set_autoplay_compat_110767(const String &p_name);
|
||||
|
||||
static void _bind_compatibility_methods();
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
@@ -200,23 +208,23 @@ public:
|
||||
void play_section_backwards(const StringName &p_name = StringName(), double p_start_time = -1, double p_end_time = -1, double p_custom_blend = -1);
|
||||
void play_with_capture(const StringName &p_name = StringName(), double p_duration = -1.0, double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false, Tween::TransitionType p_trans_type = Tween::TRANS_LINEAR, Tween::EaseType p_ease_type = Tween::EASE_IN);
|
||||
void queue(const StringName &p_name);
|
||||
Vector<String> get_queue();
|
||||
TypedArray<StringName> get_queue();
|
||||
void clear_queue();
|
||||
void pause();
|
||||
void stop(bool p_keep_state = false);
|
||||
bool is_playing() const;
|
||||
String get_current_animation() const;
|
||||
void set_current_animation(const String &p_animation);
|
||||
String get_assigned_animation() const;
|
||||
void set_assigned_animation(const String &p_animation);
|
||||
StringName get_current_animation() const;
|
||||
void set_current_animation(const StringName &p_animation);
|
||||
StringName get_assigned_animation() const;
|
||||
void set_assigned_animation(const StringName &p_animation);
|
||||
bool is_valid() const;
|
||||
|
||||
void set_speed_scale(float p_speed);
|
||||
float get_speed_scale() const;
|
||||
float get_playing_speed() const;
|
||||
|
||||
void set_autoplay(const String &p_name);
|
||||
String get_autoplay() const;
|
||||
void set_autoplay(const StringName &p_name);
|
||||
StringName get_autoplay() const;
|
||||
|
||||
void set_movie_quit_on_finish_enabled(bool p_enabled);
|
||||
bool is_movie_quit_on_finish_enabled() const;
|
||||
|
Reference in New Issue
Block a user