You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
Add EditorUndoRedoManager singleton
This commit is contained in:
@@ -107,7 +107,7 @@ bool AnimationTrackKeyEdit::_set(const StringName &p_name, const Variant &p_valu
|
||||
float val = p_value;
|
||||
float prev_val = animation->track_get_key_transition(track, key);
|
||||
setting = true;
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation 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);
|
||||
@@ -119,7 +119,7 @@ bool AnimationTrackKeyEdit::_set(const StringName &p_name, const Variant &p_valu
|
||||
return true;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
switch (animation->track_get_type(track)) {
|
||||
case Animation::TYPE_POSITION_3D:
|
||||
case Animation::TYPE_ROTATION_3D:
|
||||
@@ -704,7 +704,7 @@ bool AnimationMultiTrackKeyEdit::_set(const StringName &p_name, const Variant &p
|
||||
float val = p_value;
|
||||
float prev_val = animation->track_get_key_transition(track, key);
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
if (!setting) {
|
||||
setting = true;
|
||||
undo_redo->create_action(TTR("Animation Multi Change Transition"), UndoRedo::MERGE_ENDS);
|
||||
@@ -714,7 +714,7 @@ bool AnimationMultiTrackKeyEdit::_set(const StringName &p_name, const Variant &p
|
||||
update_obj = true;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
switch (animation->track_get_type(track)) {
|
||||
case Animation::TYPE_POSITION_3D:
|
||||
case Animation::TYPE_ROTATION_3D:
|
||||
@@ -925,7 +925,7 @@ bool AnimationMultiTrackKeyEdit::_set(const StringName &p_name, const Variant &p
|
||||
}
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
if (setting) {
|
||||
if (update_obj) {
|
||||
undo_redo->add_do_method(this, "_update_obj", animation);
|
||||
@@ -1252,7 +1252,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) {
|
||||
}
|
||||
|
||||
editing = true;
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Change Animation Length"), UndoRedo::MERGE_ENDS);
|
||||
undo_redo->add_do_method(animation.ptr(), "set_length", p_new_len);
|
||||
undo_redo->add_undo_method(animation.ptr(), "set_length", animation->get_length());
|
||||
@@ -1265,7 +1265,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Change Animation Loop"));
|
||||
switch (animation->get_loop_mode()) {
|
||||
case Animation::LOOP_NONE: {
|
||||
@@ -2392,7 +2392,7 @@ void AnimationTrackEdit::_zoom_changed() {
|
||||
}
|
||||
|
||||
void AnimationTrackEdit::_path_submitted(const String &p_text) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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));
|
||||
@@ -2630,7 +2630,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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));
|
||||
@@ -3020,7 +3020,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) {
|
||||
case MENU_CALL_MODE_DISCRETE:
|
||||
case MENU_CALL_MODE_CAPTURE: {
|
||||
Animation::UpdateMode update_mode = Animation::UpdateMode(p_index);
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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));
|
||||
@@ -3034,7 +3034,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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));
|
||||
@@ -3044,7 +3044,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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));
|
||||
@@ -3438,7 +3438,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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.
|
||||
@@ -3639,7 +3639,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation Insert Key"));
|
||||
|
||||
Ref<Animation> reset_anim;
|
||||
@@ -3968,7 +3968,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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);
|
||||
@@ -3978,7 +3978,7 @@ Ref<Animation> AnimationTrackEditor::_create_and_get_reset_animation() {
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::_confirm_insert_list() {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation Insert Key"));
|
||||
|
||||
bool create_reset = insert_confirm_reset->is_visible() && insert_confirm_reset->is_pressed();
|
||||
@@ -4148,7 +4148,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
|
||||
}
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
if (create_normal_track) {
|
||||
if (p_create_beziers) {
|
||||
bool valid;
|
||||
@@ -4600,7 +4600,7 @@ void AnimationTrackEditor::_update_scroll(double) {
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::_update_step(double p_new_step) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Change Animation Step"));
|
||||
float step_value = p_new_step;
|
||||
if (timeline->is_using_fps()) {
|
||||
@@ -4627,7 +4627,7 @@ void AnimationTrackEditor::_dropped_track(int p_from_track, int p_to_track) {
|
||||
}
|
||||
|
||||
_clear_selection(true);
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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.
|
||||
@@ -4671,7 +4671,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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);
|
||||
@@ -4700,7 +4700,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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);
|
||||
@@ -4719,7 +4719,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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);
|
||||
@@ -4744,7 +4744,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
if (adding_track_type == Animation::TYPE_VALUE) {
|
||||
Animation::UpdateMode update_mode = Animation::UPDATE_DISCRETE;
|
||||
{
|
||||
@@ -4835,7 +4835,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
|
||||
p_ofs += 0.0001;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
switch (animation->track_get_type(p_track)) {
|
||||
case Animation::TYPE_POSITION_3D: {
|
||||
if (!root->has_node(animation->track_get_path(p_track))) {
|
||||
@@ -4991,7 +4991,7 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) {
|
||||
}
|
||||
d["args"] = params;
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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);
|
||||
@@ -5178,7 +5178,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation Move Keys"));
|
||||
|
||||
List<_AnimMoveRestore> to_restore;
|
||||
@@ -5430,7 +5430,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation Duplicate Keys"));
|
||||
|
||||
List<Pair<int, float>> new_selection_values;
|
||||
@@ -5660,7 +5660,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
||||
}
|
||||
|
||||
int base_track = animation->get_track_count();
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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);
|
||||
@@ -5730,7 +5730,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
||||
float s = scale->get_value();
|
||||
ERR_FAIL_COND_MSG(s == 0, "Can't scale to 0.");
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation Scale Keys"));
|
||||
|
||||
List<_AnimMoveRestore> to_restore;
|
||||
@@ -5810,7 +5810,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Make Easing Keys"));
|
||||
|
||||
Tween::TransitionType transition_type = static_cast<Tween::TransitionType>(transition_selection->get_selected_id());
|
||||
@@ -5917,7 +5917,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation Add RESET Keys"));
|
||||
|
||||
Ref<Animation> reset = _create_and_get_reset_animation();
|
||||
@@ -5978,7 +5978,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
||||
}
|
||||
|
||||
if (selection.size()) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation Delete Keys"));
|
||||
|
||||
for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
|
||||
@@ -6009,7 +6009,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Bake Animation as Linear keys."));
|
||||
|
||||
int track_len = animation->get_track_count();
|
||||
@@ -6130,7 +6130,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();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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));
|
||||
|
||||
@@ -6200,7 +6200,7 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) {
|
||||
}
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
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();
|
||||
@@ -6801,7 +6801,7 @@ void AnimationTrackKeyEditEditor::_time_edit_exited() {
|
||||
}
|
||||
|
||||
int existing = animation->track_find_key(track, new_time, Animation::FIND_MODE_APPROX);
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Animation Change Keyframe Time"), UndoRedo::MERGE_ENDS);
|
||||
|
||||
if (existing != -1) {
|
||||
|
||||
Reference in New Issue
Block a user