Skip to content

Commit 2eaeee5

Browse files
committed
Fix animation player controls being enabled when no player is selected
1 parent be56cab commit 2eaeee5

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

editor/plugins/animation_player_editor_plugin.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ void AnimationPlayerEditor::_update_player() {
881881

882882
tool_anim->set_disabled(player == nullptr);
883883
pin->set_disabled(player == nullptr);
884+
_set_controls_disabled(player == nullptr);
884885

885886
if (!player) {
886887
AnimationPlayerEditor::get_singleton()->get_track_editor()->update_keying();
@@ -931,17 +932,6 @@ void AnimationPlayerEditor::_update_player() {
931932
ITEM_CHECK_DISABLED(TOOL_NEW_ANIM);
932933
#undef ITEM_CHECK_DISABLED
933934

934-
stop->set_disabled(no_anims_found);
935-
play->set_disabled(no_anims_found);
936-
play_bw->set_disabled(no_anims_found);
937-
play_bw_from->set_disabled(no_anims_found);
938-
play_from->set_disabled(no_anims_found);
939-
frame->set_editable(!no_anims_found);
940-
animation->set_disabled(no_anims_found);
941-
autoplay->set_disabled(no_anims_found);
942-
onion_toggle->set_disabled(no_anims_found);
943-
onion_skinning->set_disabled(no_anims_found);
944-
945935
_update_animation_list_icons();
946936

947937
updating = false;
@@ -958,7 +948,9 @@ void AnimationPlayerEditor::_update_player() {
958948
_animation_selected(0);
959949
}
960950

961-
if (!no_anims_found) {
951+
if (no_anims_found) {
952+
_set_controls_disabled(true);
953+
} else {
962954
String current = animation->get_item_text(animation->get_selected());
963955
Ref<Animation> anim = player->get_animation(current);
964956

@@ -974,6 +966,20 @@ void AnimationPlayerEditor::_update_player() {
974966
_update_animation();
975967
}
976968

969+
void AnimationPlayerEditor::_set_controls_disabled(bool p_disabled) {
970+
frame->set_editable(!p_disabled);
971+
972+
stop->set_disabled(p_disabled);
973+
play->set_disabled(p_disabled);
974+
play_bw->set_disabled(p_disabled);
975+
play_bw_from->set_disabled(p_disabled);
976+
play_from->set_disabled(p_disabled);
977+
animation->set_disabled(p_disabled);
978+
autoplay->set_disabled(p_disabled);
979+
onion_toggle->set_disabled(p_disabled);
980+
onion_skinning->set_disabled(p_disabled);
981+
}
982+
977983
void AnimationPlayerEditor::_update_animation_list_icons() {
978984
for (int i = 0; i < animation->get_item_count(); i++) {
979985
String anim_name = animation->get_item_text(i);
@@ -1076,9 +1082,6 @@ void AnimationPlayerEditor::_ensure_dummy_player() {
10761082
}
10771083
}
10781084

1079-
// Make some options disabled.
1080-
onion_toggle->set_disabled(dummy_exists);
1081-
onion_skinning->set_disabled(dummy_exists);
10821085
int selected = animation->get_selected();
10831086
autoplay->set_disabled(selected != -1 ? (animation->get_item_text(selected).is_empty() ? true : dummy_exists) : true);
10841087

editor/plugins/animation_player_editor_plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ class AnimationPlayerEditor : public VBoxContainer {
206206
void _current_animation_changed(const String &p_name);
207207
void _update_animation();
208208
void _update_player();
209+
void _set_controls_disabled(bool p_disabled);
209210
void _update_animation_list_icons();
210211
void _update_name_dialog_library_dropdown();
211212
void _blend_edited();

0 commit comments

Comments
 (0)