mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Cleanup remaining EditorUndoRedoManager usages
This commit is contained in:
parent
cd3d6e63a6
commit
8a3d2f4e0c
59 changed files with 408 additions and 406 deletions
|
@ -1659,6 +1659,7 @@ void VisualShaderEditor::_update_parameters(bool p_update_refs) {
|
|||
}
|
||||
|
||||
void VisualShaderEditor::_update_parameter_refs(HashSet<String> &p_deleted_names) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
for (int i = 0; i < VisualShader::TYPE_MAX; i++) {
|
||||
VisualShader::Type type = VisualShader::Type(i);
|
||||
|
||||
|
@ -1758,6 +1759,7 @@ void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Add Input Port"));
|
||||
undo_redo->add_do_method(node.ptr(), "add_input_port", p_port, p_port_type, p_name);
|
||||
undo_redo->add_undo_method(node.ptr(), "remove_input_port", p_port);
|
||||
|
@ -1773,6 +1775,7 @@ void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_typ
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Add Output Port"));
|
||||
undo_redo->add_do_method(node.ptr(), "add_output_port", p_port, p_port_type, p_name);
|
||||
undo_redo->add_undo_method(node.ptr(), "remove_output_port", p_port);
|
||||
|
@ -1788,6 +1791,7 @@ void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_p
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Change Input Port Type"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_input_port_type", p_port, p_type);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_input_port_type", p_port, node->get_input_port_type(p_port));
|
||||
|
@ -1803,6 +1807,7 @@ void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Change Output Port Type"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_output_port_type", p_port, p_type);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_output_port_type", p_port, node->get_output_port_type(p_port));
|
||||
|
@ -1831,6 +1836,7 @@ void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *p
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Change Input Port Name"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_input_port_name", p_port_id, validated_name);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_input_port_name", p_port_id, node->get_input_port_name(p_port_id));
|
||||
|
@ -1857,6 +1863,7 @@ void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Change Output Port Name"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_output_port_name", p_port_id, validated_name);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_output_port_name", p_port_id, prev_name);
|
||||
|
@ -1869,6 +1876,7 @@ void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expa
|
|||
Ref<VisualShaderNode> node = visual_shader->get_node(type, p_node);
|
||||
ERR_FAIL_COND(!node.is_valid());
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
if (p_expand) {
|
||||
undo_redo->create_action(TTR("Expand Output Port"));
|
||||
} else {
|
||||
|
@ -1966,6 +1974,7 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Remove Input Port"));
|
||||
|
||||
List<VisualShader::Connection> conns;
|
||||
|
@ -2015,6 +2024,7 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Remove Output Port"));
|
||||
|
||||
List<VisualShader::Connection> conns;
|
||||
|
@ -2081,6 +2091,7 @@ void VisualShaderEditor::_expression_focus_out(Object *code_edit, int p_node) {
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Set VisualShader Expression"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_expression", expression_box->get_text());
|
||||
undo_redo->add_undo_method(node.ptr(), "set_expression", node->get_expression());
|
||||
|
@ -2144,6 +2155,7 @@ void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, in
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Resize VisualShader Node"), UndoRedo::MERGE_ENDS);
|
||||
undo_redo->add_do_method(this, "_set_node_size", p_type, p_node, p_new_size);
|
||||
undo_redo->add_undo_method(this, "_set_node_size", p_type, p_node, node->get_size());
|
||||
|
@ -2160,6 +2172,7 @@ void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {
|
|||
if (node->get_output_port_for_preview() == p_port) {
|
||||
p_port = -1; //toggle it
|
||||
}
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(p_port == -1 ? TTR("Hide Port Preview") : TTR("Show Port Preview"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_output_port_for_preview", p_port);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_output_port_for_preview", prev_port);
|
||||
|
@ -2205,6 +2218,7 @@ void VisualShaderEditor::_comment_title_popup_hide() {
|
|||
if (node->get_title() == comment_title_change_edit->get_text()) {
|
||||
return; // nothing changed - ignored
|
||||
}
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Set Comment Node Title"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_title", comment_title_change_edit->get_text());
|
||||
undo_redo->add_undo_method(node.ptr(), "set_title", node->get_title());
|
||||
|
@ -2247,6 +2261,7 @@ void VisualShaderEditor::_comment_desc_popup_hide() {
|
|||
if (node->get_description() == comment_desc_change_edit->get_text()) {
|
||||
return; // nothing changed - ignored
|
||||
}
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Set Comment Node Description"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_description", comment_desc_change_edit->get_text());
|
||||
undo_redo->add_undo_method(node.ptr(), "set_description", node->get_title());
|
||||
|
@ -2267,6 +2282,7 @@ void VisualShaderEditor::_parameter_line_edit_changed(const String &p_text, int
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Set Parameter Name"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_parameter_name", validated_name);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_parameter_name", node->get_parameter_name());
|
||||
|
@ -2302,6 +2318,7 @@ void VisualShaderEditor::_port_edited(const StringName &p_property, const Varian
|
|||
Ref<VisualShaderNode> vsn = visual_shader->get_node(type, editing_node);
|
||||
ERR_FAIL_COND(!vsn.is_valid());
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Set Input Default Port"));
|
||||
|
||||
Ref<VisualShaderNodeCustom> custom = Object::cast_to<VisualShaderNodeCustom>(vsn.ptr());
|
||||
|
@ -2725,6 +2742,7 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
|
|||
|
||||
int id_to_use = visual_shader->get_valid_node_id(type);
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
if (p_resource_path.is_empty()) {
|
||||
undo_redo->create_action(TTR("Add Node to Visual Shader"));
|
||||
} else {
|
||||
|
@ -2894,6 +2912,7 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
|
|||
}
|
||||
|
||||
void VisualShaderEditor::_add_varying(const String &p_name, VisualShader::VaryingMode p_mode, VisualShader::VaryingType p_type) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(vformat(TTR("Add Varying to Visual Shader: %s"), p_name));
|
||||
|
||||
undo_redo->add_do_method(visual_shader.ptr(), "add_varying", p_name, p_mode, p_type);
|
||||
|
@ -2928,6 +2947,7 @@ void VisualShaderEditor::_add_varying(const String &p_name, VisualShader::Varyin
|
|||
}
|
||||
|
||||
void VisualShaderEditor::_remove_varying(const String &p_name) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(vformat(TTR("Remove Varying from Visual Shader: %s"), p_name));
|
||||
|
||||
VisualShader::VaryingMode var_mode = visual_shader->get_varying_mode(p_name);
|
||||
|
@ -3015,6 +3035,7 @@ void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_t
|
|||
void VisualShaderEditor::_nodes_dragged() {
|
||||
drag_dirty = false;
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Node(s) Moved"));
|
||||
|
||||
for (const DragOp &E : drag_buffer) {
|
||||
|
@ -3038,6 +3059,7 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Nodes Connected"));
|
||||
|
||||
List<VisualShader::Connection> conns;
|
||||
|
@ -3069,6 +3091,7 @@ void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from
|
|||
int from = p_from.to_int();
|
||||
int to = p_to.to_int();
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Nodes Disconnected"));
|
||||
undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from, p_from_index, to, p_to_index);
|
||||
undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, from, p_from_index, to, p_to_index);
|
||||
|
@ -3108,6 +3131,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) {
|
|||
List<VisualShader::Connection> conns;
|
||||
visual_shader->get_node_connections(type, &conns);
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
for (const int &F : p_nodes) {
|
||||
for (const VisualShader::Connection &E : conns) {
|
||||
if (E.from_node == F || E.to_node == F) {
|
||||
|
@ -3180,6 +3204,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) {
|
|||
}
|
||||
|
||||
void VisualShaderEditor::_replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->add_do_method(visual_shader.ptr(), "replace_node", p_type_id, p_node_id, p_to);
|
||||
undo_redo->add_undo_method(visual_shader.ptr(), "replace_node", p_type_id, p_node_id, p_from);
|
||||
}
|
||||
|
@ -3214,6 +3239,7 @@ void VisualShaderEditor::_update_parameter(VisualShader::Type p_type_id, int p_n
|
|||
void VisualShaderEditor::_convert_constants_to_parameters(bool p_vice_versa) {
|
||||
VisualShader::Type type_id = get_current_shader_type();
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
if (!p_vice_versa) {
|
||||
undo_redo->create_action(TTR("Convert Constant Node(s) To Parameter(s)"));
|
||||
} else {
|
||||
|
@ -3412,6 +3438,7 @@ void VisualShaderEditor::_delete_node_request(int p_type, int p_node) {
|
|||
List<int> to_erase;
|
||||
to_erase.push_back(p_node);
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Delete VisualShader Node"));
|
||||
_delete_nodes(p_type, to_erase);
|
||||
undo_redo->commit_action();
|
||||
|
@ -3440,6 +3467,7 @@ void VisualShaderEditor::_delete_nodes_request(const TypedArray<StringName> &p_n
|
|||
return;
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Delete VisualShader Node(s)"));
|
||||
_delete_nodes(get_current_shader_type(), to_erase);
|
||||
undo_redo->commit_action();
|
||||
|
@ -3852,6 +3880,7 @@ void VisualShaderEditor::_dup_copy_nodes(int p_type, List<CopyItem> &r_items, Li
|
|||
}
|
||||
|
||||
void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, const List<VisualShader::Connection> &p_connections, const Vector2 &p_offset, bool p_duplicate) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
if (p_duplicate) {
|
||||
undo_redo->create_action(TTR("Duplicate VisualShader Node(s)"));
|
||||
} else {
|
||||
|
@ -3970,6 +3999,7 @@ void VisualShaderEditor::_copy_nodes(bool p_cut) {
|
|||
_dup_copy_nodes(get_current_shader_type(), copy_items_buffer, copy_connections_buffer);
|
||||
|
||||
if (p_cut) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Cut VisualShader Node(s)"));
|
||||
|
||||
List<int> ids;
|
||||
|
@ -4240,6 +4270,7 @@ void VisualShaderEditor::_float_constant_selected(int p_which) {
|
|||
return; // same
|
||||
}
|
||||
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(vformat(TTR("Set Constant: %s"), float_constant_defs[p_which].name));
|
||||
undo_redo->add_do_method(node.ptr(), "set_constant", float_constant_defs[p_which].value);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_constant", node->get_constant());
|
||||
|
@ -4500,6 +4531,7 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
|
|||
saved_node_pos_dirty = true;
|
||||
_add_node(idx, add_options[idx].ops);
|
||||
} else if (d.has("files")) {
|
||||
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("Add Node(s) to Visual Shader"));
|
||||
|
||||
if (d["files"].get_type() == Variant::PACKED_STRING_ARRAY) {
|
||||
|
@ -5675,8 +5707,6 @@ VisualShaderEditor::VisualShaderEditor() {
|
|||
|
||||
_update_options_menu();
|
||||
|
||||
undo_redo = EditorNode::get_undo_redo();
|
||||
|
||||
Ref<VisualShaderNodePluginDefault> default_plugin;
|
||||
default_plugin.instantiate();
|
||||
default_plugin->set_editor(this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue