You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
Fix AnimationPlayer finished state in the editor
This commit is contained in:
@@ -80,6 +80,7 @@ void AnimationPlayerEditor::_node_removed(Node *p_node) {
|
|||||||
void AnimationPlayerEditor::_notification(int p_what) {
|
void AnimationPlayerEditor::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_PROCESS: {
|
case NOTIFICATION_PROCESS: {
|
||||||
|
finishing = false;
|
||||||
if (!player || is_dummy) {
|
if (!player || is_dummy) {
|
||||||
track_editor->show_inactive_player_warning(false);
|
track_editor->show_inactive_player_warning(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -1210,6 +1211,9 @@ void AnimationPlayerEditor::edit(AnimationMixer *p_node, AnimationPlayer *p_play
|
|||||||
if (player->is_connected(SNAME("animation_list_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) {
|
if (player->is_connected(SNAME("animation_list_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) {
|
||||||
player->disconnect(SNAME("animation_list_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated));
|
player->disconnect(SNAME("animation_list_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated));
|
||||||
}
|
}
|
||||||
|
if (player->is_connected(SceneStringName(animation_finished), callable_mp(this, &AnimationPlayerEditor::_animation_finished))) {
|
||||||
|
player->disconnect(SceneStringName(animation_finished), callable_mp(this, &AnimationPlayerEditor::_animation_finished));
|
||||||
|
}
|
||||||
if (player->is_connected(SNAME("current_animation_changed"), callable_mp(this, &AnimationPlayerEditor::_current_animation_changed))) {
|
if (player->is_connected(SNAME("current_animation_changed"), callable_mp(this, &AnimationPlayerEditor::_current_animation_changed))) {
|
||||||
player->disconnect(SNAME("current_animation_changed"), callable_mp(this, &AnimationPlayerEditor::_current_animation_changed));
|
player->disconnect(SNAME("current_animation_changed"), callable_mp(this, &AnimationPlayerEditor::_current_animation_changed));
|
||||||
}
|
}
|
||||||
@@ -1237,6 +1241,9 @@ void AnimationPlayerEditor::edit(AnimationMixer *p_node, AnimationPlayer *p_play
|
|||||||
if (!player->is_connected(SNAME("animation_list_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) {
|
if (!player->is_connected(SNAME("animation_list_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated))) {
|
||||||
player->connect(SNAME("animation_list_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated), CONNECT_DEFERRED);
|
player->connect(SNAME("animation_list_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_libraries_updated), CONNECT_DEFERRED);
|
||||||
}
|
}
|
||||||
|
if (!player->is_connected(SceneStringName(animation_finished), callable_mp(this, &AnimationPlayerEditor::_animation_finished))) {
|
||||||
|
player->connect(SceneStringName(animation_finished), callable_mp(this, &AnimationPlayerEditor::_animation_finished));
|
||||||
|
}
|
||||||
if (!player->is_connected(SNAME("current_animation_changed"), callable_mp(this, &AnimationPlayerEditor::_current_animation_changed))) {
|
if (!player->is_connected(SNAME("current_animation_changed"), callable_mp(this, &AnimationPlayerEditor::_current_animation_changed))) {
|
||||||
player->connect(SNAME("current_animation_changed"), callable_mp(this, &AnimationPlayerEditor::_current_animation_changed));
|
player->connect(SNAME("current_animation_changed"), callable_mp(this, &AnimationPlayerEditor::_current_animation_changed));
|
||||||
}
|
}
|
||||||
@@ -1428,9 +1435,16 @@ void AnimationPlayerEditor::_list_changed() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnimationPlayerEditor::_animation_finished(const String &p_name) {
|
||||||
|
finishing = true;
|
||||||
|
}
|
||||||
|
|
||||||
void AnimationPlayerEditor::_current_animation_changed(const String &p_name) {
|
void AnimationPlayerEditor::_current_animation_changed(const String &p_name) {
|
||||||
if (is_visible_in_tree()) {
|
if (is_visible_in_tree()) {
|
||||||
if (p_name.is_empty()) {
|
if (finishing) {
|
||||||
|
finishing = false; // Maybe redundant since it will be false in the AnimationPlayerEditor::_process(), but for safety.
|
||||||
|
return;
|
||||||
|
} else if (p_name.is_empty()) {
|
||||||
// Means [stop].
|
// Means [stop].
|
||||||
frame->set_value(0);
|
frame->set_value(0);
|
||||||
track_editor->set_anim_pos(0);
|
track_editor->set_anim_pos(0);
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ class AnimationPlayerEditor : public VBoxContainer {
|
|||||||
Ref<Texture2D> reset_icon;
|
Ref<Texture2D> reset_icon;
|
||||||
Ref<ImageTexture> autoplay_reset_icon;
|
Ref<ImageTexture> autoplay_reset_icon;
|
||||||
|
|
||||||
|
bool finishing = false;
|
||||||
bool last_active = false;
|
bool last_active = false;
|
||||||
float timeline_position = 0;
|
float timeline_position = 0;
|
||||||
|
|
||||||
@@ -204,6 +205,7 @@ class AnimationPlayerEditor : public VBoxContainer {
|
|||||||
void _update_animation_blend();
|
void _update_animation_blend();
|
||||||
|
|
||||||
void _list_changed();
|
void _list_changed();
|
||||||
|
void _animation_finished(const String &p_name);
|
||||||
void _current_animation_changed(const String &p_name);
|
void _current_animation_changed(const String &p_name);
|
||||||
void _update_animation();
|
void _update_animation();
|
||||||
void _update_player();
|
void _update_player();
|
||||||
|
|||||||
Reference in New Issue
Block a user