Skip to content

Commit 461bb8e

Browse files
committed
Don't allow creating invalid RESET keys
1 parent e96ad5a commit 461bb8e

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
@@ -2931,7 +2931,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
29312931
}
29322932
if (selected || editor->is_selection_active()) {
29332933
AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player();
2934-
if (!player->has_animation(SceneStringName(RESET)) || animation != player->get_animation(SceneStringName(RESET))) {
2934+
if ((!player->has_animation(SceneStringName(RESET)) || animation != player->get_animation(SceneStringName(RESET))) && editor->can_add_reset_key()) {
29352935
menu->add_icon_item(get_editor_theme_icon(SNAME("Reload")), TTR("Add RESET Value(s)"), MENU_KEY_ADD_RESET);
29362936
}
29372937

@@ -4526,6 +4526,16 @@ bool AnimationTrackEditor::is_snap_enabled() const {
45264526
return snap->is_pressed() ^ Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL);
45274527
}
45284528

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

@@ -6611,6 +6621,11 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
66116621
for (const KeyValue<SelectedKey, KeyInfo> &E : selection) {
66126622
const SelectedKey &sk = E.key;
66136623

6624+
const Animation::TrackType track_type = animation->track_get_type(E.key.track);
6625+
if (track_type == Animation::TYPE_ANIMATION || track_type == Animation::TYPE_AUDIO || track_type == Animation::TYPE_METHOD) {
6626+
continue;
6627+
}
6628+
66146629
// Only add one key per track.
66156630
if (tracks_added.has(sk.track)) {
66166631
continue;

editor/animation_track_editor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ class AnimationTrackEditor : public VBoxContainer {
724724
bool is_key_clipboard_active() const;
725725
bool is_moving_selection() const;
726726
bool is_snap_enabled() const;
727+
bool can_add_reset_key() const;
727728
float get_moving_selection_offset() const;
728729
float snap_time(float p_value, bool p_relative = false);
729730
bool is_grouping_tracks();

0 commit comments

Comments
 (0)