From 6c4928fe6927e854045f5b0d4b527e8491779bd4 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Tue, 31 Aug 2021 00:26:40 -0500 Subject: [PATCH] [3.x] Allow disabling the RegEx module in the editor --- SConstruct | 2 +- editor/rename_dialog.cpp | 4 ++++ editor/rename_dialog.h | 7 ++++++- editor/scene_tree_dock.cpp | 14 +++++++++++--- editor/scene_tree_dock.h | 4 ++++ 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/SConstruct b/SConstruct index ca4ee910bb5..1253f68ad2d 100644 --- a/SConstruct +++ b/SConstruct @@ -596,7 +596,7 @@ if selected_platform in platform_list: if env["minizip"]: env.Append(CPPDEFINES=["MINIZIP_ENABLED"]) - editor_module_list = ["freetype", "regex"] + editor_module_list = ["freetype"] for x in editor_module_list: if not env["module_" + x + "_enabled"]: if env["tools"]: diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index ffd8b8a6d9a..b4018b59e64 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -30,6 +30,8 @@ #include "rename_dialog.h" +#ifdef MODULE_REGEX_ENABLED + #include "core/print_string.h" #include "editor_node.h" #include "editor_scale.h" @@ -656,3 +658,5 @@ void RenameDialog::_features_toggled(bool pressed) { size.y = 0; set_size(size); } + +#endif // MODULE_REGEX_ENABLED diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index ac5c17f0e45..dd522c0657f 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -31,6 +31,9 @@ #ifndef RENAME_DIALOG_H #define RENAME_DIALOG_H +#include "modules/modules_enabled.gen.h" +#ifdef MODULE_REGEX_ENABLED + #include "scene/gui/check_box.h" #include "scene/gui/dialogs.h" #include "scene/gui/option_button.h" @@ -114,4 +117,6 @@ public: ~RenameDialog(){}; }; -#endif +#endif // MODULE_REGEX_ENABLED + +#endif // RENAME_DIALOG_H diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 1c02cde1f5d..32a351adaaf 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -82,10 +82,12 @@ void SceneTreeDock::_unhandled_key_input(Ref p_event) { return; } - if (ED_IS_SHORTCUT("scene_tree/batch_rename", p_event)) { - _tool_selected(TOOL_BATCH_RENAME); - } else if (ED_IS_SHORTCUT("scene_tree/rename", p_event)) { + if (ED_IS_SHORTCUT("scene_tree/rename", p_event)) { _tool_selected(TOOL_RENAME); +#ifdef MODULE_REGEX_ENABLED + } else if (ED_IS_SHORTCUT("scene_tree/batch_rename", p_event)) { + _tool_selected(TOOL_BATCH_RENAME); +#endif // MODULE_REGEX_ENABLED } else if (ED_IS_SHORTCUT("scene_tree/add_child_node", p_event)) { _tool_selected(TOOL_NEW); } else if (ED_IS_SHORTCUT("scene_tree/instance_scene", p_event)) { @@ -332,6 +334,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option = p_tool; switch (p_tool) { +#ifdef MODULE_REGEX_ENABLED case TOOL_BATCH_RENAME: { if (!profile_allow_editing) { break; @@ -340,6 +343,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { rename_dialog->popup_centered(); } } break; +#endif // MODULE_REGEX_ENABLED case TOOL_RENAME: { if (!profile_allow_editing) { break; @@ -2811,11 +2815,13 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } } +#ifdef MODULE_REGEX_ENABLED if (profile_allow_editing && selection.size() > 1) { //this is not a commonly used action, it makes no sense for it to be where it was nor always present. menu->add_separator(); menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); } +#endif // MODULE_REGEX_ENABLED menu->add_separator(); menu->add_icon_item(get_icon("Help", "EditorIcons"), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); @@ -3302,8 +3308,10 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel create_dialog->connect("create", this, "_create"); create_dialog->connect("favorites_updated", this, "_update_create_root_dialog"); +#ifdef MODULE_REGEX_ENABLED rename_dialog = memnew(RenameDialog(scene_tree, &editor_data->get_undo_redo())); add_child(rename_dialog); +#endif // MODULE_REGEX_ENABLED script_create_dialog = memnew(ScriptCreateDialog); script_create_dialog->set_inheritance_base_type("Node"); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 3905fb8f9a5..1ec5c263ca7 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -64,7 +64,9 @@ class SceneTreeDock : public VBoxContainer { TOOL_COPY, TOOL_PASTE, TOOL_RENAME, +#ifdef MODULE_REGEX_ENABLED TOOL_BATCH_RENAME, +#endif // MODULE_REGEX_ENABLED TOOL_REPLACE, TOOL_EXTEND_SCRIPT, TOOL_ATTACH_SCRIPT, @@ -108,7 +110,9 @@ class SceneTreeDock : public VBoxContainer { int current_option; CreateDialog *create_dialog; +#ifdef MODULE_REGEX_ENABLED RenameDialog *rename_dialog; +#endif // MODULE_REGEX_ENABLED ToolButton *button_add; ToolButton *button_instance;