@@ -2873,6 +2873,12 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
2873
2873
if (editor->is_selection_active ()) {
2874
2874
menu->add_separator ();
2875
2875
menu->add_icon_item (get_theme_icon (SNAME (" Duplicate" ), SNAME (" EditorIcons" )), TTR (" Duplicate Key(s)" ), MENU_KEY_DUPLICATE);
2876
+
2877
+ AnimationPlayer *player = AnimationPlayerEditor::get_singleton ()->get_player ();
2878
+ if (!player->has_animation (SceneStringNames::get_singleton ()->RESET ) || animation != player->get_animation (SceneStringNames::get_singleton ()->RESET )) {
2879
+ menu->add_icon_item (get_theme_icon (SNAME (" Reload" ), SNAME (" EditorIcons" )), TTR (" Add RESET Value(s)" ), MENU_KEY_ADD_RESET);
2880
+ }
2881
+
2876
2882
menu->add_separator ();
2877
2883
menu->add_icon_item (get_theme_icon (SNAME (" Remove" ), SNAME (" EditorIcons" )), TTR (" Delete Key(s)" ), MENU_KEY_DELETE);
2878
2884
}
@@ -3062,6 +3068,9 @@ void AnimationTrackEdit::_menu_selected(int p_index) {
3062
3068
} break ;
3063
3069
case MENU_KEY_DUPLICATE: {
3064
3070
emit_signal (SNAME (" duplicate_request" ));
3071
+ } break ;
3072
+ case MENU_KEY_ADD_RESET: {
3073
+ emit_signal (SNAME (" create_reset_request" ));
3065
3074
3066
3075
} break ;
3067
3076
case MENU_KEY_DELETE: {
@@ -3124,6 +3133,7 @@ void AnimationTrackEdit::_bind_methods() {
3124
3133
ADD_SIGNAL (MethodInfo (" move_selection_cancel" ));
3125
3134
3126
3135
ADD_SIGNAL (MethodInfo (" duplicate_request" ));
3136
+ ADD_SIGNAL (MethodInfo (" create_reset_request" ));
3127
3137
ADD_SIGNAL (MethodInfo (" duplicate_transpose_request" ));
3128
3138
ADD_SIGNAL (MethodInfo (" delete_request" ));
3129
3139
}
@@ -4389,6 +4399,7 @@ void AnimationTrackEditor::_update_tracks() {
4389
4399
4390
4400
track_edit->connect (" duplicate_request" , callable_mp (this , &AnimationTrackEditor::_edit_menu_pressed), varray (EDIT_DUPLICATE_SELECTION), CONNECT_DEFERRED);
4391
4401
track_edit->connect (" duplicate_transpose_request" , callable_mp (this , &AnimationTrackEditor::_edit_menu_pressed), varray (EDIT_DUPLICATE_TRANSPOSED), CONNECT_DEFERRED);
4402
+ track_edit->connect (" create_reset_request" , callable_mp (this , &AnimationTrackEditor::_edit_menu_pressed), varray (EDIT_ADD_RESET_KEY), CONNECT_DEFERRED);
4392
4403
track_edit->connect (" delete_request" , callable_mp (this , &AnimationTrackEditor::_edit_menu_pressed), varray (EDIT_DELETE_SELECTION), CONNECT_DEFERRED);
4393
4404
}
4394
4405
}
@@ -5721,6 +5732,54 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
5721
5732
}
5722
5733
_anim_duplicate_keys (true );
5723
5734
} break ;
5735
+ case EDIT_ADD_RESET_KEY: {
5736
+ undo_redo->create_action (TTR (" Anim Add RESET Keys" ));
5737
+ Ref<Animation> reset = _create_and_get_reset_animation ();
5738
+ int reset_tracks = reset->get_track_count ();
5739
+ Set<int > tracks_added;
5740
+
5741
+ for (const KeyValue<SelectedKey, KeyInfo> &E : selection) {
5742
+ const SelectedKey &sk = E.key ;
5743
+
5744
+ // Only add one key per track.
5745
+ if (tracks_added.has (sk.track )) {
5746
+ continue ;
5747
+ }
5748
+ tracks_added.insert (sk.track );
5749
+
5750
+ int dst_track = -1 ;
5751
+
5752
+ const NodePath &path = animation->track_get_path (sk.track );
5753
+ for (int i = 0 ; i < reset->get_track_count (); i++) {
5754
+ if (reset->track_get_path (i) == path) {
5755
+ dst_track = i;
5756
+ break ;
5757
+ }
5758
+ }
5759
+
5760
+ if (dst_track == -1 ) {
5761
+ // If adding multiple tracks, make sure that correct track is referenced.
5762
+ dst_track = reset_tracks;
5763
+ reset_tracks++;
5764
+
5765
+ undo_redo->add_do_method (reset.ptr (), " add_track" , animation->track_get_type (sk.track ));
5766
+ undo_redo->add_do_method (reset.ptr (), " track_set_path" , dst_track, path);
5767
+ undo_redo->add_undo_method (reset.ptr (), " remove_track" , dst_track);
5768
+ }
5769
+
5770
+ int existing_idx = reset->track_find_key (dst_track, 0 , true );
5771
+
5772
+ undo_redo->add_do_method (reset.ptr (), " track_insert_key" , dst_track, 0 , animation->track_get_key_value (sk.track , sk.key ), animation->track_get_key_transition (sk.track , sk.key ));
5773
+ undo_redo->add_undo_method (reset.ptr (), " track_remove_key_at_time" , dst_track, 0 );
5774
+
5775
+ if (existing_idx != -1 ) {
5776
+ undo_redo->add_undo_method (reset.ptr (), " track_insert_key" , dst_track, 0 , reset->track_get_key_value (dst_track, existing_idx), reset->track_get_key_transition (dst_track, existing_idx));
5777
+ }
5778
+ }
5779
+
5780
+ undo_redo->commit_action ();
5781
+
5782
+ } break ;
5724
5783
case EDIT_DELETE_SELECTION: {
5725
5784
if (bezier_edit->is_visible ()) {
5726
5785
bezier_edit->delete_selection ();
@@ -6145,6 +6204,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
6145
6204
edit->get_popup ()->add_separator ();
6146
6205
edit->get_popup ()->add_shortcut (ED_SHORTCUT (" animation_editor/duplicate_selection" , TTR (" Duplicate Selection" ), KeyModifierMask::CMD | Key::D), EDIT_DUPLICATE_SELECTION);
6147
6206
edit->get_popup ()->add_shortcut (ED_SHORTCUT (" animation_editor/duplicate_selection_transposed" , TTR (" Duplicate Transposed" ), KeyModifierMask::SHIFT | KeyModifierMask::CMD | Key::D), EDIT_DUPLICATE_TRANSPOSED);
6207
+ edit->get_popup ()->add_shortcut (ED_SHORTCUT (" animation_editor/add_reset_value" , TTR (" Add RESET Value(s)" )));
6148
6208
edit->get_popup ()->add_separator ();
6149
6209
edit->get_popup ()->add_shortcut (ED_SHORTCUT (" animation_editor/delete_selection" , TTR (" Delete Selection" ), Key::KEY_DELETE), EDIT_DELETE_SELECTION);
6150
6210
0 commit comments