Skip to content

Commit e988c1a

Browse files
committed
Merge pull request #92870 from KoBeWi/maybe_RESET_a_bit_less
Don't allow creating invalid RESET keys
2 parents fe61f94 + 461bb8e commit e988c1a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

editor/animation_track_editor.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2934,7 +2934,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
29342934
}
29352935
if (selected || editor->is_selection_active()) {
29362936
AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player();
2937-
if (!player->has_animation(SceneStringName(RESET)) || animation != player->get_animation(SceneStringName(RESET))) {
2937+
if ((!player->has_animation(SceneStringName(RESET)) || animation != player->get_animation(SceneStringName(RESET))) && editor->can_add_reset_key()) {
29382938
menu->add_icon_item(get_editor_theme_icon(SNAME("Reload")), TTR("Add RESET Value(s)"), MENU_KEY_ADD_RESET);
29392939
}
29402940

@@ -4529,6 +4529,16 @@ bool AnimationTrackEditor::is_snap_enabled() const {
45294529
return snap->is_pressed() ^ Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL);
45304530
}
45314531

4532+
bool AnimationTrackEditor::can_add_reset_key() const {
4533+
for (const KeyValue<SelectedKey, KeyInfo> &E : selection) {
4534+
const Animation::TrackType track_type = animation->track_get_type(E.key.track);
4535+
if (track_type != Animation::TYPE_ANIMATION && track_type != Animation::TYPE_AUDIO && track_type != Animation::TYPE_METHOD) {
4536+
return true;
4537+
}
4538+
}
4539+
return false;
4540+
}
4541+
45324542
void AnimationTrackEditor::_update_tracks() {
45334543
int selected = _get_track_selected();
45344544

@@ -6621,6 +6631,11 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
66216631
for (const KeyValue<SelectedKey, KeyInfo> &E : selection) {
66226632
const SelectedKey &sk = E.key;
66236633

6634+
const Animation::TrackType track_type = animation->track_get_type(E.key.track);
6635+
if (track_type == Animation::TYPE_ANIMATION || track_type == Animation::TYPE_AUDIO || track_type == Animation::TYPE_METHOD) {
6636+
continue;
6637+
}
6638+
66246639
// Only add one key per track.
66256640
if (tracks_added.has(sk.track)) {
66266641
continue;

editor/animation_track_editor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ class AnimationTrackEditor : public VBoxContainer {
727727
bool is_key_clipboard_active() const;
728728
bool is_moving_selection() const;
729729
bool is_snap_enabled() const;
730+
bool can_add_reset_key() const;
730731
float get_moving_selection_offset() const;
731732
float snap_time(float p_value, bool p_relative = false);
732733
bool is_grouping_tracks();

0 commit comments

Comments
 (0)