From 8a3d2f4e0c452a1d333f45cf106d2397f4c8b873 Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 24 Nov 2022 18:28:49 +0100 Subject: Cleanup remaining EditorUndoRedoManager usages --- editor/plugins/sprite_frames_editor_plugin.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'editor/plugins/sprite_frames_editor_plugin.cpp') diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index cf8cc71db7..6924cb58bf 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -249,6 +249,7 @@ void SpriteFramesEditor::_sheet_add_frames() { const Size2i offset = _get_offset(); const Size2i separation = _get_separation(); + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Frame")); int fc = frames->get_frame_count(edited_anim); @@ -467,6 +468,7 @@ void SpriteFramesEditor::_file_load_request(const Vector &p_path, int p_ return; } + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Frame")); int fc = frames->get_frame_count(edited_anim); @@ -527,6 +529,7 @@ void SpriteFramesEditor::_paste_pressed() { return; ///beh should show an error i guess } + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Paste Frame")); undo_redo->add_do_method(frames, "add_frame", edited_anim, r); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, frames->get_frame_count(edited_anim)); @@ -564,6 +567,7 @@ void SpriteFramesEditor::_empty_pressed() { Ref r; + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Empty")); undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, from); @@ -587,6 +591,7 @@ void SpriteFramesEditor::_empty2_pressed() { Ref r; + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Empty")); undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from + 1); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, from + 1); @@ -610,6 +615,7 @@ void SpriteFramesEditor::_up_pressed() { sel = to_move; sel -= 1; + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Delete Resource")); undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move, frames->get_frame(edited_anim, to_move - 1)); undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move - 1, frames->get_frame(edited_anim, to_move)); @@ -635,6 +641,7 @@ void SpriteFramesEditor::_down_pressed() { sel = to_move; sel += 1; + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Delete Resource")); undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move, frames->get_frame(edited_anim, to_move + 1)); undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move + 1, frames->get_frame(edited_anim, to_move)); @@ -657,6 +664,7 @@ void SpriteFramesEditor::_delete_pressed() { return; } + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Delete Resource")); undo_redo->add_do_method(frames, "remove_frame", edited_anim, to_delete); undo_redo->add_undo_method(frames, "add_frame", edited_anim, frames->get_frame(edited_anim, to_delete), to_delete); @@ -743,6 +751,7 @@ void SpriteFramesEditor::_animation_name_edited() { List nodes; _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(), &nodes, Ref(frames)); + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Rename Animation")); undo_redo->add_do_method(frames, "rename_animation", edited_anim, name); undo_redo->add_undo_method(frames, "rename_animation", name, edited_anim); @@ -772,6 +781,7 @@ void SpriteFramesEditor::_animation_add() { List nodes; _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(), &nodes, Ref(frames)); + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Animation")); undo_redo->add_do_method(frames, "add_animation", name); undo_redo->add_undo_method(frames, "remove_animation", name); @@ -804,6 +814,7 @@ void SpriteFramesEditor::_animation_remove() { } void SpriteFramesEditor::_animation_remove_confirmed() { + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Remove Animation")); undo_redo->add_do_method(frames, "remove_animation", edited_anim); undo_redo->add_undo_method(frames, "add_animation", edited_anim); @@ -831,6 +842,7 @@ void SpriteFramesEditor::_animation_loop_changed() { return; } + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Change Animation Loop")); undo_redo->add_do_method(frames, "set_animation_loop", edited_anim, anim_loop->is_pressed()); undo_redo->add_undo_method(frames, "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim)); @@ -844,6 +856,7 @@ void SpriteFramesEditor::_animation_fps_changed(double p_value) { return; } + Ref &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Change Animation FPS"), UndoRedo::MERGE_ENDS); undo_redo->add_do_method(frames, "set_animation_speed", edited_anim, p_value); undo_redo->add_undo_method(frames, "set_animation_speed", edited_anim, frames->get_animation_speed(edited_anim)); @@ -1035,10 +1048,6 @@ void SpriteFramesEditor::edit(SpriteFrames *p_frames) { delete_frame->set_disabled(read_only); } -void SpriteFramesEditor::set_undo_redo(Ref p_undo_redo) { - undo_redo = p_undo_redo; -} - Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { if (read_only) { return false; @@ -1136,6 +1145,7 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da reorder = true; } + Ref &undo_redo = EditorNode::get_undo_redo(); if (reorder) { //drop is from reordering frames int from_frame = -1; if (d.has("frame")) { @@ -1530,8 +1540,6 @@ SpriteFramesEditor::SpriteFramesEditor() { } void SpriteFramesEditorPlugin::edit(Object *p_object) { - frames_editor->set_undo_redo(get_undo_redo()); - SpriteFrames *s; AnimatedSprite2D *animated_sprite = Object::cast_to(p_object); if (animated_sprite) { -- cgit v1.2.3