diff options
Diffstat (limited to 'editor/animation_track_editor.cpp')
-rw-r--r-- | editor/animation_track_editor.cpp | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 8305baf0a1..9587a84e18 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -133,6 +133,7 @@ public: int existing = animation->track_find_key(track, new_time, true); setting = true; + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Anim Change Keyframe Time"), UndoRedo::MERGE_ENDS); Variant val = animation->track_get_key_value(track, key); @@ -160,6 +161,7 @@ public: float val = p_value; float prev_val = animation->track_get_key_transition(track, key); setting = true; + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Anim Change Transition"), UndoRedo::MERGE_ENDS); undo_redo->add_do_method(animation.ptr(), "track_set_key_transition", track, key, val); undo_redo->add_undo_method(animation.ptr(), "track_set_key_transition", track, key, prev_val); @@ -171,6 +173,7 @@ public: return true; } + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); switch (animation->track_get_type(track)) { case Animation::TYPE_POSITION_3D: case Animation::TYPE_ROTATION_3D: @@ -685,7 +688,6 @@ public: } } - Ref<EditorUndoRedoManager> undo_redo; Ref<Animation> animation; int track = -1; float key_ofs = 0; @@ -810,6 +812,7 @@ public: int existing = animation->track_find_key(track, new_time, true); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); if (!setting) { setting = true; undo_redo->create_action(TTR("Anim Multi Change Keyframe Time"), UndoRedo::MERGE_ENDS); @@ -834,6 +837,7 @@ public: float val = p_value; float prev_val = animation->track_get_key_transition(track, key); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); if (!setting) { setting = true; undo_redo->create_action(TTR("Anim Multi Change Transition"), UndoRedo::MERGE_ENDS); @@ -843,6 +847,7 @@ public: update_obj = true; } + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); switch (animation->track_get_type(track)) { case Animation::TYPE_POSITION_3D: case Animation::TYPE_ROTATION_3D: @@ -1053,6 +1058,7 @@ public: } } + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); if (setting) { if (update_obj) { undo_redo->add_do_method(this, "_update_obj", animation); @@ -1376,8 +1382,6 @@ public: bool use_fps = false; - Ref<EditorUndoRedoManager> undo_redo; - void notify_change() { notify_property_list_changed(); } @@ -1419,6 +1423,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { } editing = true; + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Change Animation Length")); undo_redo->add_do_method(animation.ptr(), "set_length", p_new_len); undo_redo->add_undo_method(animation.ptr(), "set_length", animation->get_length()); @@ -1431,6 +1436,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { void AnimationTimelineEdit::_anim_loop_pressed() { if (!read_only) { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Change Animation Loop")); switch (animation->get_loop_mode()) { case Animation::LOOP_NONE: { @@ -1712,10 +1718,6 @@ Size2 AnimationTimelineEdit::get_minimum_size() const { return ms; } -void AnimationTimelineEdit::set_undo_redo(Ref<EditorUndoRedoManager> p_undo_redo) { - undo_redo = p_undo_redo; -} - void AnimationTimelineEdit::set_zoom(Range *p_zoom) { zoom = p_zoom; zoom->connect("value_changed", callable_mp(this, &AnimationTimelineEdit::_zoom_changed)); @@ -2514,14 +2516,6 @@ Size2 AnimationTrackEdit::get_minimum_size() const { return Vector2(1, max_h + separation); } -void AnimationTrackEdit::set_undo_redo(Ref<EditorUndoRedoManager> p_undo_redo) { - undo_redo = p_undo_redo; -} - -Ref<EditorUndoRedoManager> AnimationTrackEdit::get_undo_redo() const { - return undo_redo; -} - void AnimationTrackEdit::set_timeline(AnimationTimelineEdit *p_timeline) { timeline = p_timeline; timeline->set_track_edit(this); @@ -2568,6 +2562,7 @@ void AnimationTrackEdit::_zoom_changed() { } void AnimationTrackEdit::_path_submitted(const String &p_text) { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Change Track Path")); undo_redo->add_do_method(animation.ptr(), "track_set_path", track, p_text); undo_redo->add_undo_method(animation.ptr(), "track_set_path", track, animation->track_get_path(track)); @@ -2805,6 +2800,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { if (!read_only) { if (check_rect.has_point(pos)) { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Toggle Track Enabled")); undo_redo->add_do_method(animation.ptr(), "track_set_enabled", track, !animation->track_is_enabled(track)); undo_redo->add_undo_method(animation.ptr(), "track_set_enabled", track, animation->track_is_enabled(track)); @@ -3196,6 +3192,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { case MENU_CALL_MODE_TRIGGER: case MENU_CALL_MODE_CAPTURE: { Animation::UpdateMode update_mode = Animation::UpdateMode(p_index); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Change Animation Update Mode")); undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", track, update_mode); undo_redo->add_undo_method(animation.ptr(), "value_track_set_update_mode", track, animation->value_track_get_update_mode(track)); @@ -3209,6 +3206,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { case MENU_INTERPOLATION_LINEAR_ANGLE: case MENU_INTERPOLATION_CUBIC_ANGLE: { Animation::InterpolationType interp_mode = Animation::InterpolationType(p_index - MENU_INTERPOLATION_NEAREST); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Change Animation Interpolation Mode")); undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", track, interp_mode); undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_type", track, animation->track_get_interpolation_type(track)); @@ -3218,6 +3216,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { case MENU_LOOP_WRAP: case MENU_LOOP_CLAMP: { bool loop_wrap = p_index == MENU_LOOP_WRAP; + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Change Animation Loop Mode")); undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, loop_wrap); undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, animation->track_get_interpolation_loop_wrap(track)); @@ -3611,6 +3610,7 @@ void AnimationTrackEditor::_animation_track_remove_request(int p_track, Ref<Anim } int idx = p_track; if (idx >= 0 && idx < p_from_animation->get_track_count()) { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Remove Anim Track"), UndoRedo::MERGE_DISABLE, p_from_animation.ptr()); // Remove corresponding reset tracks if they are no longer needed. @@ -3811,6 +3811,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } void AnimationTrackEditor::_insert_track(bool p_reset_wanted, bool p_create_beziers) { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Anim Insert")); Ref<Animation> reset_anim; @@ -4141,6 +4142,7 @@ Ref<Animation> AnimationTrackEditor::_create_and_get_reset_animation() { Ref<Animation> reset_anim; reset_anim.instantiate(); reset_anim->set_length(ANIM_MIN_LENGTH); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->add_do_method(al.ptr(), "add_animation", SceneStringNames::get_singleton()->RESET, reset_anim); undo_redo->add_do_method(AnimationPlayerEditor::get_singleton(), "_animation_player_changed", player); undo_redo->add_undo_method(al.ptr(), "remove_animation", SceneStringNames::get_singleton()->RESET); @@ -4150,6 +4152,7 @@ Ref<Animation> AnimationTrackEditor::_create_and_get_reset_animation() { } void AnimationTrackEditor::_confirm_insert_list() { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Anim Create & Insert")); bool create_reset = insert_confirm_reset->is_visible() && insert_confirm_reset->is_pressed(); @@ -4323,6 +4326,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD } } + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); if (create_normal_track) { if (p_create_beziers) { bool valid; @@ -4607,7 +4611,6 @@ void AnimationTrackEditor::_update_tracks() { track_vbox->add_child(track_edit); } - track_edit->set_undo_redo(undo_redo); track_edit->set_timeline(timeline); track_edit->set_root(root); track_edit->set_animation_and_track(animation, i, file_read_only); @@ -4781,6 +4784,7 @@ void AnimationTrackEditor::_update_scroll(double) { } void AnimationTrackEditor::_update_step(double p_new_step) { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Change Animation Step")); float step_value = p_new_step; if (timeline->is_using_fps()) { @@ -4807,6 +4811,7 @@ void AnimationTrackEditor::_dropped_track(int p_from_track, int p_to_track) { } _clear_selection(true); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Rearrange Tracks")); undo_redo->add_do_method(animation.ptr(), "track_move_to", p_from_track, p_to_track); // Take into account that the position of the tracks that come after the one removed will change. @@ -4850,6 +4855,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { case Animation::TYPE_ROTATION_3D: case Animation::TYPE_SCALE_3D: case Animation::TYPE_METHOD: { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Track")); undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), path_to); @@ -4878,6 +4884,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { return; } + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Track")); undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), path_to); @@ -4896,6 +4903,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { return; } + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Track")); undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), path_to); @@ -4920,6 +4928,7 @@ void AnimationTrackEditor::_add_track(int p_type) { void AnimationTrackEditor::_new_track_property_selected(String p_name) { String full_path = String(adding_track_path) + ":" + p_name; + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); if (adding_track_type == Animation::TYPE_VALUE) { Animation::UpdateMode update_mode = Animation::UPDATE_DISCRETE; { @@ -5014,6 +5023,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { p_ofs += 0.001; } + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); switch (animation->track_get_type(p_track)) { case Animation::TYPE_POSITION_3D: { if (!root->has_node(animation->track_get_path(p_track))) { @@ -5169,6 +5179,7 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { } d["args"] = params; + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Method Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", insert_key_from_track_call_track, insert_key_from_track_call_ofs, d); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", insert_key_from_track_call_track, insert_key_from_track_call_ofs); @@ -5284,7 +5295,6 @@ void AnimationTrackEditor::_update_key_edit() { NodePath np; key_edit->hint = _find_hint_for_track(key_edit->track, np); - key_edit->undo_redo = undo_redo; key_edit->base = np; EditorNode::get_singleton()->push_item(key_edit); @@ -5312,13 +5322,9 @@ void AnimationTrackEditor::_update_key_edit() { multi_key_edit->key_ofs_map = key_ofs_map; multi_key_edit->base_map = base_map; multi_key_edit->hint = _find_hint_for_track(first_track, base_map[first_track]); - multi_key_edit->use_fps = timeline->is_using_fps(); - multi_key_edit->root_path = root; - multi_key_edit->undo_redo = undo_redo; - EditorNode::get_singleton()->push_item(multi_key_edit); } } @@ -5349,6 +5355,7 @@ void AnimationTrackEditor::_select_at_anim(const Ref<Animation> &p_anim, int p_t } void AnimationTrackEditor::_move_selection_commit() { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Anim Move Keys")); List<_AnimMoveRestore> to_restore; @@ -5601,6 +5608,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { int start_track = transpose ? _get_track_selected() : top_track; + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Anim Duplicate Keys")); List<Pair<int, float>> new_selection_values; @@ -5831,6 +5839,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } int base_track = animation->get_track_count(); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Paste Tracks")); for (int i = 0; i < track_clipboard.size(); i++) { undo_redo->add_do_method(animation.ptr(), "add_track", track_clipboard[i].track_type); @@ -5902,6 +5911,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { ERR_PRINT("Can't scale to 0"); } + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Anim Scale Keys")); List<_AnimMoveRestore> to_restore; @@ -5983,6 +5993,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { ease_dialog->popup_centered(Size2(200, 100) * EDSCALE); } break; case EDIT_EASE_CONFIRM: { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Make Easing Keys")); Tween::TransitionType transition_type = static_cast<Tween::TransitionType>(transition_selection->get_selected_id()); @@ -6089,6 +6100,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { _anim_duplicate_keys(true); } break; case EDIT_ADD_RESET_KEY: { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Anim Add RESET Keys")); Ref<Animation> reset = _create_and_get_reset_animation(); @@ -6149,6 +6161,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } if (selection.size()) { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Anim Delete Keys")); for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { @@ -6179,6 +6192,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { bake_dialog->popup_centered(Size2(200, 100) * EDSCALE); } break; case EDIT_BAKE_ANIMATION_CONFIRM: { + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Bake Animation as Linear keys.")); int track_len = animation->get_track_count(); @@ -6299,6 +6313,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { animation->optimize(optimize_velocity_error->get_value(), optimize_angular_error->get_value(), optimize_precision_error->get_value()); _redraw_tracks(); _update_key_edit(); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->clear_history(true, undo_redo->get_history_id_for_object(animation.ptr())); undo_redo->clear_history(true, undo_redo->get_history_id_for_object(this)); @@ -6368,6 +6383,7 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { } } + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->clear_history(true, undo_redo->get_history_id_for_object(animation.ptr())); undo_redo->clear_history(true, undo_redo->get_history_id_for_object(this)); _update_tracks(); @@ -6533,8 +6549,6 @@ void AnimationTrackEditor::_pick_track_filter_input(const Ref<InputEvent> &p_ie) } AnimationTrackEditor::AnimationTrackEditor() { - undo_redo = EditorNode::get_undo_redo(); - main_panel = memnew(PanelContainer); main_panel->set_focus_mode(FOCUS_ALL); // Allow panel to have focus so that shortcuts work as expected. add_child(main_panel); @@ -6559,7 +6573,6 @@ AnimationTrackEditor::AnimationTrackEditor() { main_panel->add_child(info_message); timeline = memnew(AnimationTimelineEdit); - timeline->set_undo_redo(undo_redo); timeline_vbox->add_child(timeline); timeline->connect("timeline_changed", callable_mp(this, &AnimationTrackEditor::_timeline_changed)); timeline->connect("name_limit_changed", callable_mp(this, &AnimationTrackEditor::_name_limit_changed)); @@ -6582,7 +6595,6 @@ AnimationTrackEditor::AnimationTrackEditor() { bezier_edit = memnew(AnimationBezierTrackEdit); timeline_vbox->add_child(bezier_edit); - bezier_edit->set_undo_redo(undo_redo); bezier_edit->set_editor(this); bezier_edit->set_timeline(timeline); bezier_edit->hide(); |